fixed a few jshint errors
This commit is contained in:
@ -36,6 +36,6 @@
|
|||||||
"tar": "~0.1.18"
|
"tar": "~0.1.18"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test"
|
"test": "grunt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
|
var fs = require('fs');
|
||||||
/**
|
/**
|
||||||
* Stupid simple recursive file/directory clearing. Nothing serious.
|
* 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 _ = require('../../../src/lib/utils');
|
||||||
var asset = require('assert');
|
var asset = require('assert');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
@ -9,6 +7,8 @@ var templates = require('./templates');
|
|||||||
var clean = require('../../clean');
|
var clean = require('../../clean');
|
||||||
var urlParamRE = /\{(\w+)\}/g;
|
var urlParamRE = /\{(\w+)\}/g;
|
||||||
|
|
||||||
|
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
|
||||||
|
|
||||||
require('./spec').on('ready', function (specs) {
|
require('./spec').on('ready', function (specs) {
|
||||||
var defs = [];
|
var defs = [];
|
||||||
var namespaces = [];
|
var namespaces = [];
|
||||||
@ -22,6 +22,7 @@ require('./spec').on('ready', function (specs) {
|
|||||||
var requiredVars = {};
|
var requiredVars = {};
|
||||||
var param;
|
var param;
|
||||||
var target;
|
var target;
|
||||||
|
var match;
|
||||||
|
|
||||||
if (url.charAt(0) !== '/') {
|
if (url.charAt(0) !== '/') {
|
||||||
url = '/' + url;
|
url = '/' + url;
|
||||||
@ -36,8 +37,8 @@ require('./spec').on('ready', function (specs) {
|
|||||||
[requiredVars, optionalVars].forEach(function (vars) {
|
[requiredVars, optionalVars].forEach(function (vars) {
|
||||||
_.each(vars, function (v, name) {
|
_.each(vars, function (v, name) {
|
||||||
vars[name] = _.omit(v, 'description');
|
vars[name] = _.omit(v, 'description');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
note.push(_.omit({
|
note.push(_.omit({
|
||||||
fmt: url.replace(urlParamRE, '<%=$1%>'),
|
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 EventEmitter = require('events').EventEmitter;
|
||||||
var aliases = require('./aliases');
|
var aliases = require('./aliases');
|
||||||
@ -7,6 +7,7 @@ var castNotFoundRE = /exists/;
|
|||||||
var usesBulkBodyRE = /^(bulk|msearch)$/;
|
var usesBulkBodyRE = /^(bulk|msearch)$/;
|
||||||
|
|
||||||
var specCount = 0;
|
var specCount = 0;
|
||||||
|
var completedSpecs = [];
|
||||||
var doneParsing = false;
|
var doneParsing = false;
|
||||||
|
|
||||||
require('../../get_spec')
|
require('../../get_spec')
|
||||||
@ -14,12 +15,10 @@ require('../../get_spec')
|
|||||||
.on('entry', transformFile)
|
.on('entry', transformFile)
|
||||||
.on('end', function () {
|
.on('end', function () {
|
||||||
doneParsing = true;
|
doneParsing = true;
|
||||||
if (specs.length === specCount) {
|
if (completedSpecs.length === specCount) {
|
||||||
module.exports.emit('ready', specs);
|
module.exports.emit('ready', completedSpecs);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
var specs = [];
|
|
||||||
|
|
||||||
function transformFile(entry) {
|
function transformFile(entry) {
|
||||||
specCount++;
|
specCount++;
|
||||||
@ -50,10 +49,10 @@ function transformFile(entry) {
|
|||||||
if (castNotFoundRE.test(name)) {
|
if (castNotFoundRE.test(name)) {
|
||||||
spec.castNotFound = true;
|
spec.castNotFound = true;
|
||||||
}
|
}
|
||||||
if (specs.push(spec) === specCount && doneParsing) {
|
if (completedSpecs.push(spec) === specCount && doneParsing) {
|
||||||
module.exports.emit('ready', specs);
|
module.exports.emit('ready', completedSpecs);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new EventEmitter();
|
module.exports = new EventEmitter();
|
||||||
|
|||||||
@ -66,7 +66,7 @@ function stringify(thing, pretty) {
|
|||||||
// remove quotes around key names that are only made up of letters
|
// remove quotes around key names that are only made up of letters
|
||||||
.replace(/^( +)'([a-zA-Z_]+)':/gm, '$1$2:')
|
.replace(/^( +)'([a-zA-Z_]+)':/gm, '$1$2:')
|
||||||
// requote "special" key names
|
// requote "special" key names
|
||||||
.replace(/^( +)(default):/gm, '$1\'$2\':')
|
.replace(/^( +)(default):/gm, '$1\'$2\':');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/*jshint maxlen:false, white:false, -W116:false, quotmark:false, -W018:false, -W064:false */
|
||||||
(function() {
|
(function() {
|
||||||
var Set, Stochator, callFunctions, floatGenerator, integerGenerator, inverseNormalCumulativeDistribution, isType, randomBoundedFloat, randomBoundedInteger, randomCharacter, randomColor, randomNormallyDistributedFloat, randomSetMember, randomSetMemberWithoutReplacement, randomWeightedSetMember, setGenerator, shuffleSet,
|
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; },
|
__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 stream = new EventEmitter();
|
||||||
var matcher = new Minimatch(pattern);
|
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) {
|
if (incoming.statusCode !== 200) {
|
||||||
req.abort();
|
req.abort();
|
||||||
if (incoming.headers.location) {
|
if (incoming.headers.location) {
|
||||||
@ -21,10 +21,10 @@ exports.get = function (pattern) {
|
|||||||
url.parse(tarUrl),
|
url.parse(tarUrl),
|
||||||
url.parse(incoming.headers.location)
|
url.parse(incoming.headers.location)
|
||||||
),
|
),
|
||||||
receiveZip
|
receiveTarBall
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.error('request failed', incoming.statusCode, incoming.headers)
|
console.error('request failed', incoming.statusCode, incoming.headers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
incoming.pipe(zlib.createGunzip()).pipe(tar.Parse())
|
incoming.pipe(zlib.createGunzip()).pipe(tar.Parse())
|
||||||
@ -45,7 +45,7 @@ exports.get = function (pattern) {
|
|||||||
function collectData(entry) {
|
function collectData(entry) {
|
||||||
entry.data = '';
|
entry.data = '';
|
||||||
|
|
||||||
entry.on('data', onData)
|
entry.on('data', onData);
|
||||||
entry.on('end', onEnd);
|
entry.on('end', onEnd);
|
||||||
|
|
||||||
function onData(chunk) {
|
function onData(chunk) {
|
||||||
|
|||||||
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,
|
maxRetries: 3,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
deadTimeout: 60000,
|
deadTimeout: 60000,
|
||||||
|
maxSockets: 10,
|
||||||
nodesToHostCallback: function (nodes) {
|
nodesToHostCallback: function (nodes) {
|
||||||
var hosts = [];
|
var hosts = [];
|
||||||
_.each(nodes, function (node, id) {
|
_.each(nodes, function (node, id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user