elasticsearch
Advanced tools
Comparing version 14.2.2 to 15.0.0
@@ -10,3 +10,3 @@ { | ||
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", | ||
"version": "14.2.2", | ||
"version": "15.0.0", | ||
"keywords": [ | ||
@@ -17,2 +17,8 @@ "elasticsearch", | ||
], | ||
"scripts": { | ||
"test": "grunt test", | ||
"generate": "node scripts/generate", | ||
"grunt": "grunt", | ||
"lint": "eslint ." | ||
}, | ||
"browser": { | ||
@@ -110,6 +116,3 @@ "./src/lib/connectors/index.js": "./src/lib/connectors/browser_index.js", | ||
"chalk": "^1.0.0", | ||
"lodash": "2.4.2", | ||
"lodash.get": "^4.4.2", | ||
"lodash.isempty": "^4.4.0", | ||
"lodash.trimend": "^4.5.1" | ||
"lodash": "^4.17.10" | ||
}, | ||
@@ -123,8 +126,2 @@ "resolutions": { | ||
}, | ||
"scripts": { | ||
"test": "grunt test", | ||
"generate": "node scripts/generate", | ||
"grunt": "grunt", | ||
"eslint": "eslint src scripts test grunt Gruntfile.js" | ||
}, | ||
"engines": { | ||
@@ -131,0 +128,0 @@ "node": ">=0.8" |
@@ -1,2 +0,2 @@ | ||
# elasticsearch.js 14.2.2 | ||
# elasticsearch.js 15.0.0 | ||
@@ -3,0 +3,0 @@ The official low-level Elasticsearch client for Node.js and the browser. |
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
@@ -64,3 +65,3 @@ /** | ||
if (typeof cb === 'function') { | ||
_.nextTick(cb, e); | ||
utils.nextTick(cb, e); | ||
} else { | ||
@@ -124,3 +125,3 @@ var def = this.transport.defer(); | ||
duration: function (param, val, name) { | ||
if (_.isNumeric(val) || _.isInterval(val)) { | ||
if (utils.isNumeric(val) || utils.isInterval(val)) { | ||
return val; | ||
@@ -156,3 +157,3 @@ } else { | ||
number: function (param, val, name) { | ||
if (_.isNumeric(val)) { | ||
if (utils.isNumeric(val)) { | ||
return val * 1; | ||
@@ -176,3 +177,3 @@ } else { | ||
} | ||
else if (_.isNumeric(val)) { | ||
else if (utils.isNumeric(val)) { | ||
return '' + val; | ||
@@ -332,3 +333,3 @@ } | ||
case 'method': | ||
request.method = _.toUpperString(params[key]); | ||
request.method = utils.toUpperString(params[key]); | ||
break; | ||
@@ -335,0 +336,0 @@ default: |
@@ -31,3 +31,4 @@ /** | ||
var clientAction = require('./client_action'); | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
@@ -70,3 +71,3 @@ function Client(config) { | ||
EsApiClient.prototype = _.funcEnum(config, 'apiVersion', Client.apis, '_default'); | ||
EsApiClient.prototype = utils.funcEnum(config, 'apiVersion', Client.apis, '_default'); | ||
if (!config.sniffEndpoint && EsApiClient.prototype === Client.apis['0.90']) { | ||
@@ -97,4 +98,3 @@ config.sniffEndpoint = '/_cluster/nodes'; | ||
NodesToHost: require('./nodes_to_host'), | ||
Transport: require('./transport'), | ||
utils: require('./utils') | ||
Transport: require('./transport') | ||
}) || Constructor; | ||
@@ -101,0 +101,0 @@ }); |
@@ -12,3 +12,4 @@ /** | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
var Log = require('./log'); | ||
@@ -18,3 +19,3 @@ | ||
config = config || {}; | ||
_.makeBoundMethods(this); | ||
utils.makeBoundMethods(this); | ||
@@ -32,6 +33,6 @@ if (!config.log) { | ||
// get the selector config var | ||
this.selector = _.funcEnum(config, 'selector', ConnectionPool.selectors, ConnectionPool.defaultSelector); | ||
this.selector = utils.funcEnum(config, 'selector', ConnectionPool.selectors, ConnectionPool.defaultSelector); | ||
// get the connection class | ||
this.Connection = _.funcEnum(config, 'connectionClass', ConnectionPool.connectionClasses, | ||
this.Connection = utils.funcEnum(config, 'connectionClass', ConnectionPool.connectionClasses, | ||
ConnectionPool.defaultConnectionClass); | ||
@@ -42,3 +43,3 @@ | ||
this.maxDeadTimeout = config.hasOwnProperty('maxDeadTimeout') ? config.maxDeadTimeout : 18e5; | ||
this.calcDeadTimeout = _.funcEnum(config, 'calcDeadTimeout', ConnectionPool.calcDeadTimeoutOptions, 'exponential'); | ||
this.calcDeadTimeout = utils.funcEnum(config, 'calcDeadTimeout', ConnectionPool.calcDeadTimeoutOptions, 'exponential'); | ||
@@ -93,3 +94,3 @@ // a map of connections to their "id" property, used when sniffing | ||
try { | ||
_.nextTick(cb, void 0, this.selector(this._conns.alive)); | ||
utils.nextTick(cb, void 0, this.selector(this._conns.alive)); | ||
} catch (e) { | ||
@@ -102,3 +103,3 @@ cb(e); | ||
} else { | ||
_.nextTick(cb, void 0); | ||
utils.nextTick(cb, void 0); | ||
} | ||
@@ -115,3 +116,3 @@ }; | ||
*/ | ||
ConnectionPool.prototype.onStatusSet = _.handler(function (status, oldStatus, connection) { | ||
ConnectionPool.prototype.onStatusSet = utils.handler(function (status, oldStatus, connection) { | ||
var index; | ||
@@ -210,3 +211,3 @@ | ||
timeout.id = setTimeout(timeout.revive, ms); | ||
timeout.runAt = _.now() + ms; | ||
timeout.runAt = utils.now() + ms; | ||
}; | ||
@@ -213,0 +214,0 @@ |
module.exports = ConnectionAbstract; | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
var EventEmitter = require('events').EventEmitter; | ||
@@ -29,5 +30,5 @@ var Log = require('./log'); | ||
_.makeBoundMethods(this); | ||
utils.makeBoundMethods(this); | ||
} | ||
_.inherits(ConnectionAbstract, EventEmitter); | ||
utils.inherits(ConnectionAbstract, EventEmitter); | ||
@@ -34,0 +35,0 @@ /** |
@@ -9,3 +9,3 @@ /** | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
var ConnectionAbstract = require('../connection'); | ||
@@ -24,3 +24,3 @@ var ConnectionFault = require('../errors').ConnectionFault; | ||
} | ||
_.inherits(AngularConnector, ConnectionAbstract); | ||
utils.inherits(AngularConnector, ConnectionAbstract); | ||
@@ -27,0 +27,0 @@ AngularConnector.prototype.request = function (params, cb) { |
@@ -6,3 +6,3 @@ var opts = { | ||
}; | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
@@ -9,0 +9,0 @@ // remove modules that have been ignored by browserify |
@@ -15,3 +15,4 @@ /** | ||
}; | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
var utils = require('../utils'); | ||
var parseUrl = require('url').parse; | ||
@@ -51,5 +52,5 @@ var qs = require('querystring'); | ||
} | ||
_.inherits(HttpConnector, ConnectionAbstract); | ||
utils.inherits(HttpConnector, ConnectionAbstract); | ||
HttpConnector.prototype.onStatusSet = _.handler(function (status) { | ||
HttpConnector.prototype.onStatusSet = utils.handler(function (status) { | ||
if (status === 'closed') { | ||
@@ -150,5 +151,10 @@ var agent = this.agent; | ||
request && request.removeAllListeners(); | ||
incoming && incoming.removeAllListeners(); | ||
if (request) { | ||
request.removeAllListeners(); | ||
} | ||
if (incoming) { | ||
incoming.removeAllListeners(); | ||
} | ||
if ((err instanceof Error) === false) { | ||
@@ -155,0 +161,0 @@ err = void 0; |
@@ -10,3 +10,3 @@ /* global jQuery: false */ | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
var ConnectionAbstract = require('../connection'); | ||
@@ -18,3 +18,3 @@ var ConnectionFault = require('../errors').ConnectionFault; | ||
} | ||
_.inherits(JqueryConnector, ConnectionAbstract); | ||
utils.inherits(JqueryConnector, ConnectionAbstract); | ||
@@ -21,0 +21,0 @@ JqueryConnector.prototype.request = function (params, cb) { |
@@ -10,3 +10,3 @@ /** | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
var ConnectionAbstract = require('../connection'); | ||
@@ -19,3 +19,3 @@ var ConnectionFault = require('../errors').ConnectionFault; | ||
} | ||
_.inherits(XhrConnector, ConnectionAbstract); | ||
utils.inherits(XhrConnector, ConnectionAbstract); | ||
@@ -48,3 +48,3 @@ /** | ||
.compact() | ||
.first(); | ||
.head(); | ||
} | ||
@@ -51,0 +51,0 @@ |
@@ -1,2 +0,3 @@ | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
var errors = module.exports; | ||
@@ -37,3 +38,3 @@ | ||
errors._Abstract = ErrorAbstract; | ||
_.inherits(ErrorAbstract, Error); | ||
utils.inherits(ErrorAbstract, Error); | ||
@@ -47,3 +48,3 @@ /** | ||
}; | ||
_.inherits(errors.ConnectionFault, ErrorAbstract); | ||
utils.inherits(errors.ConnectionFault, ErrorAbstract); | ||
@@ -57,3 +58,3 @@ /** | ||
}; | ||
_.inherits(errors.NoConnections, ErrorAbstract); | ||
utils.inherits(errors.NoConnections, ErrorAbstract); | ||
@@ -67,3 +68,3 @@ /** | ||
}; | ||
_.inherits(errors.Generic, ErrorAbstract); | ||
utils.inherits(errors.Generic, ErrorAbstract); | ||
@@ -77,3 +78,3 @@ /** | ||
}; | ||
_.inherits(errors.RequestTimeout, ErrorAbstract); | ||
utils.inherits(errors.RequestTimeout, ErrorAbstract); | ||
@@ -88,3 +89,3 @@ | ||
}; | ||
_.inherits(errors.Serialization, ErrorAbstract); | ||
utils.inherits(errors.Serialization, ErrorAbstract); | ||
@@ -98,3 +99,3 @@ | ||
}; | ||
_.inherits(errors.RequestTypeError, ErrorAbstract); | ||
utils.inherits(errors.RequestTypeError, ErrorAbstract); | ||
@@ -151,3 +152,3 @@ var statusCodes = [ | ||
var primaryName = allNames[0]; | ||
var className = _.studlyCase(primaryName); | ||
var className = utils.studlyCase(primaryName); | ||
allNames = _.uniq(allNames.concat(className)); | ||
@@ -194,3 +195,3 @@ | ||
} | ||
_.inherits(StatusCodeError, ErrorAbstract); | ||
utils.inherits(StatusCodeError, ErrorAbstract); | ||
@@ -197,0 +198,0 @@ allNames.forEach(function (name) { |
@@ -9,3 +9,4 @@ /** | ||
var qs = require('querystring'); | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
@@ -127,3 +128,3 @@ var startsWithProtocolRE = /^([a-z]+:)?\/\//; | ||
// make sure that the port is a number | ||
if (_.isNumeric(this.port)) { | ||
if (utils.isNumeric(this.port)) { | ||
this.port = parseInt(this.port, 10); | ||
@@ -130,0 +131,0 @@ } else { |
@@ -1,2 +0,3 @@ | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
var url = require('url'); | ||
@@ -27,3 +28,3 @@ var EventEmitter = require('events').EventEmitter; | ||
if (_.isArrayOfStrings(config.log)) { | ||
if (utils.isArrayOfStrings(config.log)) { | ||
outputs = [{ | ||
@@ -33,3 +34,3 @@ levels: config.log | ||
} else { | ||
outputs = _.createArray(config.log, function (val) { | ||
outputs = utils.createArray(config.log, function (val) { | ||
if (_.isPlainObject(val)) { | ||
@@ -55,3 +56,3 @@ return val; | ||
} | ||
_.inherits(Log, EventEmitter); | ||
utils.inherits(Log, EventEmitter); | ||
@@ -215,3 +216,3 @@ Log.loggers = require('./loggers'); | ||
var Logger = _.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio'); | ||
var Logger = utils.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio'); | ||
return new Logger(this, config); | ||
@@ -218,0 +219,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
@@ -12,3 +13,3 @@ /** | ||
_.makeBoundMethods(this); | ||
utils.makeBoundMethods(this); | ||
@@ -41,3 +42,3 @@ // when the log closes, remove our event listeners | ||
function indent(text, spaces) { | ||
var space = _.repeat(' ', spaces || 2); | ||
var space = utils.repeat(' ', spaces || 2); | ||
return (text || '').split(/\r?\n/).map(function (line) { | ||
@@ -70,3 +71,3 @@ return space + line; | ||
_.each(levels, _.bind(function (level) { | ||
var fnName = 'on' + _.ucfirst(level); | ||
var fnName = 'on' + utils.ucfirst(level); | ||
if (this.bound[fnName]) { | ||
@@ -88,5 +89,5 @@ this.listeningLevels.push(level); | ||
*/ | ||
LoggerAbstract.prototype.cleanUpListeners = _.handler(function () { | ||
LoggerAbstract.prototype.cleanUpListeners = utils.handler(function () { | ||
_.each(this.listeningLevels, _.bind(function (level) { | ||
this.log.removeListener(level, this.bound['on' + _.ucfirst(level)]); | ||
this.log.removeListener(level, this.bound['on' + utils.ucfirst(level)]); | ||
}, this)); | ||
@@ -103,3 +104,3 @@ }); | ||
*/ | ||
LoggerAbstract.prototype.onError = _.handler(function (e) { | ||
LoggerAbstract.prototype.onError = utils.handler(function (e) { | ||
this.write((e.name === 'Error' ? 'ERROR' : e.name), e.stack); | ||
@@ -116,3 +117,3 @@ }); | ||
*/ | ||
LoggerAbstract.prototype.onWarning = _.handler(function (msg) { | ||
LoggerAbstract.prototype.onWarning = utils.handler(function (msg) { | ||
this.write('WARNING', msg); | ||
@@ -129,3 +130,3 @@ }); | ||
*/ | ||
LoggerAbstract.prototype.onInfo = _.handler(function (msg) { | ||
LoggerAbstract.prototype.onInfo = utils.handler(function (msg) { | ||
this.write('INFO', msg); | ||
@@ -142,3 +143,3 @@ }); | ||
*/ | ||
LoggerAbstract.prototype.onDebug = _.handler(function (msg) { | ||
LoggerAbstract.prototype.onDebug = utils.handler(function (msg) { | ||
this.write('DEBUG', msg); | ||
@@ -155,3 +156,3 @@ }); | ||
*/ | ||
LoggerAbstract.prototype.onTrace = _.handler(function (requestDetails) { | ||
LoggerAbstract.prototype.onTrace = utils.handler(function (requestDetails) { | ||
this.write('TRACE', this._formatTraceMessage(requestDetails)); | ||
@@ -158,0 +159,0 @@ }); |
@@ -16,3 +16,4 @@ /** | ||
var LoggerAbstract = require('../logger'); | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
var utils = require('../utils'); | ||
@@ -25,3 +26,3 @@ function Console(log, config) { | ||
} | ||
_.inherits(Console, LoggerAbstract); | ||
utils.inherits(Console, LoggerAbstract); | ||
@@ -52,3 +53,3 @@ /** | ||
*/ | ||
Console.prototype.onError = _.handler(function (e) { | ||
Console.prototype.onError = utils.handler(function (e) { | ||
var to = console.error ? 'error' : 'log'; | ||
@@ -66,3 +67,3 @@ this.write(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message, to); | ||
*/ | ||
Console.prototype.onWarning = _.handler(function (msg) { | ||
Console.prototype.onWarning = utils.handler(function (msg) { | ||
this.write('WARNING', msg, console.warn ? 'warn' : 'log'); | ||
@@ -79,3 +80,3 @@ }); | ||
*/ | ||
Console.prototype.onInfo = _.handler(function (msg) { | ||
Console.prototype.onInfo = utils.handler(function (msg) { | ||
this.write('INFO', msg, console.info ? 'info' : 'log'); | ||
@@ -92,3 +93,3 @@ }); | ||
*/ | ||
Console.prototype.onDebug = _.handler(function (msg) { | ||
Console.prototype.onDebug = utils.handler(function (msg) { | ||
this.write('DEBUG', msg, console.debug ? 'debug' : 'log'); | ||
@@ -103,4 +104,4 @@ }); | ||
*/ | ||
Console.prototype.onTrace = _.handler(function (msg) { | ||
Console.prototype.onTrace = utils.handler(function (msg) { | ||
this.write('TRACE', this._formatTraceMessage(msg), 'log'); | ||
}); |
@@ -15,3 +15,3 @@ /** | ||
var StreamLogger = require('./stream'); | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
var fs = require('fs'); | ||
@@ -33,6 +33,6 @@ | ||
} | ||
_.inherits(File, StreamLogger); | ||
utils.inherits(File, StreamLogger); | ||
File.prototype.onProcessExit = _.handler(function () { | ||
var toWrite = _.getUnwrittenFromStream(this.stream); | ||
File.prototype.onProcessExit = utils.handler(function () { | ||
var toWrite = utils.getUnwrittenFromStream(this.stream); | ||
if (toWrite) { | ||
@@ -39,0 +39,0 @@ fs.appendFileSync(this.path, toWrite); |
@@ -20,3 +20,4 @@ /** | ||
var LoggerAbstract = require('../logger'); | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
var utils = require('../utils'); | ||
@@ -40,3 +41,3 @@ var defaultColors = { | ||
_.inherits(Stdio, LoggerAbstract); | ||
utils.inherits(Stdio, LoggerAbstract); | ||
@@ -70,3 +71,3 @@ /** | ||
*/ | ||
Stdio.prototype.onError = _.handler(function (e) { | ||
Stdio.prototype.onError = utils.handler(function (e) { | ||
this.write(e.name === 'Error' ? 'ERROR' : e.name, e.stack, process.stderr, this.colors.error); | ||
@@ -83,3 +84,3 @@ }); | ||
*/ | ||
Stdio.prototype.onWarning = _.handler(function (msg) { | ||
Stdio.prototype.onWarning = utils.handler(function (msg) { | ||
this.write('WARNING', msg, process.stderr, this.colors.warning); | ||
@@ -96,3 +97,3 @@ }); | ||
*/ | ||
Stdio.prototype.onInfo = _.handler(function (msg) { | ||
Stdio.prototype.onInfo = utils.handler(function (msg) { | ||
this.write('INFO', msg, process.stdout, this.colors.info); | ||
@@ -109,3 +110,3 @@ }); | ||
*/ | ||
Stdio.prototype.onDebug = _.handler(function (msg) { | ||
Stdio.prototype.onDebug = utils.handler(function (msg) { | ||
this.write('DEBUG', msg, process.stdout, this.colors.debug); | ||
@@ -121,4 +122,4 @@ }); | ||
*/ | ||
Stdio.prototype.onTrace = _.handler(function (message) { | ||
Stdio.prototype.onTrace = utils.handler(function (message) { | ||
this.write('TRACE', this._formatTraceMessage(message), process.stdout, this.colors.trace); | ||
}); |
@@ -16,3 +16,3 @@ /** | ||
var LoggerAbstract = require('../logger'); | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
@@ -30,5 +30,5 @@ function Stream(log, config) { | ||
} | ||
_.inherits(Stream, LoggerAbstract); | ||
utils.inherits(Stream, LoggerAbstract); | ||
Stream.prototype.cleanUpListeners = _.handler(function () { | ||
Stream.prototype.cleanUpListeners = utils.handler(function () { | ||
process.removeListener('exit', this.bound.onProcessExit); | ||
@@ -39,5 +39,5 @@ LoggerAbstract.prototype.cleanUpListeners.call(this); | ||
// flush the write buffer to stderr synchronously | ||
Stream.prototype.onProcessExit = _.handler(function () { | ||
Stream.prototype.onProcessExit = utils.handler(function () { | ||
// process is dying, lets manually flush the buffer synchronously to stderr. | ||
var unwritten = _.getUnwrittenFromStream(this.stream); | ||
var unwritten = utils.getUnwrittenFromStream(this.stream); | ||
if (unwritten) { | ||
@@ -44,0 +44,0 @@ console.error('Log stream did not get to finish writing. Flushing to stderr'); |
@@ -17,3 +17,4 @@ /** | ||
var fs = require('fs'); | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
var utils = require('../utils'); | ||
var url = require('url'); | ||
@@ -33,3 +34,3 @@ | ||
} | ||
_.inherits(Tracer, StreamLogger); | ||
utils.inherits(Tracer, StreamLogger); | ||
@@ -41,3 +42,3 @@ var usefulUrlFields = ['protocol', 'slashes', 'port', 'hostname', 'pathname', 'query']; | ||
var originalHost = url.format(_.pick(reqUrl, 'protocol', 'hostname', 'port')); | ||
var originalHost = url.format(_.pick(reqUrl, ['protocol', 'hostname', 'port'])); | ||
@@ -44,0 +45,0 @@ reqUrl.port = this.curlPort; |
@@ -1,2 +0,2 @@ | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
@@ -3,0 +3,0 @@ var extractHostPartsRE1x = /\[(?:(.*)\/)?(.+?):(\d+)\]/; |
/* global angular */ | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
var JsonSerializer = require('../serializers/json'); | ||
function AngularSerializer() {} | ||
_.inherits(AngularSerializer, JsonSerializer); | ||
utils.inherits(AngularSerializer, JsonSerializer); | ||
@@ -8,0 +8,0 @@ // mimic the JsonSerializer's encode method, but use angular's toJson instead |
@@ -7,3 +7,3 @@ /** | ||
var _ = require('../utils'); | ||
var _ = require('lodash'); | ||
@@ -10,0 +10,0 @@ function Json() {} |
@@ -7,3 +7,4 @@ /** | ||
var _ = require('./utils'); | ||
var _ = require('lodash'); | ||
var utils = require('./utils'); | ||
var errors = require('./errors'); | ||
@@ -22,11 +23,11 @@ var Host = require('./host'); | ||
// setup the connection pool | ||
var ConnectionPool = _.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main'); | ||
var ConnectionPool = utils.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main'); | ||
self.connectionPool = new ConnectionPool(config); | ||
// setup the serializer | ||
var Serializer = _.funcEnum(config, 'serializer', Transport.serializers, 'json'); | ||
var Serializer = utils.funcEnum(config, 'serializer', Transport.serializers, 'json'); | ||
self.serializer = new Serializer(config); | ||
// setup the nodesToHostCallback | ||
self.nodesToHostCallback = _.funcEnum(config, 'nodesToHostCallback', Transport.nodesToHostCallbacks, 'main'); | ||
self.nodesToHostCallback = utils.funcEnum(config, 'nodesToHostCallback', Transport.nodesToHostCallbacks, 'main'); | ||
@@ -54,3 +55,3 @@ // setup max retries | ||
if (config.hosts) { | ||
var hostsConfig = _.createArray(config.hosts, function (val) { | ||
var hostsConfig = utils.createArray(config.hosts, function (val) { | ||
if (_.isPlainObject(val) || _.isString(val) || val instanceof Host) { | ||
@@ -185,3 +186,3 @@ return val; | ||
if (body && params.method === 'GET') { | ||
_.nextTick(respond, new TypeError('Body can not be sent with method "GET"')); | ||
utils.nextTick(respond, new TypeError('Body can not be sent with method "GET"')); | ||
return ret; | ||
@@ -299,3 +300,3 @@ } | ||
&& (status < 200 || status >= 300) | ||
&& (!params.ignore || !_.include(params.ignore, status)) | ||
&& (!params.ignore || !_.includes(params.ignore, status)) | ||
) { | ||
@@ -302,0 +303,0 @@ |
@@ -1,5 +0,5 @@ | ||
var isEmpty = require('lodash.isempty'); | ||
var _ = require('lodash'); | ||
module.exports = function (hosts) { | ||
if (isEmpty(hosts)) return false; | ||
if (_.isEmpty(hosts)) return false; | ||
@@ -14,2 +14,2 @@ var commonProtocol = hosts.shift().protocol; | ||
return commonProtocol; | ||
} | ||
}; |
@@ -1,2 +0,2 @@ | ||
var _ = require('../utils'); | ||
var utils = require('../utils'); | ||
@@ -28,3 +28,3 @@ | ||
var countdownTo = function (ms) { | ||
var start = _.now(); | ||
var start = utils.now(); | ||
return function () { | ||
@@ -31,0 +31,0 @@ return start - ms; |
@@ -1,9 +0,6 @@ | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
var nodeUtils = require('util'); | ||
var lodash = require('lodash'); | ||
/** | ||
* 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 | ||
* confusion when requiring lodash itself. | ||
* Custom utils library | ||
* | ||
@@ -13,44 +10,7 @@ * @class utils | ||
*/ | ||
var _ = lodash.assign({}, lodash, nodeUtils); | ||
var utils = {}; | ||
/** | ||
* Link to [path.join](http://nodejs.org/api/path.html#path_path_join_path1_path2) | ||
* | ||
* @method _.joinPath | ||
* @type {function} | ||
*/ | ||
_.joinPath = path.join; | ||
utils.inherits = nodeUtils.inherits; | ||
_.get = require('lodash.get'); | ||
_.trimEnd = require('lodash.trimend'); | ||
/** | ||
* Recursively merge two objects, walking into each object and concating arrays. If both to and from have a value at a | ||
* key, but the values' types don't match to's value is left unmodified. Only Array and Object values are merged - that | ||
* it to say values with a typeof "object" | ||
* | ||
* @param {Object} to - Object to merge into (no cloning, the original object | ||
* is modified) | ||
* @param {Object} from - Object to pull changed from | ||
* @return {Object} - returns the modified to value | ||
*/ | ||
_.deepMerge = function (to, from) { | ||
_.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])) { | ||
to[key] = to[key].concat(from[key]); | ||
} | ||
else if (_.isPlainObject(to[key]) && _.isPlainObject(from[key])) { | ||
_.deepMerge(to[key], from[key]); | ||
} | ||
} | ||
}); | ||
return to; | ||
}; | ||
/** | ||
* Test if a value is an array and its contents are string type | ||
@@ -62,3 +22,3 @@ * | ||
*/ | ||
_.isArrayOfStrings = function (arr) { | ||
utils.isArrayOfStrings = function (arr) { | ||
// quick shallow check of arrays | ||
@@ -76,3 +36,3 @@ return _.isArray(arr) && _.every(arr.slice(0, 10), _.isString); | ||
*/ | ||
_.ucfirst = function (word) { | ||
utils.ucfirst = function (word) { | ||
return word[0].toUpperCase() + word.substring(1).toLowerCase(); | ||
@@ -138,3 +98,3 @@ }; | ||
*/ | ||
_.studlyCase = adjustWordCase(true, true, ''); | ||
utils.studlyCase = adjustWordCase(true, true, ''); | ||
@@ -148,3 +108,3 @@ /** | ||
*/ | ||
_.camelCase = adjustWordCase(false, true, ''); | ||
utils.camelCase = adjustWordCase(false, true, ''); | ||
@@ -158,22 +118,5 @@ /** | ||
*/ | ||
_.snakeCase = adjustWordCase(false, false, '_'); | ||
utils.snakeCase = adjustWordCase(false, false, '_'); | ||
/** | ||
* Lower-case a string, and return an empty string if any is not a string | ||
* | ||
* @param any {*} - Something or nothing | ||
* @returns {string} | ||
*/ | ||
_.toLowerString = function (any) { | ||
if (any) { | ||
if (typeof any !== 'string') { | ||
any = any.toString(); | ||
} | ||
} else { | ||
any = ''; | ||
} | ||
return any.toLowerCase(); | ||
}; | ||
/** | ||
* Upper-case the string, return an empty string if any is not a string | ||
@@ -184,3 +127,3 @@ * | ||
*/ | ||
_.toUpperString = function (any) { | ||
utils.toUpperString = function (any) { | ||
if (any) { | ||
@@ -203,3 +146,3 @@ if (typeof any !== 'string') { | ||
*/ | ||
_.isNumeric = function (val) { | ||
utils.isNumeric = function (val) { | ||
return typeof val !== 'object' && val - parseFloat(val) >= 0; | ||
@@ -218,3 +161,3 @@ }; | ||
*/ | ||
_.isInterval = function (val) { | ||
utils.isInterval = function (val) { | ||
return !!(val.match && val.match(intervalRE)); | ||
@@ -232,3 +175,3 @@ }; | ||
*/ | ||
_.repeat = function (what, times) { | ||
utils.repeat = function (what, times) { | ||
return (new Array(times + 1)).join(what); | ||
@@ -246,3 +189,3 @@ }; | ||
*/ | ||
_.applyArgs = function (func, context, args, sliceIndex) { | ||
utils.applyArgs = function (func, context, args, sliceIndex) { | ||
sliceIndex = sliceIndex || 0; | ||
@@ -273,5 +216,5 @@ switch (args.length - sliceIndex) { | ||
*/ | ||
_.nextTick = function (cb) { | ||
utils.nextTick = function (cb) { | ||
// bind the function and schedule it | ||
process.nextTick(_.bindKey(_, 'applyArgs', cb, null, arguments, 1)); | ||
process.nextTick(_.bindKey(utils, 'applyArgs', cb, null, arguments, 1)); | ||
}; | ||
@@ -284,3 +227,3 @@ | ||
* ``` | ||
* ClassName.prototype.methodName = _.handler(function () { | ||
* ClassName.prototype.methodName = utils.handler(function () { | ||
* // this will always be bound when called via classInstance.bound.methodName | ||
@@ -291,11 +234,9 @@ * this === classInstance | ||
* | ||
* @alias _.scheduled | ||
* @param {Function} func - The method that is being defined | ||
* @return {Function} | ||
*/ | ||
_.handler = function (func) { | ||
utils.handler = function (func) { | ||
func._provideBound = true; | ||
return func; | ||
}; | ||
_.scheduled = _.handler; | ||
@@ -311,3 +252,3 @@ /** | ||
* | ||
* _.makeBoundMethods(obj); | ||
* utils.makeBoundMethods(obj); | ||
* | ||
@@ -319,3 +260,3 @@ * obj.bound.onEvent() // is bound to obj, and can safely be used as an event handler. | ||
*/ | ||
_.makeBoundMethods = function (obj) { | ||
utils.makeBoundMethods = function (obj) { | ||
obj.bound = {}; | ||
@@ -330,4 +271,2 @@ for (var prop in obj) { | ||
_.noop = function () {}; | ||
/** | ||
@@ -339,3 +278,3 @@ * Implements the standard "string or constructor" check that I was copy/pasting everywhere | ||
*/ | ||
_.funcEnum = function (config, name, opts, def) { | ||
utils.funcEnum = function (config, name, opts, def) { | ||
var val = config[name]; | ||
@@ -378,3 +317,3 @@ switch (typeof val) { | ||
*/ | ||
_.createArray = function (input, transform) { | ||
utils.createArray = function (input, transform) { | ||
transform = typeof transform === 'function' ? transform : _.identity; | ||
@@ -408,4 +347,4 @@ var output = []; | ||
*/ | ||
_.getUnwrittenFromStream = function (stream) { | ||
var writeBuffer = _.getStreamWriteBuffer(stream); | ||
utils.getUnwrittenFromStream = function (stream) { | ||
var writeBuffer = utils.getStreamWriteBuffer(stream); | ||
if (!writeBuffer) return; | ||
@@ -431,3 +370,3 @@ | ||
_.getStreamWriteBuffer = function (stream) { | ||
utils.getStreamWriteBuffer = function (stream) { | ||
if (!stream || !stream._writableState) return; | ||
@@ -444,4 +383,4 @@ | ||
_.clearWriteStreamBuffer = function (stream) { | ||
var buffer = _.getStreamWriteBuffer(stream); | ||
utils.clearWriteStreamBuffer = function (stream) { | ||
var buffer = utils.getStreamWriteBuffer(stream); | ||
return buffer && buffer.splice(0); | ||
@@ -453,6 +392,6 @@ }; | ||
*/ | ||
_.now = function () { | ||
utils.now = function () { | ||
return (typeof Date.now === 'function') ? Date.now() : (new Date()).getTime(); | ||
}; | ||
module.exports = _; | ||
module.exports = utils; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3706360
3
104043
+ Addedlodash@4.17.21(transitive)
- Removedlodash.get@^4.4.2
- Removedlodash.isempty@^4.4.0
- Removedlodash.trimend@^4.5.1
- Removedlodash@2.4.2(transitive)
- Removedlodash.get@4.4.2(transitive)
- Removedlodash.isempty@4.4.0(transitive)
- Removedlodash.trimend@4.5.1(transitive)
Updatedlodash@^4.17.10