final sweep, moved everything to _v4

This commit is contained in:
spalger
2016-05-19 14:23:33 -07:00
parent 4a77556866
commit ec06c51c5d
78 changed files with 542 additions and 542 deletions

View File

@ -1,5 +1,3 @@
'use strict';
module.exports = function (grunt) {
// load plugins
require('load-grunt-config')(grunt, {

View File

@ -2,4 +2,4 @@ module.exports = {
dist: {
src: ['<%= distDir %>']
}
};
};

View File

@ -11,8 +11,8 @@ function archive(out) {
}
module.exports = {
master_zip: archive('elasticsearch-js-master.zip'),
master_tarball: archive('elasticsearch-js-master.tar.gz'),
release_zip: archive('elasticsearch-js-<%= package.version %>.zip'),
release_tarball: archive('elasticsearch-js-<%= package.version %>.tar.gz')
};
master_zip: archive('elasticsearch-js-master.zip'),
master_tarball: archive('elasticsearch-js-master.tar.gz'),
release_zip: archive('elasticsearch-js-<%= package.version %>.zip'),
release_tarball: archive('elasticsearch-js-<%= package.version %>.tar.gz')
};

View File

@ -15,4 +15,4 @@ module.exports = {
footer: '\n}());'
}
}
};
};

View File

@ -11,4 +11,4 @@ module.exports = {
dest: '<%= bowerSubmodule %>',
expand: true
}
};
};

View File

@ -1,11 +1,11 @@
var _ = require('lodash-migrate');
// var _ = require('lodash');
var utils = require('../utils');
var fromRoot = require('path').join.bind(null, __dirname, '..', '..');
var release = process.env.ES_RELEASE;
var ref = process.env.ES_REF;
var port = parseFloat(_.get(process.env, 'ES_PORT', 9400));
var host = _.get(process.env, 'ES_HOST', 'localhost');
var port = parseFloat(_v4.get(process.env, 'ES_PORT', 9400));
var host = _v4.get(process.env, 'ES_HOST', 'localhost');
var Version = require('../../scripts/Version');
var versionedOpts = [

View File

@ -1,7 +1,7 @@
var root = require('find-root')(__dirname);
var rel = require('path').resolve.bind(null, root);
var rootReq = function (p) { return require(rel(p)); };
var _ = rootReq('src/lib/utils');
// var _ = rootReq('src/lib/utils');
var grunt = require('grunt');
var JENKINS_REPORTER = rel('test/utils/jenkins-reporter.js');
@ -65,7 +65,7 @@ var config = {
grunt.registerTask('mocha_integration', function (branch) {
grunt.config.set(
'mochacov.integration.src',
'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'
'test/integration/yaml_suite/index_' + _v4.snakeCase(branch) + '.js'
);
grunt.task.run('mochacov:integration');
});
@ -73,7 +73,7 @@ grunt.registerTask('mocha_integration', function (branch) {
grunt.registerTask('mocha_jenkins_integration', function (branch) {
grunt.config.set(
'mochacov.jenkins_integration.src',
'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'
'test/integration/yaml_suite/index_' + _v4.snakeCase(branch) + '.js'
);
grunt.task.run('mochacov:jenkins_integration');
});

View File

@ -3,4 +3,4 @@ module.exports = {
path: 'coverage.html',
app: 'Google Chrome'
}
};
};

View File

@ -9,4 +9,4 @@ module.exports = {
}]
}
}
};
};

View File

@ -22,4 +22,4 @@ module.exports = {
}
}
}
};
};

View File

@ -33,4 +33,4 @@ module.exports = {
]
}
}
};
};

View File

@ -1,4 +1,4 @@
var _ = require('../src/lib/utils');
// var _ = require('../src/lib/utils');
var root = require('find-root')(__dirname);
var pkg = require(root + '/package.json');
@ -8,7 +8,7 @@ var branches = [].concat(stable, unstable);
var utils = {
branchSuffix: function (branch) {
return branch === utils.branches._default ? '' : '_' + _.snakeCase(branch);
return branch === utils.branches._default ? '' : '_' + _v4.snakeCase(branch);
},
branches: branches,
stableBranches: stable,

View File

@ -108,7 +108,7 @@
"test": "grunt test",
"generate": "node scripts/generate",
"grunt": "grunt",
"eslint": "eslint src scripts test"
"eslint": "eslint src scripts test grunt Gruntfile.js"
},
"engines": {
"node": ">=0.8"

View File

@ -1,4 +1,4 @@
var _ = require('lodash-migrate');
// var _ = require('lodash');
var pkg = require('../package.json');
var branches = pkg.config.supported_es_branches;
var semver = require('semver');
@ -47,10 +47,10 @@ Version.prototype.mergeOpts = function (opts) {
return opts.filter(function (rule) {
return self.satisfies(rule.version);
})
.map(_.ary(_.partialRight(_.omit, 'version'), 1))
.concat(_.tail(arguments))
.map(_v4.ary(_v4.partialRight(_v4.omit, 'version'), 1))
.concat(_v4.tail(arguments))
.reverse()
.reduce(_.merge, {});
.reduce(_v4.merge, {});
};
module.exports = Version;

View File

@ -18,7 +18,7 @@
*******/
var Promise = require('bluebird');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var through2 = require('through2');
var map = require('through2-map');
var split = require('split');
@ -80,7 +80,7 @@ task('SAUCE_LABS', false, function () {
}));
})
// ignore server errors
.catch(_.noop);
.catch(_v4.noop);
// attempt to run tests on saucelabs and retry if it fails
var saucelabsAttempts = 0;
@ -116,7 +116,7 @@ task('SAUCE_LABS', false, function () {
});
})
// swallow spawn() errors, custom error handler in place
.catch(_.noop);
.catch(_v4.noop);
});
}
});
@ -168,7 +168,7 @@ execTask('SETUP', function () {
})
.then(function readTasks() {
if (!ENV.RUN) {
return _.where(TASKS, { default: true });
return _v4.filter(TASKS, { default: true });
}
return ENV.RUN
@ -218,7 +218,7 @@ function logImportant(text) {
function push(m) {
return function () {
var args = _.toArray(arguments);
var args = _v4.toArray(arguments);
var cb = args.pop();
this.push(m.apply(this, args));
cb();
@ -235,7 +235,7 @@ function indent() {
}
function task(name, def, fn) {
if (_.isFunction(def)) {
if (_v4.isFunction(def)) {
fn = def;
def = true;
}
@ -248,7 +248,7 @@ function task(name, def, fn) {
}
function execTask(name, task) {
if (_.isObject(name)) {
if (_v4.isObject(name)) {
task = name.fn;
name = name.name;
}
@ -316,13 +316,13 @@ function spawn(file, args, block) {
function node(/* args... */) {
return spawn(
process.execPath,
_.toArray(arguments)
_v4.toArray(arguments)
);
}
function grunt(/* args... */) {
return spawn(
GRUNT,
_.toArray(arguments)
_v4.toArray(arguments)
);
}

View File

@ -1,9 +1,9 @@
module.exports = function (done) {
var _ = require('../../src/lib/utils');
// var _ = require('../../src/lib/utils');
var utils = require('../../grunt/utils');
var chalk = require('chalk');
var fromRoot = _.partial(require('path').join, require('find-root')(__dirname));
var fromRoot = _v4.partial(require('path').join, require('find-root')(__dirname));
var write = require('fs').writeFileSync;
var nodeApiIndex = fromRoot('src/lib/apis/index.js');

View File

@ -1,8 +1,8 @@
module.exports = function (done) {
var _ = require('../../src/lib/utils');
// var _ = require('../../src/lib/utils');
var chalk = require('chalk');
var fromRoot = _.partial(require('path').join, require('find-root')(__dirname));
var fromRoot = _v4.partial(require('path').join, require('find-root')(__dirname));
var write = require('fs').writeFile;
var outputPath = fromRoot('docs/configuration.asciidoc');

View File

@ -1,9 +1,9 @@
module.exports = function (done) {
var _ = require('../../src/lib/utils');
// var _ = require('../../src/lib/utils');
var utils = require('../../grunt/utils');
var chalk = require('chalk');
var fromRoot = _.partial(require('path').join, require('find-root')(__dirname));
var fromRoot = _v4.partial(require('path').join, require('find-root')(__dirname));
var write = require('fs').writeFile;
var outputPath = fromRoot('docs/index.asciidoc');

View File

@ -30,7 +30,7 @@ var argv = require('optimist')
var path = require('path');
var fromRoot = path.join.bind(path, require('find-root')(__dirname));
var utils = require(fromRoot('grunt/utils'));
var _ = require(fromRoot('src/lib/utils'));
// var _ = require(fromRoot('src/lib/utils'));
var esUrl = 'https://github.com/elastic/elasticsearch.git';
var branches;
@ -56,10 +56,10 @@ var paths = {
docsIndex: fromRoot('docs/index.asciidoc'),
apiSrc: 'src/lib/apis',
getArchiveDir: function (branch) {
return fromRoot('src/_elasticsearch_' + _.snakeCase(branch));
return fromRoot('src/_elasticsearch_' + _v4.snakeCase(branch));
},
getArchiveTarball: function (branch) {
return fromRoot('src/_elasticsearch_' + _.snakeCase(branch) + '.tar');
return fromRoot('src/_elasticsearch_' + _v4.snakeCase(branch) + '.tar');
},
getSpecPathInRepo: function (branch) {
return /^v?(master|[2-9]\.)/.test(branch) ? 'rest-api-spec/src/main/resources/rest-api-spec' : 'rest-api-spec';
@ -93,9 +93,9 @@ function dirRegex(dir, regexp) {
}
function dirOpts(dir, opts) {
opts = _.isArray(opts) ? opts : [opts];
opts = _v4.isArray(opts) ? opts : [opts];
return dirFilter(dir, function (name) {
return _.includes(opts, name);
return _v4.includes(opts, name);
});
}
@ -130,7 +130,7 @@ function fetchBranchesStep() {
function findGeneratedApiFiles() {
var anyApiMethodDocs = /^(configuration|index|api_methods).*\.asciidoc$/;
var anyApiJsFiled = /^.+\.js$/;
var allBranches = _.isEqual(branches, utils.branches);
var allBranches = _v4.isEqual(branches, utils.branches);
if (allBranches) {
return [
@ -140,7 +140,7 @@ function findGeneratedApiFiles() {
}
return branches.reduce(function (files, branch) {
var b = _.snakeCase(branch);
var b = _v4.snakeCase(branch);
files.push(dirOpts(paths.docs, 'api_methods_' + b + '.asciidoc'));
@ -166,7 +166,7 @@ function clearGeneratedFiles() {
generatedFiles.push(dirRegex(paths.src, esArchives));
var rmSteps = _.chain(generatedFiles)
var rmSteps = _v4.chain(generatedFiles)
.flattenDeep()
.uniq()
.map(function (path) {
@ -195,7 +195,7 @@ function createArchive(branch) {
var dir = paths.getArchiveDir(branch);
var tarball = paths.getArchiveTarball(branch);
var specPathInRepo = paths.getSpecPathInRepo(branch);
var subDirCount = _.countBy(specPathInRepo, _.partial(_.eq, '/')).true || 0;
var subDirCount = _v4.countBy(specPathInRepo, _v4.partial(_v4.eq, '/')).true || 0;
if (isDirectory(dir)) {
console.log(branch + ' archive already exists');
@ -227,7 +227,7 @@ var steps = [
].filter(Boolean);
branches.forEach(function (branch) {
steps.push(_.partial(async.series, [
steps.push(_v4.partial(async.series, [
removePrevArchive(branch),
createArchive(branch),
generateStep(branch)

View File

@ -3,7 +3,7 @@ module.exports = function (branch, done) {
* Read the API actions form the rest-api-spec repo.
* @type {[type]}
*/
var _ = require('../../src/lib/utils');
// var _ = require('../../src/lib/utils');
var utils = require('../../grunt/utils');
var fs = require('fs');
var async = require('async');
@ -19,7 +19,7 @@ module.exports = function (branch, done) {
var docVars; // slightly modified clone of apiSpec for the docs
var branchSuffix = utils.branchSuffix(branch);
var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch));
var esDir = fromRoot('src/_elasticsearch_' + _v4.snakeCase(branch));
var version = Version.fromBranch(branch);
var overrides = version.mergeOpts(require('./overrides'), {
@ -71,27 +71,27 @@ module.exports = function (branch, done) {
});
// collect the namespaces from the action locations
var namespaces = _.filter(_.map(actions, function (action) {
var namespaces = _v4.filter(_v4.map(actions, function (action) {
if (~action.location.indexOf('.')) {
var path = action.location.split('.').slice(0, -1);
_.pull(path, 'prototype');
_v4.pull(path, 'prototype');
return path.join('.');
}
}));
// seperate the proxy actions
var groups = _.groupBy(actions, function (action) {
var groups = _v4.groupBy(actions, function (action) {
return action.proxy ? 'proxies' : 'normal';
});
apiSpec = {
actions: groups.normal || [],
proxies: groups.proxies || [],
namespaces: _.uniq(namespaces.sort(), true),
namespaces: _v4.uniq(namespaces.sort()),
clientActionModifier: overrides.clientActionModifier
};
var create = _.assign({}, _v4.find(apiSpec.actions, { name: 'index' }), {
var create = _v4.assign({}, _v4.find(apiSpec.actions, { name: 'index' }), {
name: 'create',
location: 'create',
proxy: 'index',
@ -119,7 +119,7 @@ module.exports = function (branch, done) {
}
function writeApiFile(done) {
var outputPath = fromRoot('src/lib/apis/' + _.snakeCase(branch) + '.js');
var outputPath = fromRoot('src/lib/apis/' + _v4.snakeCase(branch) + '.js');
fs.writeFileSync(outputPath, templates.apiFile(apiSpec));
console.log(chalk.white.bold('wrote'), apiSpec.actions.length, 'api actions to', outputPath);
done();
@ -145,8 +145,8 @@ module.exports = function (branch, done) {
// merge the actions and proxies to make
// itteration easir and keep them in order
docVars = _.omit(apiSpec, 'proxies');
docVars.actions = _.sortBy(
docVars = _v4.omit(apiSpec, 'proxies');
docVars.actions = _v4.sortBy(
[].concat(apiSpec.actions).concat(apiSpec.proxies),
'name'
);
@ -176,7 +176,7 @@ module.exports = function (branch, done) {
// itterate all of the specs within the file, should only be one
_v4.each(spec, function (def, name) {
// camelcase the name
name = _.map(name.split('.'), _.camelCase).join('.');
name = _v4.map(name.split('.'), _v4.camelCase).join('.');
if (name === 'cat.aliases') {
def.documentation = 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html';
@ -185,23 +185,23 @@ module.exports = function (branch, done) {
var steps = name.split('.');
function transformParamKeys(note, param, key) {
var cmlKey = _.camelCase(key);
var cmlKey = _v4.camelCase(key);
if (cmlKey !== key) {
param.name = key;
}
note[cmlKey] = param;
}
def.url.params = _.transform(def.url.params, transformParamKeys, {});
def.url.parts = _.transform(def.url.parts, transformParamKeys, {});
def.url.params = _v4.transform(def.url.params, transformParamKeys, {});
def.url.parts = _v4.transform(def.url.parts, transformParamKeys, {});
var allParams = _.extend({}, def.url.params, def.url.parts);
var allParams = _v4.extend({}, def.url.params, def.url.parts);
var spec = {
name: name,
methods: _.map(def.methods, function (m) { return m.toUpperCase(); }),
methods: _v4.map(def.methods, function (m) { return m.toUpperCase(); }),
params: def.url.params,
body: def.body || null,
path2lib: _.repeat('../', steps.length + 1) + 'lib/'
path2lib: _v4.repeat('../', steps.length + 1) + 'lib/'
};
if (def.body && def.body.required) {
@ -216,7 +216,7 @@ module.exports = function (branch, done) {
spec.requestTimeout = 3000;
}
var urls = _.difference(def.url.paths, overrides.aliases[name]);
var urls = _v4.difference(def.url.paths, overrides.aliases[name]);
var urlSignatures = [];
urls = _v4.map(urls, function (url) {
var optionalVars = {};
@ -231,47 +231,47 @@ module.exports = function (branch, done) {
}
while (match = urlParamRE.exec(url)) {
name = _.camelCase(match[1]);
name = _v4.camelCase(match[1]);
param = def.url.parts[name] || {};
target = (param.required || !param.default) ? requiredVars : optionalVars;
target[name] = _.omit(param, 'required', 'description', 'name');
target[name] = _v4.omit(param, 'required', 'description', 'name');
}
urlSignatures.push(_.union(_.keys(optionalVars), _.keys(requiredVars)).sort().join(':'));
urlSignatures.push(_v4.union(_v4.keys(optionalVars), _v4.keys(requiredVars)).sort().join(':'));
return _v4.omitBy({
fmt: url.replace(urlParamRE, function (full, match) {
return '<%=' + _.camelCase(match) + '%>';
return '<%=' + _v4.camelCase(match) + '%>';
}),
opt: _.size(optionalVars) ? optionalVars : null,
req: _.size(requiredVars) ? requiredVars : null,
sortOrder: _.size(requiredVars) * -1
opt: _v4.size(optionalVars) ? optionalVars : null,
req: _v4.size(requiredVars) ? requiredVars : null,
sortOrder: _v4.size(requiredVars) * -1
}, function (v) {
return !v;
});
});
if (urlSignatures.length !== _.uniq(urlSignatures).length) {
if (urlSignatures.length !== _v4.uniq(urlSignatures).length) {
throw new Error(
'Multiple URLS with the same signature detected for ' +
spec.name +
'\n' +
_.map(urls, 'fmt').join('\n') +
_v4.map(urls, 'fmt').join('\n') +
'\n'
);
}
if (urls.length > 1) {
spec.urls = _.map(_.sortBy(urls, 'sortOrder'), function (url) {
return _.omit(url, 'sortOrder');
spec.urls = _v4.map(_v4.sortBy(urls, 'sortOrder'), function (url) {
return _v4.omit(url, 'sortOrder');
});
} else {
spec.url = _.omit(urls[0], 'sortOrder');
spec.url = _v4.omit(urls[0], 'sortOrder');
}
spec.params = _.transform(spec.params, function (note, param, name) {
spec.params = _v4.transform(spec.params, function (note, param, name) {
// param.name = name;
note[name] = _.pick(param, [
note[name] = _v4.pick(param, [
'type', 'default', 'options', 'required', 'name'
]);
}, {});
@ -280,7 +280,7 @@ module.exports = function (branch, done) {
spec.paramAsBody = overrides.paramAsBody[name];
}
if (_.size(spec.params) === 0) {
if (_v4.size(spec.params) === 0) {
delete spec.params;
}
@ -290,7 +290,7 @@ module.exports = function (branch, done) {
var action = {
_methods: spec.methods,
spec: _.pick(spec, [
spec: _v4.pick(spec, [
'params',
'url',
'urls',

View File

@ -12,7 +12,7 @@ api._namespaces = <%= stringify(namespaces) %>;<%
_v4.each(actions, function (action) {
var namespace = action.location.split('.').shift();
if (_.includes(namespaces, namespace)) {
_.pull(namespaces, namespace);
_v4.pull(namespaces, namespace);
%>
api.<%= namespace %> = namespace();<%

View File

@ -2,7 +2,7 @@ module.exports = {
<%
branches.forEach(function (branch, i, list) {
var req = "require('./" + _.snakeCase(branch) + "')";
var req = "require('./" + _v4.snakeCase(branch) + "')";
if (branch === utils.branches._default) {
print(" '_default': " + req + ',\n');
}

View File

@ -7,7 +7,7 @@ NOTE: This is currently the default API, but in upcoming versions that will chan
NOTE: At this time, you must opt into the <%= branch %> API by setting the `apiVersion` config parameter.
<% }
actions = _.sortBy(actions, 'namespace');
actions = _v4.sortBy(actions, 'namespace');
_v4.each(actions, function (action) {
action.index = 'api-' + action.name.toLowerCase().replace(/[^\w]+/g, '-') + branchSuffix;
@ -27,7 +27,7 @@ The default method is `<%= action.spec.method || 'GET' %>` and the usual <<api-c
<%= action.examples %>
<% if (_.size(action.allParams)) { %>
<% if (_v4.size(action.allParams)) { %>
*Params*
[horizontal]<%

View File

@ -1,5 +1,5 @@
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var utils = require('../../../grunt/utils');
var fs = require('fs');
var path = require('path');
@ -41,11 +41,10 @@ var templateGlobals = {
stringify: stringify,
_: _,
_v4: _v4,
indent: function (block, spaces) {
var indent = _.repeat(' ', spaces);
var indent = _v4.repeat(' ', spaces);
return block.split('\n').map(function (line) {
return indent + line;
}).join('\n');
@ -78,7 +77,7 @@ var templateGlobals = {
case 'list':
return 'String, String[], Boolean';
default:
return _.ucfirst(type);
return _v4.ucfirst(type);
}
},
@ -98,7 +97,7 @@ var templateGlobals = {
fs.readdirSync(path.resolve(__dirname)).forEach(function (filename) {
var name = filename.replace(/\..+$/, '');
if (name !== 'index') {
templates[name] = _.template(
templates[name] = _v4.template(
fs.readFileSync(path.resolve(__dirname, filename), 'utf8'),
{
imports: templateGlobals

View File

@ -8,10 +8,10 @@ module.exports = function (branch, done) {
var chalk = require('chalk');
var path = require('path');
var fromRoot = path.join.bind(path, require('find-root')(__dirname));
var _ = require(fromRoot('src/lib/utils'));
// var _ = require(fromRoot('src/lib/utils'));
var tests = {}; // populated in readYamlTests
var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch));
var esDir = fromRoot('src/_elasticsearch_' + _v4.snakeCase(branch));
// generate the yaml tests
async.series([
@ -43,15 +43,15 @@ module.exports = function (branch, done) {
}
function writeYamlTests(done) {
var testFile = fromRoot('test/integration/yaml_suite/yaml_tests_' + _.snakeCase(branch) + '.json');
var testFile = fromRoot('test/integration/yaml_suite/yaml_tests_' + _v4.snakeCase(branch) + '.json');
fs.writeFileSync(testFile, JSON.stringify(tests, null, ' '), 'utf8');
console.log(chalk.white.bold('wrote') + ' YAML tests as JSON to', testFile);
done();
}
function writeTestIndex(done) {
var file = fromRoot('test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js');
fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');', 'utf8');
var file = fromRoot('test/integration/yaml_suite/index_' + _v4.snakeCase(branch) + '.js');
fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');\n', 'utf8');
console.log(chalk.white.bold('wrote') + ' YAML index to', file);
done();
}

View File

@ -1,7 +1,7 @@
var fs = require('fs');
var spawn = require('../_spawn');
var async = require('async');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var root = require('path').join(__dirname, '../..');
var bowerDir = root + '/src/bower_es_js';
@ -21,7 +21,7 @@ fs.writeFileSync(bowerDir + '/bower.json', JSON.stringify(bowerJson, null, ' ')
fs.writeFileSync(bowerDir + '/package.json', JSON.stringify(bowerPackageJson, null, ' '));
function make(cmd, args) {
return _.bind(spawn, null, cmd, args, {
return _v4.bind(spawn, null, cmd, args, {
verbose: true,
cwd: bowerDir
});
@ -36,7 +36,7 @@ async.series([
make('npm', ['publish'])
], function (err) {
if (err) {
if (_.isNumber(err)) {
if (_v4.isNumber(err)) {
console.log('Non-zero exit code: %d', err);
} else {
console.log('Error: ', err.message ? err.message : err);

View File

@ -28,7 +28,7 @@ module.exports = Client;
var Transport = require('./transport');
var clientAction = require('./client_action');
var _ = require('./utils');
// var _ = require('./utils');
function Client(config) {
config = config || {};
@ -56,7 +56,7 @@ function Client(config) {
this.transport = new Transport(config);
_v4.each(EsApiClient.prototype, _.bind(function (Fn, prop) {
_v4.each(EsApiClient.prototype, _v4.bind(function (Fn, prop) {
if (Fn.prototype instanceof clientAction.ApiNamespace) {
this[prop] = new Fn(this.transport);
}
@ -66,7 +66,7 @@ function Client(config) {
}
EsApiClient.prototype = _.funcEnum(config, 'apiVersion', Client.apis, '_default');
EsApiClient.prototype = _v4.funcEnum(config, 'apiVersion', Client.apis, '_default');
if (!config.sniffEndpoint && EsApiClient.prototype === Client.apis['0.90']) {
config.sniffEndpoint = '/_cluster/nodes';
}

View File

@ -1,5 +1,5 @@
var _ = require('./utils');
// var _ = require('./utils');
/**
* Constructs a client action factory that uses specific defaults
@ -34,12 +34,12 @@ exports.namespaceFactory = function () {
};
function makeFactoryWithModifier(modifier) {
modifier = modifier || _.identity;
modifier = modifier || _v4.identity;
var factory = function (spec) {
spec = modifier(spec);
if (!_.isPlainObject(spec.params)) {
if (!_v4.isPlainObject(spec.params)) {
spec.params = {};
}
@ -60,7 +60,7 @@ function makeFactoryWithModifier(modifier) {
return exec(this.transport, spec, _v4.clone(params), cb);
} catch (e) {
if (typeof cb === 'function') {
_.nextTick(cb, e);
_v4.nextTick(cb, e);
} else {
var def = this.transport.defer();
def.reject(e);
@ -97,11 +97,11 @@ function makeFactoryWithModifier(modifier) {
var castType = {
'enum': function validSelection(param, val, name) {
if (_.isString(val) && val.indexOf(',') > -1) {
if (_v4.isString(val) && val.indexOf(',') > -1) {
val = commaSepList(val);
}
if (_.isArray(val)) {
if (_v4.isArray(val)) {
return val.map(function (v) {
return validSelection(param, v, name);
}).join(',');
@ -119,7 +119,7 @@ var castType = {
));
},
duration: function (param, val, name) {
if (_.isNumeric(val) || _.isInterval(val)) {
if (_v4.isNumeric(val) || _v4.isInterval(val)) {
return val;
} else {
throw new TypeError(
@ -137,7 +137,7 @@ var castType = {
val = commaSepList(val);
/* falls through */
case 'object':
if (_.isArray(val)) {
if (_v4.isArray(val)) {
return val.join(',');
}
/* falls through */
@ -146,11 +146,11 @@ var castType = {
}
},
'boolean': function (param, val) {
val = _.isString(val) ? val.toLowerCase() : val;
val = _v4.isString(val) ? val.toLowerCase() : val;
return (val === 'no' || val === 'off') ? false : !!val;
},
number: function (param, val, name) {
if (_.isNumeric(val)) {
if (_v4.isNumeric(val)) {
return val * 1;
} else {
throw new TypeError('Invalid ' + name + ': expected a number.');
@ -169,7 +169,7 @@ var castType = {
if (typeof val === 'string') {
return val;
}
else if (_.isNumeric(val)) {
else if (_v4.isNumeric(val)) {
return '' + val;
}
else if (val instanceof Date) {
@ -188,7 +188,7 @@ function resolveUrl(url, params) {
// url has required params
if (!url.reqParamKeys) {
// create cached key list on demand
url.reqParamKeys = _.keys(url.req);
url.reqParamKeys = _v4.keys(url.req);
}
for (i = 0; i < url.reqParamKeys.length; i ++) {
@ -210,7 +210,7 @@ function resolveUrl(url, params) {
if (url.opt) {
// url has optional params
if (!url.optParamKeys) {
url.optParamKeys = _.keys(url.opt);
url.optParamKeys = _v4.keys(url.opt);
}
for (i = 0; i < url.optParamKeys.length; i ++) {
@ -229,10 +229,10 @@ function resolveUrl(url, params) {
if (!url.template) {
// compile the template on demand
url.template = _.template(url.fmt);
url.template = _v4.template(url.fmt);
}
return url.template(_.transform(vars, function (note, val, name) {
return url.template(_v4.transform(vars, function (note, val, name) {
// encode each value
note[name] = encodeURIComponent(val);
// remove it from the params so that it isn't sent to the final request
@ -287,14 +287,14 @@ function exec(transport, spec, params, cb) {
if (!request.path) {
// there must have been some mimimun requirements that were not met
var minUrl = spec.url || spec.urls[spec.urls.length - 1];
throw new TypeError('Unable to build a path with those params. Supply at least ' + _.keys(minUrl.req).join(', '));
throw new TypeError('Unable to build a path with those params. Supply at least ' + _v4.keys(minUrl.req).join(', '));
}
// build the query string
if (!spec.paramKeys) {
// build a key list on demand
spec.paramKeys = _.keys(spec.params);
spec.requireParamKeys = _.transform(spec.params, function (req, param, key) {
spec.paramKeys = _v4.keys(spec.params);
spec.requireParamKeys = _v4.transform(spec.params, function (req, param, key) {
if (param.required) {
req.push(key);
}
@ -311,10 +311,10 @@ function exec(transport, spec, params, cb) {
request[key] = params[key];
break;
case 'ignore':
request.ignore = _.isArray(params[key]) ? params[key] : [params[key]];
request.ignore = _v4.isArray(params[key]) ? params[key] : [params[key]];
break;
case 'method':
request.method = _.toUpperString(params[key]);
request.method = _v4.toUpperString(params[key]);
break;
default:
var paramSpec = spec.params[key];

View File

@ -1,6 +1,6 @@
module.exports = ConnectionAbstract;
var _ = require('./utils');
// var _ = require('./utils');
var EventEmitter = require('events').EventEmitter;
var Log = require('./log');
var Host = require('./host');
@ -26,9 +26,9 @@ function ConnectionAbstract(host, config) {
throw new TypeError('Invalid host');
}
_.makeBoundMethods(this);
_v4.makeBoundMethods(this);
}
_.inherits(ConnectionAbstract, EventEmitter);
_v4.inherits(ConnectionAbstract, EventEmitter);
/**
* Make a request using this connection. Must be overridden by Connection classes, which can add whatever keys to
@ -61,7 +61,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) {
requestTimeout = params.requestTimeout;
}
abort = this.request(_.defaults(params || {}, {
abort = this.request(_v4.defaults(params || {}, {
path: '/',
method: 'HEAD'
}), function (err) {

View File

@ -9,12 +9,12 @@
module.exports = ConnectionPool;
var _ = require('./utils');
// var _ = require('./utils');
var Log = require('./log');
function ConnectionPool(config) {
config = config || {};
_.makeBoundMethods(this);
_v4.makeBoundMethods(this);
if (!config.log) {
this.log = new Log();
@ -27,16 +27,16 @@ function ConnectionPool(config) {
this._config = config;
// get the selector config var
this.selector = _.funcEnum(config, 'selector', ConnectionPool.selectors, ConnectionPool.defaultSelector);
this.selector = _v4.funcEnum(config, 'selector', ConnectionPool.selectors, ConnectionPool.defaultSelector);
// get the connection class
this.Connection = _.funcEnum(config, 'connectionClass', ConnectionPool.connectionClasses,
this.Connection = _v4.funcEnum(config, 'connectionClass', ConnectionPool.connectionClasses,
ConnectionPool.defaultConnectionClass);
// time that connections will wait before being revived
this.deadTimeout = config.hasOwnProperty('deadTimeout') ? config.deadTimeout : 60000;
this.maxDeadTimeout = config.hasOwnProperty('maxDeadTimeout') ? config.maxDeadTimeout : 18e5;
this.calcDeadTimeout = _.funcEnum(config, 'calcDeadTimeout', ConnectionPool.calcDeadTimeoutOptions, 'exponential');
this.calcDeadTimeout = _v4.funcEnum(config, 'calcDeadTimeout', ConnectionPool.calcDeadTimeoutOptions, 'exponential');
// a map of connections to their "id" property, used when sniffing
this.index = {};
@ -86,7 +86,7 @@ ConnectionPool.prototype.select = function (cb) {
this.selector(this._conns.alive, cb);
} else {
try {
_.nextTick(cb, void 0, this.selector(this._conns.alive));
_v4.nextTick(cb, void 0, this.selector(this._conns.alive));
} catch (e) {
cb(e);
}
@ -94,7 +94,7 @@ ConnectionPool.prototype.select = function (cb) {
} else if (this._timeouts.length) {
this._selectDeadConnection(cb);
} else {
_.nextTick(cb, void 0);
_v4.nextTick(cb, void 0);
}
};
@ -106,7 +106,7 @@ ConnectionPool.prototype.select = function (cb) {
* @param {String} oldStatus - the connection's old status
* @param {ConnectionAbstract} connection - the connection object itself
*/
ConnectionPool.prototype.onStatusSet = _.handler(function (status, oldStatus, connection) {
ConnectionPool.prototype.onStatusSet = _v4.handler(function (status, oldStatus, connection) {
var index;
var died = (status === 'dead');
@ -121,14 +121,14 @@ ConnectionPool.prototype.onStatusSet = _.handler(function (status, oldStatus, co
}
if (from !== to) {
if (_.isArray(from)) {
if (_v4.isArray(from)) {
index = from.indexOf(connection);
if (index !== -1) {
from.splice(index, 1);
}
}
if (_.isArray(to)) {
if (_v4.isArray(to)) {
index = to.indexOf(connection);
if (index === -1) {
to.push(connection);
@ -200,11 +200,11 @@ ConnectionPool.prototype._onConnectionDied = function (connection, alreadyWasDea
var ms = this.calcDeadTimeout(timeout.attempt, this.deadTimeout);
timeout.id = setTimeout(timeout.revive, ms);
timeout.runAt = _.now() + ms;
timeout.runAt = _v4.now() + ms;
};
ConnectionPool.prototype._selectDeadConnection = function (cb) {
var orderedTimeouts = _.sortBy(this._timeouts, 'runAt');
var orderedTimeouts = _v4.sortBy(this._timeouts, 'runAt');
var log = this.log;
process.nextTick(function next() {
@ -322,14 +322,14 @@ ConnectionPool.prototype.setHosts = function (hosts) {
}
}
var removeIds = _.keys(toRemove);
var removeIds = _v4.keys(toRemove);
for (i = 0; i < removeIds.length; i++) {
this.removeConnection(this.index[removeIds[i]]);
}
};
ConnectionPool.prototype.getAllHosts = function () {
return _.values(this.index).map(function (connection) {
return _v4.values(this.index).map(function (connection) {
return connection.host;
});
};

View File

@ -6,7 +6,7 @@
*/
module.exports = AngularConnector;
var _ = require('../utils');
// var _ = require('../utils');
var ConnectionAbstract = require('../connection');
var ConnectionFault = require('../errors').ConnectionFault;
@ -20,7 +20,7 @@ function AngularConnector(host, config) {
}]);
}
_.inherits(AngularConnector, ConnectionAbstract);
_v4.inherits(AngularConnector, ConnectionAbstract);
AngularConnector.prototype.request = function (params, cb) {
var abort = this.$q.defer();

View File

@ -3,7 +3,7 @@ var opts = {
jquery: require('./jquery'),
angular: require('./angular')
};
var _ = require('../utils');
// var _ = require('../utils');
// remove modules that have been ignored by browserify
_v4.each(opts, function (conn, name) {

View File

@ -12,7 +12,7 @@ var handles = {
http: require('http'),
https: require('https')
};
var _ = require('../utils');
// var _ = require('../utils');
var qs = require('querystring');
var KeepAliveAgent = require('./_keep_alive_agent');
var ConnectionAbstract = require('../connection');
@ -31,12 +31,12 @@ function HttpConnector(host, config) {
this.hand = handles[this.host.protocol];
if (!this.hand) {
throw new TypeError('Invalid protocol "' + this.host.protocol +
'", expected one of ' + _.keys(handles).join(', '));
'", expected one of ' + _v4.keys(handles).join(', '));
}
this.useSsl = this.host.protocol === 'https';
config = _.defaults(config || {}, {
config = _v4.defaults(config || {}, {
keepAlive: true,
minSockets: 10,
// 10 makes sense but 11 actually keeps 10 sockets around
@ -46,9 +46,9 @@ function HttpConnector(host, config) {
this.agent = config.createNodeAgent ? config.createNodeAgent(this, config) : this.createAgent(config);
}
_.inherits(HttpConnector, ConnectionAbstract);
_v4.inherits(HttpConnector, ConnectionAbstract);
HttpConnector.prototype.onStatusSet = _.handler(function (status) {
HttpConnector.prototype.onStatusSet = _v4.handler(function (status) {
if (status === 'closed') {
var agent = this.agent;
var toRemove = [];
@ -102,7 +102,7 @@ HttpConnector.prototype.makeAgentConfig = function (config) {
};
if (this.useSsl) {
_.merge(agentConfig, this.host.ssl);
_v4.merge(agentConfig, this.host.ssl);
}
return agentConfig;
@ -147,7 +147,7 @@ HttpConnector.prototype.request = function (params, cb) {
// general clean-up procedure to run after the request
// completes, has an error, or is aborted.
var cleanUp = _.bind(function (err) {
var cleanUp = _v4.bind(function (err) {
clearTimeout(timeoutId);
request && request.removeAllListeners();

View File

@ -7,14 +7,14 @@
*/
module.exports = JqueryConnector;
var _ = require('../utils');
// var _ = require('../utils');
var ConnectionAbstract = require('../connection');
var ConnectionFault = require('../errors').ConnectionFault;
function JqueryConnector(host, config) {
ConnectionAbstract.call(this, host, config);
}
_.inherits(JqueryConnector, ConnectionAbstract);
_v4.inherits(JqueryConnector, ConnectionAbstract);
JqueryConnector.prototype.request = function (params, cb) {
var ajax = {

View File

@ -7,7 +7,7 @@ module.exports = XhrConnector;
/* jshint browser:true */
var _ = require('../utils');
// var _ = require('../utils');
var ConnectionAbstract = require('../connection');
var ConnectionFault = require('../errors').ConnectionFault;
var asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent));
@ -15,13 +15,13 @@ var asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent));
function XhrConnector(host, config) {
ConnectionAbstract.call(this, host, config);
}
_.inherits(XhrConnector, ConnectionAbstract);
_v4.inherits(XhrConnector, ConnectionAbstract);
/**
* Simply returns an XHR object cross browser
* @type {Function}
*/
var getXhr = _.noop;
var getXhr = _v4.noop;
if (typeof XMLHttpRequest !== 'undefined') {
// rewrite the getXhr method to always return the native implementation
@ -30,7 +30,7 @@ if (typeof XMLHttpRequest !== 'undefined') {
};
} else {
// find the first MS implementation available
getXhr = _(['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'])
getXhr = _v4(['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'])
.map(function (appName) {
/* jshint unused: false */
try {

View File

@ -1,4 +1,4 @@
var _ = require('./utils');
// var _ = require('./utils');
var qs = require('querystring');
var errors = module.exports;
@ -21,21 +21,21 @@ function ErrorAbstract(msg, constructor, metadata) {
}
if (metadata) {
_.assign(this, metadata);
_v4.assign(this, metadata);
this.toString = function () {
return msg + ' :: ' + JSON.stringify(metadata);
};
this.toJSON = function () {
return _.assign({
return _v4.assign({
msg: msg
}, metadata);
};
}
}
errors._Abstract = ErrorAbstract;
_.inherits(ErrorAbstract, Error);
_v4.inherits(ErrorAbstract, Error);
/**
* Connection Error
@ -44,7 +44,7 @@ _.inherits(ErrorAbstract, Error);
errors.ConnectionFault = function ConnectionFault(msg) {
ErrorAbstract.call(this, msg || 'Connection Failure', errors.ConnectionFault);
};
_.inherits(errors.ConnectionFault, ErrorAbstract);
_v4.inherits(errors.ConnectionFault, ErrorAbstract);
/**
* No Living Connections
@ -53,7 +53,7 @@ _.inherits(errors.ConnectionFault, ErrorAbstract);
errors.NoConnections = function NoConnections(msg) {
ErrorAbstract.call(this, msg || 'No Living connections', errors.NoConnections);
};
_.inherits(errors.NoConnections, ErrorAbstract);
_v4.inherits(errors.NoConnections, ErrorAbstract);
/**
* Generic Error
@ -62,7 +62,7 @@ _.inherits(errors.NoConnections, ErrorAbstract);
errors.Generic = function Generic(msg, metadata) {
ErrorAbstract.call(this, msg || 'Generic Error', errors.Generic, metadata);
};
_.inherits(errors.Generic, ErrorAbstract);
_v4.inherits(errors.Generic, ErrorAbstract);
/**
* Request Timeout Error
@ -71,7 +71,7 @@ _.inherits(errors.Generic, ErrorAbstract);
errors.RequestTimeout = function RequestTimeout(msg) {
ErrorAbstract.call(this, msg || 'Request Timeout', errors.RequestTimeout);
};
_.inherits(errors.RequestTimeout, ErrorAbstract);
_v4.inherits(errors.RequestTimeout, ErrorAbstract);
/**
@ -81,7 +81,7 @@ _.inherits(errors.RequestTimeout, ErrorAbstract);
errors.Serialization = function Serialization(msg) {
ErrorAbstract.call(this, msg || 'Unable to parse/serialize body', errors.Serialization);
};
_.inherits(errors.Serialization, ErrorAbstract);
_v4.inherits(errors.Serialization, ErrorAbstract);
/**
@ -90,7 +90,7 @@ _.inherits(errors.Serialization, ErrorAbstract);
errors.RequestTypeError = function RequestTypeError(feature) {
ErrorAbstract.call(this, 'Cross-domain AJAX requests ' + feature + ' are not supported', errors.RequestTypeError);
};
_.inherits(errors.RequestTypeError, ErrorAbstract);
_v4.inherits(errors.RequestTypeError, ErrorAbstract);
var statusCodes = [
[300, 'Multiple Choices'],
@ -142,15 +142,15 @@ _v4.each(statusCodes, function createStatusCodeError(tuple) {
var names = tuple[1];
var allNames = [].concat(names, status);
var primaryName = allNames[0];
var className = _.studlyCase(primaryName);
allNames = _.uniq(allNames.concat(className));
var className = _v4.studlyCase(primaryName);
allNames = _v4.uniq(allNames.concat(className));
function StatusCodeError(msg, metadata) {
this.status = status;
this.displayName = className;
var esErrObject = null;
if (_.isPlainObject(msg)) {
if (_v4.isPlainObject(msg)) {
esErrObject = msg;
msg = null;
}
@ -168,8 +168,8 @@ _v4.each(statusCodes, function createStatusCodeError(tuple) {
memo += '[' + cause.type + '] ' + cause.reason;
var extraData = _.omit(cause, ['type', 'reason']);
if (_.size(extraData)) {
var extraData = _v4.omit(cause, ['type', 'reason']);
if (_v4.size(extraData)) {
memo += ', with { ' + qs.stringify(extraData, ' ', '=', {
encodeURIComponent: function (v) {
return String(v).split('\n').join('\\n');
@ -188,7 +188,7 @@ _v4.each(statusCodes, function createStatusCodeError(tuple) {
ErrorAbstract.call(this, msg || primaryName, StatusCodeError, metadata);
return this;
}
_.inherits(StatusCodeError, ErrorAbstract);
_v4.inherits(StatusCodeError, ErrorAbstract);
allNames.forEach(function (name) {
errors[name] = StatusCodeError;

View File

@ -6,7 +6,7 @@ module.exports = Host;
var url = require('url');
var qs = require('querystring');
var _ = require('./utils');
// var _ = require('./utils');
var startsWithProtocolRE = /^([a-z]+:)?\/\//;
var defaultProto = 'http:';
@ -58,7 +58,7 @@ function Host(config, globalConfig) {
this.headers = null;
this.suggestCompression = !!globalConfig.suggestCompression;
this.ssl = _.defaults({}, config.ssl || {}, globalConfig.ssl || {}, sslDefaults);
this.ssl = _v4.defaults({}, config.ssl || {}, globalConfig.ssl || {}, sslDefaults);
if (typeof config === 'string') {
var firstColon = config.indexOf(':');
@ -69,7 +69,7 @@ function Host(config, globalConfig) {
if ((noSlash || portNoPath || portWithPath) && !startsWithProtocolRE.test(config)) {
config = defaultProto + '//' + config;
}
config = _.pick(url.parse(config, false, true), urlParseFields);
config = _v4.pick(url.parse(config, false, true), urlParseFields);
// default logic for the port is to use 9200 for the default. When a string is specified though,
// we will use the default from the protocol of the string.
if (!config.port) {
@ -83,7 +83,7 @@ function Host(config, globalConfig) {
}
}
if (_.isObject(config)) {
if (_v4.isObject(config)) {
// move hostname/portname to host/port semi-intelligently.
_v4.each(simplify, function (to) {
var from = to + 'name';
@ -106,20 +106,20 @@ function Host(config, globalConfig) {
delete config.auth;
}
_.forOwn(config, function (val, prop) {
_v4.forOwn(config, _v4.bind(function (val, prop) {
if (val != null) this[prop] = _v4.clone(val);
}, this);
}, this));
// make sure the query string is parsed
if (this.query === null) {
// majority case
this.query = {};
} else if (!_.isPlainObject(this.query)) {
} else if (!_v4.isPlainObject(this.query)) {
this.query = qs.parse(this.query);
}
// make sure that the port is a number
if (_.isNumeric(this.port)) {
if (_v4.isNumeric(this.port)) {
this.port = parseInt(this.port, 10);
} else {
this.port = 9200;
@ -177,10 +177,10 @@ function objectPropertyGetter(prop, preOverride) {
}
if (overrides) {
obj = _.assign({}, obj, overrides);
obj = _v4.assign({}, obj, overrides);
}
return _.size(obj) ? obj : null;
return _v4.size(obj) ? obj : null;
};
}
@ -189,7 +189,7 @@ Host.prototype.getHeaders = objectPropertyGetter('headers', function (overrides)
return overrides;
}
return _.defaults(overrides || {}, {
return _v4.defaults(overrides || {}, {
'Accept-Encoding': 'gzip,deflate'
});
});

View File

@ -1,4 +1,4 @@
var _ = require('./utils');
// var _ = require('./utils');
var url = require('url');
var EventEmitter = require('events').EventEmitter;
@ -24,13 +24,13 @@ function Log(config) {
var i;
var outputs;
if (_.isArrayOfStrings(config.log)) {
if (_v4.isArrayOfStrings(config.log)) {
outputs = [{
levels: config.log
}];
} else {
outputs = _.createArray(config.log, function (val) {
if (_.isPlainObject(val)) {
outputs = _v4.createArray(config.log, function (val) {
if (_v4.isPlainObject(val)) {
return val;
}
if (typeof val === 'string') {
@ -50,7 +50,7 @@ function Log(config) {
this.addOutput(outputs[i]);
}
}
_.inherits(Log, EventEmitter);
_v4.inherits(Log, EventEmitter);
Log.loggers = require('./loggers');
@ -151,14 +151,14 @@ Log.levels = [
Log.parseLevels = function (input) {
switch (typeof input) {
case 'string':
var i = _.indexOf(Log.levels, input);
var i = _v4.indexOf(Log.levels, input);
if (i >= 0) {
return Log.levels.slice(0, i + 1);
}
/* fall through */
case 'object':
if (_.isArray(input)) {
var valid = _.intersection(input, Log.levels);
if (_v4.isArray(input)) {
var valid = _v4.intersection(input, Log.levels);
if (valid.length === input.length) {
return valid;
}
@ -180,9 +180,9 @@ Log.parseLevels = function (input) {
* @return {String} - The final string.
*/
Log.join = function (arrayish) {
return _.map(arrayish, function (item) {
if (_.isPlainObject(item)) {
return _.inspect(item) + '\n';
return _v4.map(arrayish, function (item) {
if (_v4.isPlainObject(item)) {
return _v4.inspect(item) + '\n';
} else {
return item.toString();
}
@ -209,7 +209,7 @@ Log.prototype.addOutput = function (config) {
config.levels = Log.parseLevels(config.levels || config.level || 'warning');
delete config.level;
var Logger = _.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio');
var Logger = _v4.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio');
return new Logger(this, config);
};

View File

@ -1,4 +1,4 @@
var _ = require('./utils');
// var _ = require('./utils');
/**
* Abstract class providing common functionality to loggers
@ -9,7 +9,7 @@ function LoggerAbstract(log, config) {
this.log = log;
this.listeningLevels = [];
_.makeBoundMethods(this);
_v4.makeBoundMethods(this);
// when the log closes, remove our event listeners
this.log.once('closing', this.bound.cleanUpListeners);
@ -37,7 +37,7 @@ LoggerAbstract.prototype.timestamp = function () {
};
function indent(text, spaces) {
var space = _.repeat(' ', spaces || 2);
var space = _v4.repeat(' ', spaces || 2);
return (text || '').split(/\r?\n/).map(function (line) {
return space + line;
}).join('\n');
@ -64,8 +64,8 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
this.listeningLevels = [];
_v4.each(levels, _.bind(function (level) {
var fnName = 'on' + _.ucfirst(level);
_v4.each(levels, _v4.bind(function (level) {
var fnName = 'on' + _v4.ucfirst(level);
if (this.bound[fnName]) {
this.listeningLevels.push(level);
this.log.on(level, this.bound[fnName]);
@ -82,9 +82,9 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
* @private
* @return {undefined}
*/
LoggerAbstract.prototype.cleanUpListeners = _.handler(function () {
_v4.each(this.listeningLevels, _.bind(function (level) {
this.log.removeListener(level, this.bound['on' + _.ucfirst(level)]);
LoggerAbstract.prototype.cleanUpListeners = _v4.handler(function () {
_v4.each(this.listeningLevels, _v4.bind(function (level) {
this.log.removeListener(level, this.bound['on' + _v4.ucfirst(level)]);
}, this));
});
@ -96,7 +96,7 @@ LoggerAbstract.prototype.cleanUpListeners = _.handler(function () {
* @param {Error} e - The Error object to log
* @return {undefined}
*/
LoggerAbstract.prototype.onError = _.handler(function (e) {
LoggerAbstract.prototype.onError = _v4.handler(function (e) {
this.write((e.name === 'Error' ? 'ERROR' : e.name), e.stack);
});
@ -108,7 +108,7 @@ LoggerAbstract.prototype.onError = _.handler(function (e) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
LoggerAbstract.prototype.onWarning = _.handler(function (msg) {
LoggerAbstract.prototype.onWarning = _v4.handler(function (msg) {
this.write('WARNING', msg);
});
@ -120,7 +120,7 @@ LoggerAbstract.prototype.onWarning = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
LoggerAbstract.prototype.onInfo = _.handler(function (msg) {
LoggerAbstract.prototype.onInfo = _v4.handler(function (msg) {
this.write('INFO', msg);
});
@ -132,7 +132,7 @@ LoggerAbstract.prototype.onInfo = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
LoggerAbstract.prototype.onDebug = _.handler(function (msg) {
LoggerAbstract.prototype.onDebug = _v4.handler(function (msg) {
this.write('DEBUG', msg);
});
@ -144,7 +144,7 @@ LoggerAbstract.prototype.onDebug = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
LoggerAbstract.prototype.onTrace = _.handler(function (requestDetails) {
LoggerAbstract.prototype.onTrace = _v4.handler(function (requestDetails) {
this.write('TRACE', this._formatTraceMessage(requestDetails));
});

View File

@ -13,15 +13,15 @@
module.exports = Console;
var LoggerAbstract = require('../logger');
var _ = require('../utils');
// var _ = require('../utils');
function Console(log, config) {
LoggerAbstract.call(this, log, config);
// config/state
this.color = _.has(config, 'color') ? !!config.color : true;
this.color = _v4.has(config, 'color') ? !!config.color : true;
}
_.inherits(Console, LoggerAbstract);
_v4.inherits(Console, LoggerAbstract);
/**
* Override the LoggerAbstract's setup listeners to do a little extra setup
@ -47,7 +47,7 @@ Console.prototype.write = function (label, message, to) {
* @param {Error} e - The Error object to log
* @return {undefined}
*/
Console.prototype.onError = _.handler(function (e) {
Console.prototype.onError = _v4.handler(function (e) {
var to = console.error ? 'error' : 'log';
this.write(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message, to);
});
@ -60,7 +60,7 @@ Console.prototype.onError = _.handler(function (e) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Console.prototype.onWarning = _.handler(function (msg) {
Console.prototype.onWarning = _v4.handler(function (msg) {
this.write('WARNING', msg, console.warn ? 'warn' : 'log');
});
@ -72,7 +72,7 @@ Console.prototype.onWarning = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Console.prototype.onInfo = _.handler(function (msg) {
Console.prototype.onInfo = _v4.handler(function (msg) {
this.write('INFO', msg, console.info ? 'info' : 'log');
});
@ -84,7 +84,7 @@ Console.prototype.onInfo = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Console.prototype.onDebug = _.handler(function (msg) {
Console.prototype.onDebug = _v4.handler(function (msg) {
this.write('DEBUG', msg, console.debug ? 'debug' : 'log');
});
/**
@ -94,6 +94,6 @@ Console.prototype.onDebug = _.handler(function (msg) {
* @private
* @return {undefined}
*/
Console.prototype.onTrace = _.handler(function (msg) {
Console.prototype.onTrace = _v4.handler(function (msg) {
this.write('TRACE', this._formatTraceMessage(msg), 'log');
});

View File

@ -12,7 +12,7 @@
module.exports = File;
var StreamLogger = require('./stream');
var _ = require('../utils');
// var _ = require('../utils');
var fs = require('fs');
function File(log, config) {
@ -29,10 +29,10 @@ function File(log, config) {
StreamLogger.call(this, log, config);
}
_.inherits(File, StreamLogger);
_v4.inherits(File, StreamLogger);
File.prototype.onProcessExit = _.handler(function () {
var toWrite = _.getUnwrittenFromStream(this.stream);
File.prototype.onProcessExit = _v4.handler(function () {
var toWrite = _v4.getUnwrittenFromStream(this.stream);
if (toWrite) {
fs.appendFileSync(this.path, toWrite);
}

View File

@ -17,7 +17,7 @@ var chalk = require('chalk');
chalk.enabled = true;
var LoggerAbstract = require('../logger');
var _ = require('../utils');
// var _ = require('../utils');
var defaultColors = {
error: chalk.red.bold,
@ -31,12 +31,12 @@ function Stdio(log, config) {
LoggerAbstract.call(this, log, config);
// config/state
this.color = !!(_.has(config, 'color') ? config.color : chalk.supportsColor);
this.color = !!(_v4.has(config, 'color') ? config.color : chalk.supportsColor);
this.colors = _.defaults(config.colors || {}, defaultColors);
this.colors = _v4.defaults(config.colors || {}, defaultColors);
}
_.inherits(Stdio, LoggerAbstract);
_v4.inherits(Stdio, LoggerAbstract);
/**
* Sends output to a stream, does some formatting first
@ -65,7 +65,7 @@ Stdio.prototype.write = function (label, message, to, colorize) {
* @param {Error} e - The Error object to log
* @return {undefined}
*/
Stdio.prototype.onError = _.handler(function (e) {
Stdio.prototype.onError = _v4.handler(function (e) {
this.write(e.name === 'Error' ? 'ERROR' : e.name, e.stack, process.stderr, this.colors.error);
});
@ -77,7 +77,7 @@ Stdio.prototype.onError = _.handler(function (e) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Stdio.prototype.onWarning = _.handler(function (msg) {
Stdio.prototype.onWarning = _v4.handler(function (msg) {
this.write('WARNING', msg, process.stderr, this.colors.warning);
});
@ -89,7 +89,7 @@ Stdio.prototype.onWarning = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Stdio.prototype.onInfo = _.handler(function (msg) {
Stdio.prototype.onInfo = _v4.handler(function (msg) {
this.write('INFO', msg, process.stdout, this.colors.info);
});
@ -101,7 +101,7 @@ Stdio.prototype.onInfo = _.handler(function (msg) {
* @param {String} msg - The message to be logged
* @return {undefined}
*/
Stdio.prototype.onDebug = _.handler(function (msg) {
Stdio.prototype.onDebug = _v4.handler(function (msg) {
this.write('DEBUG', msg, process.stdout, this.colors.debug);
});
@ -112,6 +112,6 @@ Stdio.prototype.onDebug = _.handler(function (msg) {
* @private
* @return {undefined}
*/
Stdio.prototype.onTrace = _.handler(function (message) {
Stdio.prototype.onTrace = _v4.handler(function (message) {
this.write('TRACE', this._formatTraceMessage(message), process.stdout, this.colors.trace);
});

View File

@ -13,7 +13,7 @@
module.exports = Stream;
var LoggerAbstract = require('../logger');
var _ = require('../utils');
// var _ = require('../utils');
function Stream(log, config) {
LoggerAbstract.call(this, log, config);
@ -26,17 +26,17 @@ function Stream(log, config) {
process.once('exit', this.bound.onProcessExit);
}
_.inherits(Stream, LoggerAbstract);
_v4.inherits(Stream, LoggerAbstract);
Stream.prototype.cleanUpListeners = _.handler(function () {
Stream.prototype.cleanUpListeners = _v4.handler(function () {
process.removeListener('exit', this.bound.onProcessExit);
LoggerAbstract.prototype.cleanUpListeners.call(this);
});
// flush the write buffer to stderr synchronously
Stream.prototype.onProcessExit = _.handler(function () {
Stream.prototype.onProcessExit = _v4.handler(function () {
// process is dying, lets manually flush the buffer synchronously to stderr.
var unwritten = _.getUnwrittenFromStream(this.stream);
var unwritten = _v4.getUnwrittenFromStream(this.stream);
if (unwritten) {
console.error('Log stream did not get to finish writing. Flushing to stderr');
console.error(unwritten);

View File

@ -14,7 +14,7 @@ module.exports = Tracer;
var StreamLogger = require('./stream');
var fs = require('fs');
var _ = require('../utils');
// var _ = require('../utils');
var url = require('url');
function Tracer(log, config) {
@ -29,18 +29,18 @@ function Tracer(log, config) {
StreamLogger.call(this, log, config);
}
_.inherits(Tracer, StreamLogger);
_v4.inherits(Tracer, StreamLogger);
var usefulUrlFields = ['protocol', 'slashes', 'port', 'hostname', 'pathname', 'query'];
Tracer.prototype._formatTraceMessage = function (req) {
var reqUrl = _.pick(url.parse(req.url, true, false), usefulUrlFields);
var reqUrl = _v4.pick(url.parse(req.url, true, false), usefulUrlFields);
var originalHost = url.format(_.pick(reqUrl, 'protocol', 'hostname', 'port'));
var originalHost = url.format(_v4.pick(reqUrl, 'protocol', 'hostname', 'port'));
reqUrl.port = this.curlPort;
reqUrl.hostname = this.curlHost;
reqUrl.query = _.defaults(reqUrl.query || {}, { pretty: true });
reqUrl.query = _v4.defaults(reqUrl.query || {}, { pretty: true });
/* jshint quotmark: double */
var curlCall =
@ -56,7 +56,7 @@ Tracer.prototype._formatTraceMessage = function (req) {
};
function comment(str) {
return _.map(str.split(/\r?\n/g), function (line) {
return _v4.map(str.split(/\r?\n/g), function (line) {
return '# ' + line;
}).join('\n');
}

View File

@ -1,10 +1,10 @@
var _ = require('./utils');
// var _ = require('./utils');
var extractHostPartsRE1x = /\[\/*([^:]+):(\d+)\]/;
function makeNodeParser(hostProp) {
return function (nodes) {
return _.transform(nodes, function (hosts, node, id) {
return _v4.transform(nodes, function (hosts, node, id) {
var address = node[hostProp]
if (!address) return;

View File

@ -1,9 +1,9 @@
/* global angular */
var _ = require('../utils');
// var _ = require('../utils');
var JsonSerializer = require('../serializers/json');
function AngularSerializer() {}
_.inherits(AngularSerializer, JsonSerializer);
_v4.inherits(AngularSerializer, JsonSerializer);
// mimic the JsonSerializer's encode method, but use angular's toJson instead
AngularSerializer.prototype.encode = function (val) {

View File

@ -4,7 +4,7 @@
*/
module.exports = Json;
var _ = require('../utils');
// var _ = require('../utils');
function Json() {}
@ -46,7 +46,7 @@ Json.prototype.deserialize = function (str) {
Json.prototype.bulkBody = function (val) {
var body = '', i;
if (_.isArray(val)) {
if (_v4.isArray(val)) {
for (i = 0; i < val.length; i++) {
body += this.serialize(val[i]) + '\n';
}

View File

@ -4,7 +4,7 @@
*/
module.exports = Transport;
var _ = require('./utils');
// var _ = require('./utils');
var errors = require('./errors');
var Host = require('./host');
var Promise = require('promise/lib/es6-extensions');
@ -19,15 +19,15 @@ function Transport(config) {
config.log = self.log = new LogClass(config);
// setup the connection pool
var ConnectionPool = _.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main');
var ConnectionPool = _v4.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main');
self.connectionPool = new ConnectionPool(config);
// setup the serializer
var Serializer = _.funcEnum(config, 'serializer', Transport.serializers, 'json');
var Serializer = _v4.funcEnum(config, 'serializer', Transport.serializers, 'json');
self.serializer = new Serializer(config);
// setup the nodesToHostCallback
self.nodesToHostCallback = _.funcEnum(config, 'nodesToHostCallback', Transport.nodesToHostCallbacks, 'main');
self.nodesToHostCallback = _v4.funcEnum(config, 'nodesToHostCallback', Transport.nodesToHostCallbacks, 'main');
// setup max retries
self.maxRetries = config.hasOwnProperty('maxRetries') ? config.maxRetries : 3;
@ -50,8 +50,8 @@ function Transport(config) {
}
if (config.hosts) {
var hostsConfig = _.createArray(config.hosts, function (val) {
if (_.isPlainObject(val) || _.isString(val) || val instanceof Host) {
var hostsConfig = _v4.createArray(config.hosts, function (val) {
if (_v4.isPlainObject(val) || _v4.isString(val) || val instanceof Host) {
return val;
}
});
@ -139,7 +139,7 @@ Transport.prototype.request = function (params, cb) {
var defer; // the defer object, will be set when we are using promises.
var body = params.body;
var headers = !params.headers ? {} : _.transform(params.headers, function (headers, val, name) {
var headers = !params.headers ? {} : _v4.transform(params.headers, function (headers, val, name) {
headers[String(name).toLowerCase()] = val;
});
@ -161,7 +161,7 @@ Transport.prototype.request = function (params, cb) {
}
if (body && params.method === 'GET') {
_.nextTick(respond, new TypeError('Body can not be sent with method "GET"'));
_v4.nextTick(respond, new TypeError('Body can not be sent with method "GET"'));
return ret;
}
@ -274,10 +274,10 @@ Transport.prototype.request = function (params, cb) {
if (
(!err || err instanceof errors.Serialization)
&& (status < 200 || status >= 300)
&& (!params.ignore || !_.includes(params.ignore, status))
&& (!params.ignore || !_v4.includes(params.ignore, status))
) {
var errorMetadata = _.pick(params.req, ['path', 'query', 'body']);
var errorMetadata = _v4.pick(params.req, ['path', 'query', 'body']);
errorMetadata.statusCode = status;
errorMetadata.response = body;
@ -361,7 +361,7 @@ Transport.prototype._timeout = function (cb, delay) {
if (cb) {
// set the timer
id = setTimeout(function () {
_.pull(timers, id);
_v4.pull(timers, id);
cb();
}, delay);
@ -392,7 +392,7 @@ Transport.prototype.sniff = function (cb) {
var sniffedNodesProtocol = this.sniffedNodesProtocol;
// make cb a function if it isn't
cb = typeof cb === 'function' ? cb : _.noop;
cb = typeof cb === 'function' ? cb : _v4.noop;
this.request({
path: this.sniffEndpoint,
@ -409,7 +409,7 @@ Transport.prototype.sniff = function (cb) {
return;
}
_.forEach(hostsConfigs, function (hostConfig) {
_v4.forEach(hostsConfigs, function (hostConfig) {
if (sniffedNodesProtocol) hostConfig.protocol = sniffedNodesProtocol;
});
@ -427,7 +427,7 @@ Transport.prototype.sniff = function (cb) {
*/
Transport.prototype.setHosts = function (hostsConfigs) {
var globalConfig = this._config;
this.connectionPool.setHosts(_.map(hostsConfigs, function (conf) {
this.connectionPool.setHosts(_v4.map(hostsConfigs, function (conf) {
return (conf instanceof Host) ? conf : new Host(conf, globalConfig);
}));
};

View File

@ -1,4 +1,4 @@
var _ = require('../utils');
// var _ = require('../utils');
/**
@ -25,7 +25,7 @@ module.exports = function setupSniffOnConnectionFault(transport) {
// create a function that will count down to a
// point n milliseconds into the future
var countdownTo = function (ms) {
var start = _.now();
var start = _v4.now();
return function () {
return start - ms;
};

View File

@ -1,25 +1,26 @@
var path = require('path');
var _ = require('lodash-migrate');
// var _ = require('lodash');
// require('../../stub')
var nodeUtils = require('util');
/**
* Custom utils library, basically a modified version of [lodash](http://lodash.com/docs) +
* [node.utils](http://nodejs.org/api/util.html#util_util) that doesn't use mixins to prevent
* Custom _v4 library, basically a modified version of [lodash](http://lodash.com/docs) +
* [node._v4](http://nodejs.org/api/util.html#util_util) that doesn't use mixins to prevent
* confusion when requiring lodash itself.
*
* @class utils
* @class _v4
* @static
*/
var utils = _.extend({}, _, nodeUtils);
_ = utils;
_v4.assign(_v4, nodeUtils);
// _v4 = _v4;
/**
* Link to [path.join](http://nodejs.org/api/path.html#path_path_join_path1_path2)
*
* @method utils.joinPath
* @method _v4.joinPath
* @type {function}
*/
utils.joinPath = path.join;
_v4.joinPath = path.join;
/**
* Recursively merge two objects, walking into each object and concating arrays. If both to and from have a value at a
@ -31,18 +32,18 @@ utils.joinPath = path.join;
* @param {Object} from - Object to pull changed from
* @return {Object} - returns the modified to value
*/
utils.deepMerge = function (to, from) {
_v4.deepMerge = function (to, from) {
_v4.each(from, function (fromVal, key) {
switch (typeof to[key]) {
case 'undefined':
to[key] = from[key];
break;
case 'object':
if (_.isArray(to[key]) && _.isArray(from[key])) {
if (_v4.isArray(to[key]) && _v4.isArray(from[key])) {
to[key] = to[key].concat(from[key]);
}
else if (_.isPlainObject(to[key]) && _.isPlainObject(from[key])) {
utils.deepMerge(to[key], from[key]);
else if (_v4.isPlainObject(to[key]) && _v4.isPlainObject(from[key])) {
_v4.deepMerge(to[key], from[key]);
}
}
});
@ -65,11 +66,11 @@ _v4.each([
'Function',
'RegExp'
], function (type) {
var check = _['is' + type];
var check = _v4['is' + type];
utils['isArrayOf' + type + 's'] = function (arr) {
_v4['isArrayOf' + type + 's'] = function (arr) {
// quick shallow check of arrays
return _.isArray(arr) && _.every(arr.slice(0, 10), check);
return _v4.isArray(arr) && _v4.every(arr.slice(0, 10), check);
};
});
@ -81,7 +82,7 @@ _v4.each([
* @param {string} word - The word to transform
* @return {string}
*/
utils.ucfirst = function (word) {
_v4.ucfirst = function (word) {
return word[0].toUpperCase() + word.substring(1).toLowerCase();
};
@ -142,7 +143,7 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) {
* @param {String} string
* @return {String}
*/
utils.studlyCase = adjustWordCase(true, true, '');
_v4.studlyCase = adjustWordCase(true, true, '');
/**
* Transform a string into camelCase
@ -151,7 +152,7 @@ utils.studlyCase = adjustWordCase(true, true, '');
* @param {String} string
* @return {String}
*/
utils.camelCase = adjustWordCase(false, true, '');
_v4.camelCase = adjustWordCase(false, true, '');
/**
* Transform a string into snakeCase
@ -160,7 +161,7 @@ utils.camelCase = adjustWordCase(false, true, '');
* @param {String} string
* @return {String}
*/
utils.snakeCase = adjustWordCase(false, false, '_');
_v4.snakeCase = adjustWordCase(false, false, '_');
/**
* Lower-case a string, and return an empty string if any is not a string
@ -168,7 +169,7 @@ utils.snakeCase = adjustWordCase(false, false, '_');
* @param any {*} - Something or nothing
* @returns {string}
*/
utils.toLowerString = function (any) {
_v4.toLowerString = function (any) {
if (any) {
if (typeof any !== 'string') {
any = any.toString();
@ -185,7 +186,7 @@ utils.toLowerString = function (any) {
* @param any {*} - Something or nothing
* @returns {string}
*/
utils.toUpperString = function (any) {
_v4.toUpperString = function (any) {
if (any) {
if (typeof any !== 'string') {
any = any.toString();
@ -203,7 +204,7 @@ utils.toUpperString = function (any) {
* @param {*} val
* @return {Boolean}
*/
utils.isNumeric = function (val) {
_v4.isNumeric = function (val) {
return typeof val !== 'object' && val - parseFloat(val) >= 0;
};
@ -217,7 +218,7 @@ var intervalRE = /^(\d+(?:\.\d+)?)(M|w|d|h|m|s|y|ms)$/;
* @param {String} val
* @return {Boolean}
*/
utils.isInterval = function (val) {
_v4.isInterval = function (val) {
return !!(val.match && val.match(intervalRE));
};
@ -230,7 +231,7 @@ utils.isInterval = function (val) {
* @param {Number} times - Times the string should be repeated
* @return {String}
*/
utils.repeat = function (what, times) {
_v4.repeat = function (what, times) {
return (new Array(times + 1)).join(what);
};
@ -243,7 +244,7 @@ utils.repeat = function (what, times) {
* @param [sliceIndex=0] {Integer} - The index that args should be sliced at, before feeding args to func
* @returns {*} - the return value of func
*/
utils.applyArgs = function (func, context, args, sliceIndex) {
_v4.applyArgs = function (func, context, args, sliceIndex) {
sliceIndex = sliceIndex || 0;
switch (args.length - sliceIndex) {
case 0:
@ -269,9 +270,9 @@ utils.applyArgs = function (func, context, args, sliceIndex) {
* when it is called.
* @return {[type]} [description]
*/
_.nextTick = function (cb) {
_v4.nextTick = function (cb) {
// bind the function and schedule it
process.nextTick(_.bindKey(_, 'applyArgs', cb, null, arguments, 1));
process.nextTick(_v4.bindKey(_v4, 'applyArgs', cb, null, arguments, 1));
};
/**
@ -279,7 +280,7 @@ _.nextTick = function (cb) {
* flagging it to be bound to the object at object creation when "makeBoundMethods" is called
*
* ```
* ClassName.prototype.methodName = _.handler(function () {
* ClassName.prototype.methodName = _v4.handler(function () {
* // this will always be bound when called via classInstance.bound.methodName
* this === classInstance
* });
@ -289,11 +290,11 @@ _.nextTick = function (cb) {
* @param {Function} func - The method that is being defined
* @return {Function}
*/
_.handler = function (func) {
_v4.handler = function (func) {
func._provideBound = true;
return func;
};
_.scheduled = _.handler;
_v4.scheduled = _v4.handler;
/**
* Creates an "bound" property on an object, which all or a subset of methods from
@ -304,24 +305,24 @@ _.scheduled = _.handler;
* onEvent: function () {}
* };
*
* _.makeBoundMethods(obj);
* _v4.makeBoundMethods(obj);
*
* obj.bound.onEvent() // is bound to obj, and can safely be used as an event handler.
* ```
*
* @param {Object} obj - The object to bind the methods to
*/
_.makeBoundMethods = function (obj) {
_v4.makeBoundMethods = function (obj) {
obj.bound = {};
for (var prop in obj) {
// dearest maintainer, we want to look through the prototype
if (typeof obj[prop] === 'function' && obj[prop]._provideBound === true) {
obj.bound[prop] = _.bind(obj[prop], obj);
obj.bound[prop] = _v4.bind(obj[prop], obj);
}
}
};
_.noop = function () {};
_v4.noop = function () {};
/**
* Implements the standard "string or constructor" check that I was copy/pasting everywhere
@ -329,7 +330,7 @@ _.noop = function () {};
* @param {Object} opts - a map of the options
* @return {Function|undefined} - If a valid option was specified, then the constructor is returned
*/
_.funcEnum = function (config, name, opts, def) {
_v4.funcEnum = function (config, name, opts, def) {
var val = config[name];
switch (typeof val) {
case 'undefined':
@ -343,14 +344,14 @@ _.funcEnum = function (config, name, opts, def) {
/* falls through */
default:
var err = 'Invalid ' + name + ' "' + val + '", expected a function';
switch (_.size(opts)) {
switch (_v4.size(opts)) {
case 0:
break;
case 1:
err += ' or ' + _.keys(opts)[0];
err += ' or ' + _v4.keys(opts)[0];
break;
default:
err += ' or one of ' + _.keys(opts).join(', ');
err += ' or one of ' + _v4.keys(opts).join(', ');
break;
}
throw new TypeError(err);
@ -367,13 +368,13 @@ _.funcEnum = function (config, name, opts, def) {
* @param {Function} transform - A function called for each element of the resulting array
* @return {Array|false} - an array on success, or false on failure.
*/
_.createArray = function (input, transform) {
transform = typeof transform === 'function' ? transform : _.identity;
_v4.createArray = function (input, transform) {
transform = typeof transform === 'function' ? transform : _v4.identity;
var output = [];
var item;
var i;
if (!_.isArray(input)) {
if (!_v4.isArray(input)) {
input = [input];
}
@ -396,8 +397,8 @@ _.createArray = function (input, transform) {
* @param {WritableStream} stream - an instance of stream.Writable
* @return {string} - the remaining test to be written to the stream
*/
_.getUnwrittenFromStream = function (stream) {
var writeBuffer = _.getStreamWriteBuffer(stream);
_v4.getUnwrittenFromStream = function (stream) {
var writeBuffer = _v4.getStreamWriteBuffer(stream);
if (!writeBuffer) return;
// flush the write buffer
@ -408,7 +409,7 @@ _.getUnwrittenFromStream = function (stream) {
if (writeReq.chunk) {
// 0.9.12+ uses WriteReq objects with a chunk prop
out += '' + writeReq.chunk;
} else if (_.isArray(writeReq) && (typeof writeReq[0] === 'string' || Buffer.isBuffer(writeReq[0]))) {
} else if (_v4.isArray(writeReq) && (typeof writeReq[0] === 'string' || Buffer.isBuffer(writeReq[0]))) {
// 0.9.4 - 0.9.9 buffers are arrays of arrays like [[chunk, cb], [chunk, undef], ...].
out += '' + writeReq[0];
} else {
@ -418,7 +419,7 @@ _.getUnwrittenFromStream = function (stream) {
return out;
};
_.getStreamWriteBuffer = function (stream) {
_v4.getStreamWriteBuffer = function (stream) {
if (!stream || !stream._writableState) return;
var writeState = stream._writableState;
@ -430,16 +431,16 @@ _.getStreamWriteBuffer = function (stream) {
}
};
_.clearWriteStreamBuffer = function (stream) {
var buffer = _.getStreamWriteBuffer(stream);
_v4.clearWriteStreamBuffer = function (stream) {
var buffer = _v4.getStreamWriteBuffer(stream);
return buffer && buffer.splice(0);
};
/**
* return the current time in milliseconds since epoch
*/
_.now = function () {
_v4.now = function () {
return (typeof Date.now === 'function') ? Date.now() : (new Date()).getTime();
};
module.exports = utils;
module.exports = _v4;

View File

@ -1,6 +1,6 @@
var clock = require('sinon').useFakeTimers();
var Client = require('../../src/elasticsearch').Client;
var _ = require('lodash-migrate');
// var _ = require('lodash');
var times = require('async').times;
process.once('message', function (port) {
@ -20,9 +20,9 @@ process.once('message', function (port) {
clock.tick(10);
}, function (err) {
var conns = es.transport.connectionPool._conns;
var sockets = _([].concat(conns.dead, conns.alive))
var sockets = _v4([].concat(conns.dead, conns.alive))
.transform(function (sockets, conn) {
sockets.push(_.values(conn.agent.sockets), _.values(conn.agent.freeSockets));
sockets.push(_v4.values(conn.agent.sockets), _v4.values(conn.agent.freeSockets));
}, [])
.flattenDeep()
.value();
@ -31,8 +31,8 @@ process.once('message', function (port) {
var out = {
socketCount: err || sockets.length,
remaining: _.where(sockets, { destroyed: true }).length - sockets.length,
timeouts: _.size(clock.timers) && _.map(clock.timers, 'func').map(String)
remaining: _v4.filter(sockets, { destroyed: true }).length - sockets.length,
timeouts: _v4.size(clock.timers) && _v4.map(clock.timers, 'func').map(String)
};
clock.restore();

View File

@ -9,10 +9,10 @@ if (BROWSER) {
es = require('../../../src/elasticsearch');
}
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var path = require('path');
var fs = require('fs');
var fromRoot = _.bindKey(path, 'join', require('find-root')(__dirname));
var fromRoot = _v4.bindKey(path, 'join', require('find-root')(__dirname));
var Bluebird = require('bluebird');
// current client
@ -60,7 +60,7 @@ module.exports = {
}
var logConfig = {};
if (_.has(options, 'logConfig')) {
if (_v4.has(options, 'logConfig')) {
logConfig = options.logConfig;
} else {
if (BROWSER) {
@ -106,14 +106,14 @@ module.exports = {
client.snapshot.getRepository({
snapshot: '_all'
})
.then(_.keys)
.then(_v4.keys)
.map(function (repo) {
return client.snapshot.get({
repository: repo,
snapshot: '_all'
})
.then(function (resp) {
return _.map(resp.snapshots, 'snapshot');
return _v4.map(resp.snapshots, 'snapshot');
}, function () {
return [];
})
@ -132,7 +132,7 @@ module.exports = {
]);
};
_.nextTick(cb);
_v4.nextTick(cb);
}
},
get: function () {

View File

@ -4,7 +4,7 @@ module.exports = function (branch) {
var YamlFile = require('./yaml_file');
var root = require('find-root')(__dirname);
var rootReq = function (loc) { return require(path.join(root, loc)); };
var _ = rootReq('src/lib/utils');
// var _ = rootReq('src/lib/utils');
var utils = rootReq('grunt/utils');
var es = rootReq('src/elasticsearch');
var clientManager = require('./client_manager');
@ -32,7 +32,7 @@ module.exports = function (branch) {
return clientManager.get().clearEs();
});
var files = _v4.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) {
var files = _v4.map(require('./yaml_tests_' + _v4.snakeCase(branch) + '.json'), function (docs, filename) {
return new YamlFile(filename, docs);
});

View File

@ -9,7 +9,7 @@
*/
module.exports = YamlDoc;
var _ = require('lodash-migrate/lodash');
// var _ = require('lodash-migrate/lodash');
var expect = require('expect.js');
var clientManager = require('./client_manager');
var inspect = require('util').inspect;
@ -70,8 +70,8 @@ function versionToComparableString(version, def) {
return def;
}
var parts = _.map(version.split('.'), function (part) {
part = '' + _.parseInt(part);
var parts = _v4.map(version.split('.'), function (part) {
part = '' + _v4.parseInt(part);
return (new Array(Math.max(4 - part.length, 0))).join('0') + part;
});
@ -109,26 +109,26 @@ function YamlDoc(doc, file) {
var self = this;
self.file = file;
self.description = _.keys(doc).shift();
self.description = _v4.keys(doc).shift();
self._stash = {};
self._last_requests_response = null;
// setup the actions, creating a bound and testable method for each
self._actions = _.map(self.flattenTestActions(doc[self.description]), function (action) {
self._actions = _v4.map(self.flattenTestActions(doc[self.description]), function (action) {
// get the method that will do the action
var method = self['do_' + action.name];
// check that it's a function
expect(method || 'YamlDoc#' + action.name).to.be.a('function');
if (_.isPlainObject(action.args)) {
if (_v4.isPlainObject(action.args)) {
action.name += '(' + JSON.stringify(action.args) + ')';
} else if (action.args) {
action.name += '(' + action.args + ')';
}
// wrap in a check for skipping
action.bound = _.bind(method, self, action.args);
action.bound = _v4.bind(method, self, action.args);
// create a function that can be passed to mocha or async
action.testable = function (_cb) {
@ -199,15 +199,15 @@ YamlDoc.prototype = {
flattenTestActions: function (config) {
// creates [ [ {name:"", args:"" }, ... ], ... ]
// from [ {name:args, name:args}, {name:args} ]
var actionSets = _.map(config, function (set) {
return _.map(_.toPairs(set), function (pair) {
var actionSets = _v4.map(config, function (set) {
return _v4.map(_v4.toPairs(set), function (pair) {
return { name: pair[0], args: pair[1] };
});
});
// do a single level flatten, merge=ing the nested arrays from step one
// into a master array, creating an array of action objects
return _.reduce(actionSets, function (note, set) {
return _v4.reduce(actionSets, function (note, set) {
return note.concat(set);
}, []);
},
@ -273,7 +273,7 @@ YamlDoc.prototype = {
log('getting', path, 'from', from);
var steps = _.map(path ? path.replace(/\\\./g, '\uffff').split('.') : [], function (step) {
var steps = _v4.map(path ? path.replace(/\\\./g, '\uffff').split('.') : [], function (step) {
return step.replace(/\uffff/g, '.');
});
var remainingSteps;
@ -301,7 +301,7 @@ YamlDoc.prototype = {
*/
do_skip: function (args, done) {
if (args.version) {
return rangeMatchesCurrentVersion(args.version, _.bind(function (match) {
return rangeMatchesCurrentVersion(args.version, _v4.bind(function (match) {
if (match) {
if (this.description === 'setup') {
this.file.skipping = true;
@ -320,7 +320,7 @@ YamlDoc.prototype = {
if (args.features) {
var features = Array.isArray(args.features) ? args.features : [args.features];
var notImplemented = _.difference(features, implementedFeatures);
var notImplemented = _v4.difference(features, implementedFeatures);
if (notImplemented.length) {
if (this.description === 'setup') {
@ -396,19 +396,19 @@ YamlDoc.prototype = {
delete args.headers;
}
var otherKeys = _.keys(args);
var otherKeys = _v4.keys(args);
var action = otherKeys.shift();
if (otherKeys.length) {
return done(new TypeError('Unexpected top-level args to "do": ' + otherKeys.join(', ')));
}
var client = clientManager.get();
var clientActionName = _.map(action.split('.'), _.camelCase).join('.');
var clientActionName = _v4.map(action.split('.'), _v4.camelCase).join('.');
var clientAction = this.get(clientActionName, client);
_.assign(inputParams, args[action]);
_v4.assign(inputParams, args[action]);
var params = _.transform(inputParams, _.bind(function (params, val, name) {
var camelName = _.camelCase(name);
var params = _v4.transform(inputParams, _v4.bind(function (params, val, name) {
var camelName = _v4.camelCase(name);
// search through the params and url peices to find this param name
var paramName = name;
@ -427,10 +427,10 @@ YamlDoc.prototype = {
// for ercursively traversing the params to replace '$stashed' vars
var transformObject = function (vals, val, i) {
if (_.isString(val)) {
if (_v4.isString(val)) {
val = (val[0] === '$') ? this.get(val) : val;
} else if (_.isPlainObject(val) || _.isArray(val)) {
val = _.transform(val, transformObject);
} else if (_v4.isPlainObject(val) || _v4.isArray(val)) {
val = _v4.transform(val, transformObject);
}
vals[i] = val;
@ -443,12 +443,12 @@ YamlDoc.prototype = {
expect(clientAction || clientActionName).to.be.a('function');
if (!isNaN(parseFloat(catcher))) {
params.ignore = _.union(params.ignore || [], [catcher]);
params.ignore = _v4.union(params.ignore || [], [catcher]);
catcher = null;
}
var timeoutId;
var cb = _.bind(function (error, body) {
var cb = _v4.bind(function (error, body) {
this._last_requests_response = body;
clearTimeout(timeoutId);
@ -494,7 +494,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_set: function (args) {
_.forOwn(args, _.bind(function (name, path) {
_v4.forOwn(args, _v4.bind(function (name, path) {
this._stash[name] = this.get(path);
}, this));
},
@ -566,25 +566,25 @@ YamlDoc.prototype = {
var self = this;
// recursively replace all $var within args
_.forOwn(args, function recurse(val, key, lvl) {
if (_.isObject(val)) {
_v4.forOwn(args, function recurse(val, key, lvl) {
if (_v4.isObject(val)) {
return _v4.each(val, recurse);
}
if (_.isString(val)) {
if (_v4.isString(val)) {
lvl[key] = val.replace(/\$[a-zA-Z0-9_]+/g, function (name) {
return self.get(name);
});
}
});
_.forOwn(args, _.bind(function (match, path) {
_v4.forOwn(args, _v4.bind(function (match, path) {
var origMatch = match;
var maybeRE = false;
var usedRE = false;
if (_.isString(match)) {
if (_v4.isString(match)) {
// convert the matcher into a compatible string for building a regexp
maybeRE = match
// replace comments, but allow the # to be escaped like \#
@ -655,7 +655,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_lt: function (args) {
_.forOwn(args, _.bind(function (num, path) {
_v4.forOwn(args, _v4.bind(function (num, path) {
expect(this.get(path)).to.be.below(num, 'path: ' + path);
}, this));
},
@ -667,7 +667,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_lte: function (args) {
_.forOwn(args, _.bind(function (num, path) {
_v4.forOwn(args, _v4.bind(function (num, path) {
expect(this.get(path) <= num).to.be.ok('path: ' + path);
}, this));
},
@ -679,7 +679,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_gt: function (args) {
_.forOwn(args, _.bind(function (num, path) {
_v4.forOwn(args, _v4.bind(function (num, path) {
expect(this.get(path)).to.be.above(num, 'path: ' + path);
}, this));
},
@ -691,7 +691,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_gte: function (args) {
_.forOwn(args, _.bind(function (num, path) {
_v4.forOwn(args, _v4.bind(function (num, path) {
expect(this.get(path) >= num).to.be.ok('path: ' + path);
}, this));
},
@ -704,8 +704,8 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_length: function (args) {
_.forOwn(args, _.bind(function (len, path) {
expect(_.size(this.get(path))).to.eql(len, 'path: ' + path);
_v4.forOwn(args, _v4.bind(function (len, path) {
expect(_v4.size(this.get(path))).to.eql(len, 'path: ' + path);
}, this));
}
};

View File

@ -8,7 +8,7 @@ module.exports = YamlFile;
var YamlDoc = require('./yaml_doc');
var clientManager = require('./client_manager');
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var async = require('async');
function YamlFile(filename, docs) {

View File

@ -27,7 +27,7 @@
module.exports = MockHttpRequest;
var _ = require('lodash-migrate');
// var _ = require('lodash');
function MockHttpRequest() {
// These are internal flags and data structures

View File

@ -3,7 +3,7 @@ var complete = [];
var MockHttpRequest = require('./browser_http');
var XhrServer = MockHttpRequest.MockHttpServer;
var parseUrl = MockHttpRequest.prototype.parseUri;
var _ = require('lodash-migrate');
// var _ = require('lodash');
var server = new XhrServer(function (request) {
var reqDetails = {

View File

@ -1,4 +1,5 @@
var _ = require('lodash-migrate');
/* global angular */
// var _ = require('lodash');
var expect = require('expect.js');
var Promise = require('bluebird');
var sinon = require('sinon');
@ -16,13 +17,13 @@ describe('Angular esFactory', function () {
function bootstrap(env) {
beforeEach(function () {
var promiseProvider = _.noop;
var promiseProvider = _v4.noop;
if (env.bluebirdPromises) {
promiseProvider = function ($provide) {
$provide.service('$q', function () {
return {
defer: function () {
return _.bindAll(Promise.defer(), ['resolve', 'reject']);
return _v4.bindAll(Promise.defer(), ['resolve', 'reject']);
},
reject: Promise.reject,
when: Promise.resolve,

View File

@ -1,3 +1,4 @@
/* global $ */
var expect = require('expect.js');
var Transport = require('../../../src/lib/transport');

View File

@ -3,7 +3,7 @@ module.exports = function (makeLogger) {
var stub = require('../utils/auto_release_stub').make();
var fs = require('fs');
var once = require('events').EventEmitter.prototype.once;
var _ = require('lodash-migrate');
// var _ = require('lodash');
describe('buffer flush', function () {
if (require('stream').Writable) {

View File

@ -1,7 +1,7 @@
var ca = require('../../../src/lib/client_action').factory;
var proxy = require('../../../src/lib/client_action').proxyFactory;
var expect = require('expect.js');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var Promise = require('bluebird');
/**
@ -45,7 +45,7 @@ function makeClientAction(spec) {
};
}
return _.bind(ca(spec), mockClient());
return _v4.bind(ca(spec), mockClient());
}
/**
@ -55,7 +55,7 @@ function makeClientAction(spec) {
* @return {Function} - the clientActionProxy
*/
function makeClientActionProxy(fn, spec) {
return _.bind(proxy(fn, spec || {}), mockClient());
return _v4.bind(proxy(fn, spec || {}), mockClient());
}
@ -118,7 +118,7 @@ describe('Client Action runner', function () {
it('handles passing just the callback', function () {
var action = makeClientActionProxy(function (params, cb) {
expect(_.isObject(params)).to.be.ok();
expect(_v4.isObject(params)).to.be.ok();
expect(cb).to.be.a('function');
});

View File

@ -2,7 +2,7 @@ var ConnectionAbstract = require('../../../src/lib/connection');
var Host = require('../../../src/lib/host');
var sinon = require('sinon');
var expect = require('expect.js');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var errors = require('../../../src/lib/errors');
var stub = require('../../utils/auto_release_stub').make();
@ -73,10 +73,10 @@ describe('Connection Abstract', function () {
stub(conn, 'request');
expect(_.size(clock.timers)).to.eql(0);
expect(_v4.size(clock.timers)).to.eql(0);
conn.ping();
expect(_.size(clock.timers)).to.eql(1);
expect(clock.timers[_.keys(clock.timers).shift()].delay).to.eql(5000);
expect(_v4.size(clock.timers)).to.eql(1);
expect(clock.timers[_v4.keys(clock.timers).shift()].delay).to.eql(5000);
});
it('calls it\'s own request method', function () {

View File

@ -1,7 +1,7 @@
var ConnectionPool = require('../../../src/lib/connection_pool');
var Host = require('../../../src/lib/host');
var ConnectionAbstract = require('../../../src/lib/connection');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var EventEmitter = require('events').EventEmitter;
var expect = require('expect.js');
var sinon = require('sinon');
@ -36,10 +36,10 @@ describe('Connection Pool', function () {
});
it('#addConnection only adds the connection if it doesn\'t already exist', function () {
expect(_.keys(pool.index).length).to.eql(0);
expect(_v4.keys(pool.index).length).to.eql(0);
pool.addConnection(connection);
expect(_.keys(pool.index)).to.eql([host.toString()]);
expect(_v4.keys(pool.index)).to.eql([host.toString()]);
expect(pool._conns.alive).to.eql([connection]);
expect(pool._conns.dead).to.eql([]);
@ -52,7 +52,7 @@ describe('Connection Pool', function () {
expect(pool._conns.alive).to.eql([connection]);
expect(pool._conns.dead).to.eql([]);
expect(_.keys(pool.index).length).to.eql(1);
expect(_v4.keys(pool.index).length).to.eql(1);
});
it('closes the connection when it removes it', function () {
@ -247,13 +247,13 @@ describe('Connection Pool', function () {
stub.autoRelease(clock);
connection.setStatus('dead');
expect(_.size(clock.timers)).to.eql(1);
var id = _(clock.timers).keys().first();
expect(_v4.size(clock.timers)).to.eql(1);
var id = _v4(clock.timers).keys().first();
// it re-dies
connection.setStatus('dead');
expect(_.size(clock.timers)).to.eql(1);
expect(_(clock.timers).keys().first()).to.not.eql(id);
expect(_v4.size(clock.timers)).to.eql(1);
expect(_v4(clock.timers).keys().first()).to.not.eql(id);
});
it('does nothing when a connection is re-alive', function () {
@ -295,7 +295,7 @@ describe('Connection Pool', function () {
var result = pool.getConnections();
expect(result.length).to.be(1000);
expect(_.reduce(result, function (sum, num) {
expect(_v4.reduce(result, function (sum, num) {
sum += num
return sum;
}, 0)).to.eql(499500);

View File

@ -1,6 +1,6 @@
var errors = require('../../../src/lib/errors');
var expect = require('expect.js');
var _ = require('lodash-migrate');
// var _ = require('lodash');
_v4.each(errors, function (CustomError, name) {
if (name.charAt(0) !== '_') {

View File

@ -2,7 +2,7 @@ describe('File Logger', function () {
var Log = require('../../../src/lib/log');
var FileLogger = require('../../../src/lib/loggers/file');
var once = require('events').EventEmitter.prototype.once;
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var parentLog;
var logger;
var expect = require('expect.js');
@ -15,7 +15,7 @@ describe('File Logger', function () {
afterEach(function () {
parentLog.close();
logger && _.clearWriteStreamBuffer(logger.stream);
logger && _v4.clearWriteStreamBuffer(logger.stream);
});
function makeLogger(parent, levels) {

View File

@ -1,5 +1,5 @@
var Host = require('../../../src/lib/host');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
var url = require('url');
var expectSubObject = require('../../utils/expect_sub_object');

View File

@ -1,6 +1,6 @@
describe('Http Connector', function () {
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
var nock = require('nock');
var sinon = require('sinon');
@ -67,12 +67,12 @@ describe('Http Connector', function () {
it('allows defining a custom agent', function () {
var football = {};
var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(football) });
var con = new HttpConnection(new Host(), { createNodeAgent: _v4.constant(football) });
expect(con.agent).to.be(football);
});
it('allows setting agent to false', function () {
var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(false) });
var con = new HttpConnection(new Host(), { createNodeAgent: _v4.constant(false) });
expect(con.agent).to.be(false);
});
});
@ -482,7 +482,7 @@ describe('Http Connector', function () {
this.timeout(5 * 60 * 1000);
var cp = require('child_process');
var path = require('path');
var fixture = _.partial(path.join, __dirname, '../../fixtures');
var fixture = _v4.partial(path.join, __dirname, '../../fixtures');
var timeout; // start the timeout once we hear back from the client
var server = cp.fork(fixture('keepalive_server.js'))

View File

@ -1,5 +1,5 @@
var Log = require('../../../src/lib/log');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
describe('Log class', function () {
@ -129,11 +129,11 @@ describe('Log class', function () {
log: [
{
type: function (log, config) {
log.on('error', _.noop);
log.on('warning', _.noop);
log.on('info', _.noop);
log.on('debug', _.noop);
log.on('trace', _.noop);
log.on('error', _v4.noop);
log.on('warning', _v4.noop);
log.on('info', _v4.noop);
log.on('debug', _v4.noop);
log.on('trace', _v4.noop);
}
}
]

View File

@ -1,18 +1,18 @@
describe('Random Selector', function () {
var randomSelector = require('../../../src/lib/selectors/random');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
it('chooses a selection by random', function () {
var log = { a: 0, b: 0, c: 0 };
var choices = _.keys(log);
var choices = _v4.keys(log);
_v4.times(1000, function () {
var choice = randomSelector(choices);
log[choice]++;
});
expect(_.filter(log, function (count) {
expect(_v4.filter(log, function (count) {
return count < 200 || count > 400;
})).to.have.length(0);

View File

@ -1,6 +1,6 @@
describe('Round Robin Selector', function () {
var selector = require('../../../src/lib/selectors/round_robin');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
it('chooses options in order', function () {

View File

@ -4,7 +4,7 @@ describe('Stream Logger', function () {
var MockWritableStream = require('../../mocks/writable_stream');
var once = require('events').EventEmitter.prototype.once;
var stream = new MockWritableStream();
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var expect = require('expect.js');
var parentLog;
@ -19,7 +19,7 @@ describe('Stream Logger', function () {
afterEach(function () {
parentLog.close();
_.clearWriteStreamBuffer(stream);
_v4.clearWriteStreamBuffer(stream);
});
function makeLogger(parent, levels) {
@ -41,7 +41,7 @@ describe('Stream Logger', function () {
// get the last handler for process's "exit" event
var exitHandlers = process._events.exit;
var exitHandler = _.isArray(exitHandlers) ? _.last(exitHandlers) : exitHandlers;
var exitHandler = _v4.isArray(exitHandlers) ? _v4.last(exitHandlers) : exitHandlers;
// allow the logger to acctually write to the stream
stream.write.restore();

View File

@ -4,7 +4,7 @@ var errors = require('../../../src/lib/errors');
var sinon = require('sinon');
var expect = require('expect.js');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var nodeList = require('../../fixtures/short_node_list.json');
var stub = require('../../utils/auto_release_stub').make();
@ -83,11 +83,11 @@ describe('Transport Class', function () {
sniffInterval: 25000
});
expect(_.size(clock.timers)).to.eql(1);
var id = _.keys(clock.timers).pop();
expect(_v4.size(clock.timers)).to.eql(1);
var id = _v4.keys(clock.timers).pop();
clock.tick(25000);
expect(trans.sniff.callCount).to.eql(1);
expect(_.size(clock.timers)).to.eql(1);
expect(_v4.size(clock.timers)).to.eql(1);
expect(clock.timers).to.not.have.key(id);
});
@ -285,7 +285,7 @@ describe('Transport Class', function () {
describe('randomizeHosts options', function () {
it('calls _.shuffle be default', function () {
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_v4, 'shuffle');
var trans = new Transport({
@ -295,7 +295,7 @@ describe('Transport Class', function () {
expect(_v4.shuffle.callCount).to.eql(1);
});
it('skips the call to _.shuffle when false', function () {
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_v4, 'shuffle');
var trans = new Transport({
@ -606,7 +606,7 @@ describe('Transport Class', function () {
}
var trans = new Transport({
hosts: _.map(new Array(retries + 1), function (val, i) {
hosts: _v4.map(new Array(retries + 1), function (val, i) {
return 'localhost/' + i;
}),
maxRetries: retries,
@ -617,7 +617,7 @@ describe('Transport Class', function () {
});
// trigger a select so that we can harvest the connection list
trans.connectionPool.select(_.noop);
trans.connectionPool.select(_v4.noop);
_v4.each(connections, function (conn) {
stub(conn, 'request', failRequest);
});
@ -641,7 +641,7 @@ describe('Transport Class', function () {
it('returns an object with an abort() method when a callback is sent', function () {
var tran = new Transport();
shortCircuitRequest(tran);
var ret = tran.request({}, _.noop);
var ret = tran.request({}, _v4.noop);
expect(ret).to.be.a('object');
expect(ret.abort).to.be.a('function');
});
@ -651,7 +651,7 @@ describe('Transport Class', function () {
var ret = tran.request({});
expect(ret.then).to.be.a('function');
expect(ret.abort).to.be.a('function');
ret.then(_.noop, _.noop); // prevent complaining from bluebird
ret.then(_v4.noop, _v4.noop); // prevent complaining from bluebird
});
it('promise is always pulled from the defer created by this.defer()', function () {
var fakePromise = {};
@ -659,8 +659,8 @@ describe('Transport Class', function () {
var tran = new Transport({
defer: function () {
return {
resolve: _.noop,
reject: _.noop,
resolve: _v4.noop,
reject: _v4.noop,
promise: fakePromise
};
}
@ -759,9 +759,9 @@ describe('Transport Class', function () {
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
prom.then(_.noop, _.noop);
prom.then(_v4.noop, _v4.noop);
expect(_.size(clock.timers)).to.eql(1);
expect(_v4.size(clock.timers)).to.eql(1);
_v4.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(30000);
clearTimeout(id);
@ -776,9 +776,9 @@ describe('Transport Class', function () {
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
prom.then(_.noop, _.noop);
prom.then(_v4.noop, _v4.noop);
expect(_.size(clock.timers)).to.eql(1);
expect(_v4.size(clock.timers)).to.eql(1);
_v4.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(5000);
clearTimeout(id);
@ -797,7 +797,7 @@ describe('Transport Class', function () {
requestTimeout: falsy
}, function () {});
expect(_.size(clock.timers)).to.eql(0);
expect(_v4.size(clock.timers)).to.eql(0);
});
});
});

View File

@ -7,7 +7,7 @@ var expect = require('expect.js');
var sinon = require('sinon');
var nock = require('../../mocks/server.js');
var through2 = require('through2');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var nodeList = require('../../fixtures/short_node_list.json');
var stub = require('../../utils/auto_release_stub').make();
@ -277,7 +277,7 @@ describe('Transport + Mock server', function () {
expect(err).to.be(undefined);
expect(resp).to.eql({ i: 'am here' });
expect(status).to.eql(200);
expect(_.keys(clock.timers)).to.have.length(0);
expect(_v4.keys(clock.timers)).to.have.length(0);
clock.restore();
});
});
@ -342,9 +342,9 @@ describe('Transport + Mock server', function () {
.catch(function (err) {
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
expect(tran.sniff.callCount).to.eql(0);
expect(_.size(clock.timers)).to.eql(1);
expect(_v4.size(clock.timers)).to.eql(1);
var timeout = _.values(clock.timers).pop();
var timeout = _v4.values(clock.timers).pop();
timeout.func();
expect(tran.sniff.callCount).to.eql(1);
});

View File

@ -1,4 +1,4 @@
var _ = require('../../../src/lib/utils');
// var _ = require('../../../src/lib/utils');
var expect = require('expect.js');
var stub = require('../../utils/auto_release_stub').make();
@ -6,7 +6,7 @@ var stub = require('../../utils/auto_release_stub').make();
describe('Utils', function () {
describe('Additional Type Checkers', function () {
_.forEach({
_v4.forEach({
Object: {
is: [[], /regexp/]
},
@ -34,66 +34,66 @@ describe('Utils', function () {
function (thing, name) {
describe('#isArrayOf' + name, function () {
it('likes arrays of ' + name, function () {
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(true);
expect(_v4['isArrayOf' + name + 's'](thing.is)).to.be(true);
});
it('dislikes when there is even one non ' + name, function () {
// notice a string in the array
thing.is.push(thing.not || ' not ');
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(false);
expect(_v4['isArrayOf' + name + 's'](thing.is)).to.be(false);
});
});
});
describe('#isNumeric', function () {
it('likes integer literals', function () {
expect(_.isNumeric('-10')).to.be(true);
expect(_.isNumeric('0')).to.be(true);
expect(_.isNumeric('5')).to.be(true);
expect(_.isNumeric(-16)).to.be(true);
expect(_.isNumeric(0)).to.be(true);
expect(_.isNumeric(32)).to.be(true);
expect(_.isNumeric('040')).to.be(true);
expect(_.isNumeric('0xFF')).to.be(true);
expect(_.isNumeric(0xFFF)).to.be(true);
expect(_v4.isNumeric('-10')).to.be(true);
expect(_v4.isNumeric('0')).to.be(true);
expect(_v4.isNumeric('5')).to.be(true);
expect(_v4.isNumeric(-16)).to.be(true);
expect(_v4.isNumeric(0)).to.be(true);
expect(_v4.isNumeric(32)).to.be(true);
expect(_v4.isNumeric('040')).to.be(true);
expect(_v4.isNumeric('0xFF')).to.be(true);
expect(_v4.isNumeric(0xFFF)).to.be(true);
});
it('likes float literals', function () {
expect(_.isNumeric('-1.6')).to.be(true);
expect(_.isNumeric('4.536')).to.be(true);
expect(_.isNumeric(-2.6)).to.be(true);
expect(_.isNumeric(3.1415)).to.be(true);
expect(_.isNumeric(8e5)).to.be(true);
expect(_.isNumeric('123e-2')).to.be(true);
expect(_v4.isNumeric('-1.6')).to.be(true);
expect(_v4.isNumeric('4.536')).to.be(true);
expect(_v4.isNumeric(-2.6)).to.be(true);
expect(_v4.isNumeric(3.1415)).to.be(true);
expect(_v4.isNumeric(8e5)).to.be(true);
expect(_v4.isNumeric('123e-2')).to.be(true);
});
it('dislikes non-numeric stuff', function () {
expect(_.isNumeric('')).to.be(false);
expect(_.isNumeric(' ')).to.be(false);
expect(_.isNumeric('\t\t')).to.be(false);
expect(_.isNumeric('abcdefghijklm1234567890')).to.be(false);
expect(_.isNumeric('xabcdefx')).to.be(false);
expect(_.isNumeric(true)).to.be(false);
expect(_.isNumeric(false)).to.be(false);
expect(_.isNumeric('bcfed5.2')).to.be(false);
expect(_.isNumeric('7.2acdgs')).to.be(false);
expect(_.isNumeric(undefined)).to.be(false);
expect(_.isNumeric(null)).to.be(false);
expect(_.isNumeric(NaN)).to.be(false);
expect(_.isNumeric(Infinity)).to.be(false);
expect(_.isNumeric(Number.POSITIVE_INFINITY)).to.be(false);
expect(_.isNumeric(Number.NEGATIVE_INFINITY)).to.be(false);
expect(_.isNumeric(new Date(2009, 1, 1))).to.be(false);
expect(_.isNumeric([])).to.be(false);
expect(_.isNumeric([1, 2, 3, 4])).to.be(false);
expect(_.isNumeric({})).to.be(false);
expect(_.isNumeric(function () {})).to.be(false);
expect(_v4.isNumeric('')).to.be(false);
expect(_v4.isNumeric(' ')).to.be(false);
expect(_v4.isNumeric('\t\t')).to.be(false);
expect(_v4.isNumeric('abcdefghijklm1234567890')).to.be(false);
expect(_v4.isNumeric('xabcdefx')).to.be(false);
expect(_v4.isNumeric(true)).to.be(false);
expect(_v4.isNumeric(false)).to.be(false);
expect(_v4.isNumeric('bcfed5.2')).to.be(false);
expect(_v4.isNumeric('7.2acdgs')).to.be(false);
expect(_v4.isNumeric(undefined)).to.be(false);
expect(_v4.isNumeric(null)).to.be(false);
expect(_v4.isNumeric(NaN)).to.be(false);
expect(_v4.isNumeric(Infinity)).to.be(false);
expect(_v4.isNumeric(Number.POSITIVE_INFINITY)).to.be(false);
expect(_v4.isNumeric(Number.NEGATIVE_INFINITY)).to.be(false);
expect(_v4.isNumeric(new Date(2009, 1, 1))).to.be(false);
expect(_v4.isNumeric([])).to.be(false);
expect(_v4.isNumeric([1, 2, 3, 4])).to.be(false);
expect(_v4.isNumeric({})).to.be(false);
expect(_v4.isNumeric(function () {})).to.be(false);
});
});
describe('#isInterval', function () {
_.forEach({
_v4.forEach({
M: 'months',
w: 'weeks',
d: 'days',
@ -104,20 +104,20 @@ describe('Utils', function () {
},
function (name, unit) {
it('likes ' + name, function () {
expect(_.isInterval('1' + unit)).to.be(true);
expect(_v4.isInterval('1' + unit)).to.be(true);
});
it('likes decimal ' + name, function () {
expect(_.isInterval('1.5' + unit)).to.be(true);
expect(_v4.isInterval('1.5' + unit)).to.be(true);
});
});
it('dislikes more than one unit', function () {
expect(_.isInterval('1my')).to.be(false);
expect(_v4.isInterval('1my')).to.be(false);
});
it('dislikes spaces', function () {
expect(_.isInterval('1 m')).to.be(false);
expect(_v4.isInterval('1 m')).to.be(false);
});
});
});
@ -127,108 +127,108 @@ describe('Utils', function () {
describe('#camelCase', function () {
it('find spaces, underscores, and other natural word breaks', function () {
expect(_.camelCase('Neil Patrick.Harris-is_a.dog')).to.eql('neilPatrickHarrisIsADog');
expect(_v4.camelCase('Neil Patrick.Harris-is_a.dog')).to.eql('neilPatrickHarrisIsADog');
});
it('ignores abreviations', function () {
expect(_.camelCase('Json_parser')).to.eql('jsonParser');
expect(_v4.camelCase('Json_parser')).to.eql('jsonParser');
});
it('handles leading _', function () {
expect(_.camelCase('_thing_one_')).to.eql('_thingOne');
expect(_v4.camelCase('_thing_one_')).to.eql('_thingOne');
});
it('works on numbers', function () {
expect(_.camelCase('version 1.0')).to.eql('version10');
expect(_v4.camelCase('version 1.0')).to.eql('version10');
});
});
describe('#studlyCase', function () {
it('find spaces, underscores, and other natural word breaks', function () {
expect(_.studlyCase('Neil Patrick.Harris-is_a.dog')).to.eql('NeilPatrickHarrisIsADog');
expect(_v4.studlyCase('Neil Patrick.Harris-is_a.dog')).to.eql('NeilPatrickHarrisIsADog');
});
it('ignores abreviations', function () {
expect(_.studlyCase('Json_parser')).to.eql('JsonParser');
expect(_v4.studlyCase('Json_parser')).to.eql('JsonParser');
});
it('handles leading _', function () {
expect(_.studlyCase('_thing_one_')).to.eql('_ThingOne');
expect(_v4.studlyCase('_thing_one_')).to.eql('_ThingOne');
});
it('works on numbers', function () {
expect(_.studlyCase('version 1.0')).to.eql('Version10');
expect(_v4.studlyCase('version 1.0')).to.eql('Version10');
});
});
describe('#snakeCase', function () {
it('find spaces, underscores, and other natural word breaks', function () {
expect(_.snakeCase('Neil Patrick.Harris-is_a.dog')).to.eql('neil_patrick_harris_is_a_dog');
expect(_v4.snakeCase('Neil Patrick.Harris-is_a.dog')).to.eql('neil_patrick_harris_is_a_dog');
});
it('ignores abreviations', function () {
expect(_.snakeCase('Json_parser')).to.eql('json_parser');
expect(_v4.snakeCase('Json_parser')).to.eql('json_parser');
});
it('handles leading _', function () {
expect(_.snakeCase('_thing_one_')).to.eql('_thing_one');
expect(_v4.snakeCase('_thing_one_')).to.eql('_thing_one');
});
it('works on numbers', function () {
expect(_.snakeCase('version 1.0')).to.eql('version_1_0');
expect(_v4.snakeCase('version 1.0')).to.eql('version_1_0');
});
});
describe('#toLowerString', function () {
it('transforms normal strings', function () {
expect(_.toLowerString('PASTA')).to.eql('pasta');
expect(_v4.toLowerString('PASTA')).to.eql('pasta');
});
it('ignores long form empty vals (null, false, undef)', function () {
expect(_.toLowerString(null)).to.eql('');
expect(_.toLowerString(false)).to.eql('');
expect(_.toLowerString(void 0)).to.eql('');
expect(_v4.toLowerString(null)).to.eql('');
expect(_v4.toLowerString(false)).to.eql('');
expect(_v4.toLowerString(void 0)).to.eql('');
});
it('uses the objects own toString', function () {
expect(_.toLowerString(['A', 'B'])).to.eql('a,b');
expect(_v4.toLowerString(['A', 'B'])).to.eql('a,b');
});
it('sorta kinda works on objects', function () {
expect(_.toLowerString({ a: 'thing' })).to.eql('[object object]');
expect(_v4.toLowerString({ a: 'thing' })).to.eql('[object object]');
});
});
describe('#toUpperString', function () {
it('transforms normal strings', function () {
expect(_.toUpperString('PASTA')).to.eql('PASTA');
expect(_v4.toUpperString('PASTA')).to.eql('PASTA');
});
it('ignores long form empty vals (null, false, undef)', function () {
expect(_.toUpperString(null)).to.eql('');
expect(_.toUpperString(false)).to.eql('');
expect(_.toUpperString(void 0)).to.eql('');
expect(_v4.toUpperString(null)).to.eql('');
expect(_v4.toUpperString(false)).to.eql('');
expect(_v4.toUpperString(void 0)).to.eql('');
});
it('uses the objects own toString', function () {
expect(_.toUpperString(['A', 'B'])).to.eql('A,B');
expect(_v4.toUpperString(['A', 'B'])).to.eql('A,B');
});
it('sorta kinda works on objects', function () {
expect(_.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
expect(_v4.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
});
});
describe('#repeat', function () {
it('repeats strings', function () {
expect(_.repeat(' ', 5)).to.eql(' ');
expect(_.repeat('foobar', 2)).to.eql('foobarfoobar');
expect(_v4.repeat(' ', 5)).to.eql(' ');
expect(_v4.repeat('foobar', 2)).to.eql('foobarfoobar');
});
});
describe('#ucfirst', function () {
it('only capitalized the first letter, lowercases everything else', function () {
expect(_.ucfirst('ALGER')).to.eql('Alger');
expect(_v4.ucfirst('ALGER')).to.eql('Alger');
});
});
@ -241,14 +241,14 @@ describe('Utils', function () {
var obj = {
foo: 'bar'
};
expect(_.deepMerge(obj, { bar: 'baz' })).to.eql(obj);
expect(_v4.deepMerge(obj, { bar: 'baz' })).to.eql(obj);
});
it('concats arrays', function () {
var obj = {
foo: ['bax', 'boz']
};
_.deepMerge(obj, { foo: ['boop'] });
_v4.deepMerge(obj, { foo: ['boop'] });
expect(obj.foo).to.have.length(3);
});
@ -256,7 +256,7 @@ describe('Utils', function () {
var obj = {
foo: ['stop', 'foo', 'stahp']
};
_.deepMerge(obj, { foo: 'string' });
_v4.deepMerge(obj, { foo: 'string' });
expect(obj.foo).to.have.length(3);
});
@ -267,7 +267,7 @@ describe('Utils', function () {
foo: ['bax', 'boz']
}
};
_.deepMerge(obj, { bax: { foo: ['poo'] } });
_v4.deepMerge(obj, { bax: { foo: ['poo'] } });
expect(obj.bax.foo).to.have.length(3);
});
@ -276,26 +276,26 @@ describe('Utils', function () {
describe('#createArray', function () {
it('accepts an array of things and simply returns a copy of it', function () {
var inp = [{ a: 1 }, 'pizza'];
var out = _.createArray(inp);
var out = _v4.createArray(inp);
expect(out).to.eql(inp);
expect(out).to.not.be(inp);
});
it('accepts a primitive value and calls the the transform function', function (done) {
_.createArray('str', function (val) {
_v4.createArray('str', function (val) {
expect(val).to.be('str');
done();
});
});
it('wraps any non-array in an array', function () {
expect(_.createArray({})).to.eql([{}]);
expect(_.createArray('')).to.eql(['']);
expect(_.createArray(123)).to.eql([123]);
expect(_.createArray(/abc/)).to.eql([/abc/]);
expect(_.createArray(false)).to.eql([false]);
expect(_v4.createArray({})).to.eql([{}]);
expect(_v4.createArray('')).to.eql(['']);
expect(_v4.createArray(123)).to.eql([123]);
expect(_v4.createArray(/abc/)).to.eql([/abc/]);
expect(_v4.createArray(false)).to.eql([false]);
});
it('returns false when the transform function returns undefined', function () {
expect(_.createArray(['str', 1], function (val) {
if (_.isString(val)) {
expect(_v4.createArray(['str', 1], function (val) {
if (_v4.isString(val)) {
return {
val: val
};
@ -306,27 +306,27 @@ describe('Utils', function () {
describe('#funcEnum', function () {
/*
* _.funcEnum(object, key, opts, default);
* _v4.funcEnum(object, key, opts, default);
*/
it('tests if the value at key in object is a function, returns it if so', function () {
var config = {
func: function () {}
};
expect(_.funcEnum(config, 'func', {}, 'toString'))
expect(_v4.funcEnum(config, 'func', {}, 'toString'))
.to.be(config.func);
});
it('tests if the value at key in object is undefined, returns the option at key default if so', function () {
var config = {
func: undefined
};
expect(_.funcEnum(config, 'func', {}, 'toString'))
expect(_v4.funcEnum(config, 'func', {}, 'toString'))
.to.be(Object.prototype.toString);
});
it('tests if the value at key in object is a string, returns the option at that key if so', function () {
var config = {
'config key name': 'toString'
};
expect(_.funcEnum(config, 'config key name', { toString: 'pizza' }, 'toJSON'))
expect(_v4.funcEnum(config, 'config key name', { toString: 'pizza' }, 'toJSON'))
.to.be('pizza');
});
it('throws an informative error if the selection if invalid', function () {
@ -335,15 +335,15 @@ describe('Utils', function () {
};
expect(function () {
_.funcEnum(config, 'config', {});
_v4.funcEnum(config, 'config', {});
}).to.throwError(/expected a function/i);
expect(function () {
_.funcEnum(config, 'config', { main: 'default' }, 'main');
_v4.funcEnum(config, 'config', { main: 'default' }, 'main');
}).to.throwError(/expected a function or main/i);
expect(function () {
_.funcEnum(config, 'config', { main: 'default', other: 'default' }, 'main');
_v4.funcEnum(config, 'config', { main: 'default', other: 'default' }, 'main');
}).to.throwError(/expected a function or one of main, other/i);
});
});
@ -358,8 +358,8 @@ describe('Utils', function () {
var func = function () {};
stub(func, method);
var args = _.map(new Array(i), function (val, i) { return i; });
_.applyArgs(func, null, args);
var args = _v4.map(new Array(i), function (val, i) { return i; });
_v4.applyArgs(func, null, args);
expect(func[method].callCount).to.eql(1);
if (method === 'apply') {
@ -374,9 +374,9 @@ describe('Utils', function () {
var func = function () {};
stub(func, method);
var args = _.map(new Array(argCount), function (val, i) { return i; });
var args = _v4.map(new Array(argCount), function (val, i) { return i; });
var expected = args.slice(slice);
_.applyArgs(func, null, args, slice);
_v4.applyArgs(func, null, args, slice);
expect(func[method].callCount).to.eql(1);
if (method === 'apply') {
@ -390,24 +390,24 @@ describe('Utils', function () {
describe('#getUnwrittenFromStream', function () {
it('ignores things that do not have writableState', function () {
expect(_.getUnwrittenFromStream()).to.be(undefined);
expect(_.getUnwrittenFromStream(false)).to.be(undefined);
expect(_.getUnwrittenFromStream([])).to.be(undefined);
expect(_.getUnwrittenFromStream({})).to.be(undefined);
expect(_v4.getUnwrittenFromStream()).to.be(undefined);
expect(_v4.getUnwrittenFromStream(false)).to.be(undefined);
expect(_v4.getUnwrittenFromStream([])).to.be(undefined);
expect(_v4.getUnwrittenFromStream({})).to.be(undefined);
});
if (require('stream').Writable) {
var MockWritableStream = require('../../mocks/writable_stream');
it('ignores empty stream', function () {
var stream = new MockWritableStream();
expect(_.getUnwrittenFromStream(stream)).to.be('');
expect(_v4.getUnwrittenFromStream(stream)).to.be('');
});
it('returns only what is in the buffer', function () {
var stream = new MockWritableStream();
stream.write('hot');
stream.write('dog');
expect(_.getUnwrittenFromStream(stream)).to.be('dog');
expect(_v4.getUnwrittenFromStream(stream)).to.be('dog');
});
}
});

View File

@ -1,7 +1,7 @@
var _ = require('lodash-migrate');
// var _ = require('lodash');
var expect = require('expect.js');
module.exports = function expectSubObject(obj, subObj) {
_.forOwn(subObj, function (val, prop) {
_v4.forOwn(subObj, function (val, prop) {
if (typeof obj[prop] === 'object') {
// non-strict equals
expect(obj[prop]).to.eql(val, 'Expected property' + prop + ' of object to equal ' + val);

View File

@ -7,7 +7,7 @@
module.exports = JenkinsReporter;
var Base = require('mocha/lib/reporters/base');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var chalk = require('chalk');
var makeJUnitXml = require('./make_j_unit_xml');
var fs = require('fs');
@ -15,7 +15,7 @@ var path = require('path');
var inspect = require('util').inspect;
var log = (function () {
var locked = _.bind(process.stdout.write, process.stdout);
var locked = _v4.bind(process.stdout.write, process.stdout);
return function (str) {
if (typeof str !== 'string') {
str = inspect(str);
@ -126,7 +126,7 @@ function JenkinsReporter(runner) {
errMsg += '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
}
console.error(_.map(errMsg.split('\n'), function (line) {
console.error(_v4.map(errMsg.split('\n'), function (line) {
return indt() + ' ' + line;
}).join('\n'));
}
@ -146,7 +146,7 @@ function JenkinsReporter(runner) {
runner.on('hook end', function (hook) {
if (hook.title.indexOf('"after each"') > -1 && stack[0] && stack[0].results.length) {
var result = _.last(stack[0].results);
var result = _v4.last(stack[0].results);
result.stdout += stack[0].stdout;
result.stderr += stack[0].stderr;
stack[0].stdout = stack[0].stderr = '';
@ -157,7 +157,7 @@ function JenkinsReporter(runner) {
restoreStdio();
var xml = makeJUnitXml('node ' + process.version, {
stats: stats,
suites: _.map(rootSuite.suites, function removeElements(suite) {
suites: _v4.map(rootSuite.suites, function removeElements(suite) {
var s = {
name: suite.name,
start: suite.start,
@ -168,7 +168,7 @@ function JenkinsReporter(runner) {
};
if (suite.suites) {
s.suites = _.map(suite.suites, removeElements);
s.suites = _v4.map(suite.suites, removeElements);
}
return s;
})

View File

@ -28,7 +28,7 @@ var testXml = require('xmlbuilder');
var suites = testXml.create('testsuites');
var suiteCount = 0;
var moment = require('moment');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var chalk = require('chalk');
function makeJUnitXml(runnerName, testDetails) {
@ -41,7 +41,7 @@ function makeJUnitXml(runnerName, testDetails) {
timestamp: moment(suiteInfo.start).toJSON(),
hostname: 'localhost',
tests: (suiteInfo.results && suiteInfo.results.length) || 0,
failures: _.where(suiteInfo.results, { pass: false }).length,
failures: _v4.filter(suiteInfo.results, { pass: false }).length,
errors: 0,
time: suiteInfo.time / 1000
});

View File

@ -2,7 +2,7 @@
var express = require('express');
var http = require('http');
var fs = require('fs');
var _ = require('lodash-migrate');
// var _ = require('lodash');
var async = require('async');
var root = require('path').join(__dirname, '../..');
var browserify = require('browserify');
@ -12,7 +12,7 @@ var browserBuildsDir = root + '/test/unit/browser_builds';
var testFiles = {};
testFiles.unit = _(fs.readdirSync(unitSpecDir))
testFiles.unit = _v4(fs.readdirSync(unitSpecDir))
.difference([
'file_logger.js',
'http_connector.js',