fixed a few jshint errors
This commit is contained in:
@ -36,6 +36,6 @@
|
||||
"tar": "~0.1.18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
"test": "grunt"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
|
||||
var fs = require('fs');
|
||||
/**
|
||||
* Stupid simple recursive file/directory clearing. Nothing serious.
|
||||
*
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
|
||||
|
||||
var _ = require('../../../src/lib/utils');
|
||||
var asset = require('assert');
|
||||
var path = require('path');
|
||||
@ -9,6 +7,8 @@ var templates = require('./templates');
|
||||
var clean = require('../../clean');
|
||||
var urlParamRE = /\{(\w+)\}/g;
|
||||
|
||||
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
|
||||
|
||||
require('./spec').on('ready', function (specs) {
|
||||
var defs = [];
|
||||
var namespaces = [];
|
||||
@ -22,6 +22,7 @@ require('./spec').on('ready', function (specs) {
|
||||
var requiredVars = {};
|
||||
var param;
|
||||
var target;
|
||||
var match;
|
||||
|
||||
if (url.charAt(0) !== '/') {
|
||||
url = '/' + url;
|
||||
@ -36,8 +37,8 @@ require('./spec').on('ready', function (specs) {
|
||||
[requiredVars, optionalVars].forEach(function (vars) {
|
||||
_.each(vars, function (v, name) {
|
||||
vars[name] = _.omit(v, 'description');
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
note.push(_.omit({
|
||||
fmt: url.replace(urlParamRE, '<%=$1%>'),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var _ = require('../../../src/lib/utils')
|
||||
var _ = require('../../../src/lib/utils');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var aliases = require('./aliases');
|
||||
@ -7,6 +7,7 @@ var castNotFoundRE = /exists/;
|
||||
var usesBulkBodyRE = /^(bulk|msearch)$/;
|
||||
|
||||
var specCount = 0;
|
||||
var completedSpecs = [];
|
||||
var doneParsing = false;
|
||||
|
||||
require('../../get_spec')
|
||||
@ -14,12 +15,10 @@ require('../../get_spec')
|
||||
.on('entry', transformFile)
|
||||
.on('end', function () {
|
||||
doneParsing = true;
|
||||
if (specs.length === specCount) {
|
||||
module.exports.emit('ready', specs);
|
||||
if (completedSpecs.length === specCount) {
|
||||
module.exports.emit('ready', completedSpecs);
|
||||
}
|
||||
})
|
||||
|
||||
var specs = [];
|
||||
});
|
||||
|
||||
function transformFile(entry) {
|
||||
specCount++;
|
||||
@ -50,10 +49,10 @@ function transformFile(entry) {
|
||||
if (castNotFoundRE.test(name)) {
|
||||
spec.castNotFound = true;
|
||||
}
|
||||
if (specs.push(spec) === specCount && doneParsing) {
|
||||
module.exports.emit('ready', specs);
|
||||
if (completedSpecs.push(spec) === specCount && doneParsing) {
|
||||
module.exports.emit('ready', completedSpecs);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = new EventEmitter();
|
||||
|
||||
@ -66,7 +66,7 @@ function stringify(thing, pretty) {
|
||||
// remove quotes around key names that are only made up of letters
|
||||
.replace(/^( +)'([a-zA-Z_]+)':/gm, '$1$2:')
|
||||
// requote "special" key names
|
||||
.replace(/^( +)(default):/gm, '$1\'$2\':')
|
||||
.replace(/^( +)(default):/gm, '$1\'$2\':');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3365,5 +3365,5 @@ module.exports = [
|
||||
[40.70644889, -76.37314667],
|
||||
[28.22806472, -82.15591639],
|
||||
[35.08322694, -108.7917769],
|
||||
[39.94445833,-81.89210528]
|
||||
[39.94445833, -81.89210528]
|
||||
];
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*jshint maxlen:false, white:false, -W116:false, quotmark:false, -W018:false, -W064:false */
|
||||
(function() {
|
||||
var Set, Stochator, callFunctions, floatGenerator, integerGenerator, inverseNormalCumulativeDistribution, isType, randomBoundedFloat, randomBoundedInteger, randomCharacter, randomColor, randomNormallyDistributedFloat, randomSetMember, randomSetMemberWithoutReplacement, randomWeightedSetMember, setGenerator, shuffleSet,
|
||||
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
|
||||
@ -12,7 +12,7 @@ exports.get = function (pattern) {
|
||||
var stream = new EventEmitter();
|
||||
var matcher = new Minimatch(pattern);
|
||||
|
||||
var req = https.get(tarUrl, function receiveZip (incoming) {
|
||||
var req = https.get(tarUrl, function receiveTarBall(incoming) {
|
||||
if (incoming.statusCode !== 200) {
|
||||
req.abort();
|
||||
if (incoming.headers.location) {
|
||||
@ -21,10 +21,10 @@ exports.get = function (pattern) {
|
||||
url.parse(tarUrl),
|
||||
url.parse(incoming.headers.location)
|
||||
),
|
||||
receiveZip
|
||||
receiveTarBall
|
||||
);
|
||||
} else {
|
||||
console.error('request failed', incoming.statusCode, incoming.headers)
|
||||
console.error('request failed', incoming.statusCode, incoming.headers);
|
||||
}
|
||||
} else {
|
||||
incoming.pipe(zlib.createGunzip()).pipe(tar.Parse())
|
||||
@ -45,14 +45,14 @@ exports.get = function (pattern) {
|
||||
function collectData(entry) {
|
||||
entry.data = '';
|
||||
|
||||
entry.on('data', onData)
|
||||
entry.on('data', onData);
|
||||
entry.on('end', onEnd);
|
||||
|
||||
function onData (chunk) {
|
||||
function onData(chunk) {
|
||||
entry.data += chunk;
|
||||
}
|
||||
|
||||
function onEnd () {
|
||||
function onEnd() {
|
||||
entry.removeListener('data', onData);
|
||||
entry.removeListener('end', onEnd);
|
||||
stream.emit('entry', entry);
|
||||
|
||||
46
scripts/stupid-benchmark.js
Normal file
46
scripts/stupid-benchmark.js
Normal file
@ -0,0 +1,46 @@
|
||||
var es = require('../src/elasticsearch');
|
||||
var async = require('async');
|
||||
|
||||
function getMs() {
|
||||
var hr = process.hrtime();
|
||||
return (hr[0] * 1e9 + hr[1]) / 1e6;
|
||||
}
|
||||
|
||||
var client = new es.Client({
|
||||
hosts: 'localhost:9200',
|
||||
log: null,
|
||||
maxSockets: 100
|
||||
});
|
||||
|
||||
console.log('clearing existing "test-docs" indices');
|
||||
|
||||
async.series([
|
||||
function (done) {
|
||||
client.indices.delete({
|
||||
index: 'test-docs',
|
||||
ignore: 404
|
||||
}, done);
|
||||
},
|
||||
function (done) {
|
||||
client.cluster.health({
|
||||
wait_for_status: 'yellow'
|
||||
}, done);
|
||||
},
|
||||
function (done) {
|
||||
var times = 1e4;
|
||||
console.log('creating %d docs', times);
|
||||
var start = getMs();
|
||||
async.times(times, function (i, done) {
|
||||
client.index({
|
||||
index: 'test-docs',
|
||||
type: 'test-doc',
|
||||
body: {}
|
||||
}, done);
|
||||
}, function (err) {
|
||||
console.log('complete in', Math.round((getMs() - start) * 100) / 100, 'ms');
|
||||
if (err) {
|
||||
client.config.log.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
]);
|
||||
@ -33,6 +33,7 @@ var defaultConfig = {
|
||||
maxRetries: 3,
|
||||
timeout: 10000,
|
||||
deadTimeout: 60000,
|
||||
maxSockets: 10,
|
||||
nodesToHostCallback: function (nodes) {
|
||||
var hosts = [];
|
||||
_.each(nodes, function (node, id) {
|
||||
|
||||
Reference in New Issue
Block a user