Comparing version 2.0.0 to 2.0.1
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
u: require('util'), | ||
@@ -80,3 +80,3 @@ os: require('os'), | ||
} | ||
$npm.utils.extend(err, '$isErrorList', true); | ||
npm.utils.extend(err, '$isErrorList', true); | ||
return err; | ||
@@ -100,3 +100,3 @@ }; | ||
if (typeof first !== 'string') { | ||
first = $npm.u.inspect(first); | ||
first = npm.u.inspect(first); | ||
} | ||
@@ -117,3 +117,3 @@ this.message = first; | ||
$npm.u.inherits(BatchError, Error); | ||
npm.u.inherits(BatchError, Error); | ||
BatchError.prototype.name = 'BatchError'; | ||
@@ -140,5 +140,5 @@ | ||
level = level > 0 ? parseInt(level) : 0; | ||
var gap0 = $npm.utils.messageGap(level), | ||
gap1 = $npm.utils.messageGap(level + 1), | ||
gap2 = $npm.utils.messageGap(level + 2), | ||
var gap0 = npm.utils.messageGap(level), | ||
gap1 = npm.utils.messageGap(level + 1), | ||
gap2 = npm.utils.messageGap(level + 2), | ||
lines = [ | ||
@@ -156,3 +156,3 @@ 'BatchError {', | ||
if (!d.success && counter < maxErrors) { | ||
lines.push(gap2 + index + ': ' + $npm.utils.formatError(d.result, level + 2)); | ||
lines.push(gap2 + index + ': ' + npm.utils.formatError(d.result, level + 2)); | ||
counter++; | ||
@@ -163,9 +163,9 @@ } | ||
lines.push(gap0 + '}'); | ||
return lines.join($npm.os.EOL); | ||
return lines.join(npm.os.EOL); | ||
}; | ||
BatchError.prototype.inspect = function () { | ||
npm.utils.addInspection(BatchError, function () { | ||
return this.toString(); | ||
}; | ||
}); | ||
module.exports = BatchError; |
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
BatchError: require('./batch'), | ||
@@ -34,7 +34,7 @@ PageError: require('./page'), | ||
module.exports = { | ||
BatchError: $npm.BatchError, | ||
PageError: $npm.PageError, | ||
SequenceError: $npm.SequenceError | ||
BatchError: npm.BatchError, | ||
PageError: npm.PageError, | ||
SequenceError: npm.SequenceError | ||
}; | ||
Object.freeze(module.exports); |
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
u: require('util'), | ||
@@ -80,3 +80,3 @@ os: require('os'), | ||
if (typeof this.message !== 'string') { | ||
this.message = $npm.u.inspect(this.message); | ||
this.message = npm.u.inspect(this.message); | ||
} | ||
@@ -87,5 +87,5 @@ } | ||
cbName = cbName ? ('\'' + cbName + '\'') : '<anonymous>'; | ||
this.reason = $npm.u.format(errorReasons[code], cbName, e.index); | ||
this.reason = npm.u.format(errorReasons[code], cbName, e.index); | ||
} else { | ||
this.reason = $npm.u.format(errorReasons[code], e.index); | ||
this.reason = npm.u.format(errorReasons[code], e.index); | ||
} | ||
@@ -97,3 +97,3 @@ | ||
$npm.u.inherits(PageError, Error); | ||
npm.u.inherits(PageError, Error); | ||
PageError.prototype.name = 'PageError'; | ||
@@ -117,4 +117,4 @@ | ||
var gap0 = $npm.utils.messageGap(level), | ||
gap1 = $npm.utils.messageGap(level + 1), | ||
var gap0 = npm.utils.messageGap(level), | ||
gap1 = npm.utils.messageGap(level + 1), | ||
lines = [ | ||
@@ -128,11 +128,11 @@ 'PageError {', | ||
lines.push(gap1 + 'error: ' + $npm.utils.formatError(this.error, level + 1)); | ||
lines.push(gap1 + 'error: ' + npm.utils.formatError(this.error, level + 1)); | ||
lines.push(gap0 + '}'); | ||
return lines.join($npm.os.EOL); | ||
return lines.join(npm.os.EOL); | ||
}; | ||
PageError.prototype.inspect = function () { | ||
npm.utils.addInspection(PageError, function () { | ||
return this.toString(); | ||
}; | ||
}); | ||
module.exports = PageError; |
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
u: require('util'), | ||
@@ -68,3 +68,3 @@ os: require('os'), | ||
if (typeof this.message !== 'string') { | ||
this.message = $npm.u.inspect(this.message); | ||
this.message = npm.u.inspect(this.message); | ||
} | ||
@@ -80,3 +80,3 @@ } | ||
cbName = cbName ? ('\'' + cbName + '\'') : '<anonymous>'; | ||
this.reason = $npm.u.format(errorReasons[code], cbName, e.index); | ||
this.reason = npm.u.format(errorReasons[code], cbName, e.index); | ||
@@ -86,3 +86,3 @@ Error.captureStackTrace(this, SequenceError); | ||
$npm.u.inherits(SequenceError, Error); | ||
npm.u.inherits(SequenceError, Error); | ||
SequenceError.prototype.name = 'SequenceError'; | ||
@@ -106,4 +106,4 @@ | ||
var gap0 = $npm.utils.messageGap(level), | ||
gap1 = $npm.utils.messageGap(level + 1), | ||
var gap0 = npm.utils.messageGap(level), | ||
gap1 = npm.utils.messageGap(level + 1), | ||
lines = [ | ||
@@ -117,11 +117,11 @@ 'SequenceError {', | ||
lines.push(gap1 + 'error: ' + $npm.utils.formatError(this.error, level + 1)); | ||
lines.push(gap1 + 'error: ' + npm.utils.formatError(this.error, level + 1)); | ||
lines.push(gap0 + '}'); | ||
return lines.join($npm.os.EOL); | ||
return lines.join(npm.os.EOL); | ||
}; | ||
SequenceError.prototype.inspect = function () { | ||
npm.utils.addInspection(SequenceError, function () { | ||
return this.toString(); | ||
}; | ||
}); | ||
module.exports = SequenceError; |
@@ -58,3 +58,3 @@ 'use strict'; | ||
var $p = config.promise, $utils = config.utils; | ||
var $p = config.promise, utils = config.utils; | ||
@@ -67,3 +67,3 @@ if (!Array.isArray(values)) { | ||
var empty = []; | ||
$utils.extend(empty, 'duration', 0); | ||
utils.extend(empty, 'duration', 0); | ||
return $p.resolve(empty); | ||
@@ -74,3 +74,3 @@ } | ||
var cb = $utils.wrap(options.cb), | ||
var cb = utils.wrap(options.cb), | ||
self = this, start = Date.now(); | ||
@@ -82,3 +82,3 @@ | ||
values.forEach(function (item, i) { | ||
$utils.resolve.call(self, item, null, function (data) { | ||
utils.resolve.call(self, item, null, function (data) { | ||
result[i] = data; | ||
@@ -103,3 +103,3 @@ step(i, true, data); | ||
} | ||
if ($utils.isPromise(cbResult)) { | ||
if (utils.isPromise(cbResult)) { | ||
cbResult | ||
@@ -143,3 +143,3 @@ .then(check) | ||
} else { | ||
$utils.extend(result, 'duration', Date.now() - start); | ||
utils.extend(result, 'duration', Date.now() - start); | ||
resolve(result); | ||
@@ -146,0 +146,0 @@ } |
@@ -75,3 +75,3 @@ 'use strict'; | ||
var $p = config.promise, $spex = config.spex, $utils = config.utils; | ||
var $p = config.promise, spex = config.spex, utils = config.utils; | ||
@@ -83,7 +83,7 @@ if (typeof source !== 'function') { | ||
options = options || {}; | ||
source = $utils.wrap(source); | ||
source = utils.wrap(source); | ||
var request, srcTime, destTime, | ||
limit = (options.limit > 0) ? parseInt(options.limit) : 0, | ||
dest = $utils.wrap(options.dest), | ||
dest = utils.wrap(options.dest), | ||
self = this, start = Date.now(), total = 0; | ||
@@ -97,3 +97,3 @@ | ||
srcTime = srcNow; | ||
$utils.resolve.call(self, source, [idx, request, srcDelay], function (value) { | ||
utils.resolve.call(self, source, [idx, request, srcDelay], function (value) { | ||
if (value === undefined) { | ||
@@ -103,3 +103,3 @@ success(); | ||
if (value instanceof Array) { | ||
$spex.batch(value) | ||
spex.batch(value) | ||
.then(function (data) { | ||
@@ -121,3 +121,3 @@ request = data; | ||
} | ||
if ($utils.isPromise(destResult)) { | ||
if (utils.isPromise(destResult)) { | ||
destResult | ||
@@ -124,0 +124,0 @@ .then(next) |
@@ -84,3 +84,3 @@ 'use strict'; | ||
var $p = config.promise, $utils = config.utils; | ||
var $p = config.promise, utils = config.utils; | ||
@@ -91,3 +91,3 @@ if (typeof source !== 'function') { | ||
source = $utils.wrap(source); | ||
source = utils.wrap(source); | ||
@@ -97,3 +97,3 @@ options = options || {}; | ||
var limit = (options.limit > 0) ? parseInt(options.limit) : 0, | ||
dest = $utils.wrap(options.dest), | ||
dest = utils.wrap(options.dest), | ||
self = this, data, srcTime, destTime, result = [], start = Date.now(); | ||
@@ -107,3 +107,3 @@ | ||
srcTime = srcNow; | ||
$utils.resolve.call(self, source, [idx, data, srcDelay], function (value, delayed) { | ||
utils.resolve.call(self, source, [idx, data, srcDelay], function (value, delayed) { | ||
data = value; | ||
@@ -129,3 +129,3 @@ if (data === undefined) { | ||
} | ||
if ($utils.isPromise(destResult)) { | ||
if (utils.isPromise(destResult)) { | ||
destResult | ||
@@ -175,3 +175,3 @@ .then(function () { | ||
if (options.track) { | ||
$utils.extend(result, 'duration', length); | ||
utils.extend(result, 'duration', length); | ||
} else { | ||
@@ -178,0 +178,0 @@ result = { |
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
read: require('./read') | ||
@@ -63,3 +63,3 @@ }; | ||
var res = { | ||
read: $npm.read(config) | ||
read: npm.read(config) | ||
}; | ||
@@ -66,0 +66,0 @@ Object.freeze(res); |
@@ -72,5 +72,5 @@ 'use strict'; | ||
var $p = config.promise, $utils = config.utils; | ||
var $p = config.promise, utils = config.utils; | ||
if (!$utils.isReadableStream(stream)) { | ||
if (!utils.isReadableStream(stream)) { | ||
return $p.reject(new TypeError('Readable stream is required.')); | ||
@@ -83,3 +83,3 @@ } | ||
receiver = $utils.wrap(receiver); | ||
receiver = utils.wrap(receiver); | ||
@@ -162,3 +162,3 @@ options = options || {}; | ||
if ($utils.isPromise(result)) { | ||
if (utils.isPromise(result)) { | ||
result | ||
@@ -165,0 +165,0 @@ .then(function () { |
'use strict'; | ||
var $npm = { | ||
var npm = { | ||
utils: require('./utils'), | ||
@@ -60,10 +60,10 @@ batch: require('./ext/batch'), | ||
promise: promise, | ||
utils: $npm.utils(promise) | ||
utils: npm.utils(promise) | ||
}; | ||
spex.errors = $npm.errors; | ||
spex.batch = $npm.batch(config); | ||
spex.page = $npm.page(config); | ||
spex.sequence = $npm.sequence(config); | ||
spex.stream = $npm.stream(config); | ||
spex.errors = npm.errors; | ||
spex.batch = npm.batch(config); | ||
spex.page = npm.page(config); | ||
spex.sequence = npm.sequence(config); | ||
spex.stream = npm.stream(config); | ||
@@ -70,0 +70,0 @@ config.utils.extend(spex, '$p', promise); |
'use strict'; | ||
var stat = require('./static'); | ||
var npm = { | ||
stat: require('./static') | ||
}; | ||
@@ -8,7 +10,7 @@ module.exports = function ($p) { | ||
var exp = { | ||
formatError: stat.formatError, | ||
isPromise: stat.isPromise, | ||
isReadableStream: stat.isReadableStream, | ||
messageGap: stat.messageGap, | ||
extend: stat.extend, | ||
formatError: npm.stat.formatError, | ||
isPromise: npm.stat.isPromise, | ||
isReadableStream: npm.stat.isReadableStream, | ||
messageGap: npm.stat.messageGap, | ||
extend: npm.stat.extend, | ||
resolve: resolve, | ||
@@ -15,0 +17,0 @@ wrap: wrap |
'use strict'; | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var npm = { | ||
stream: require('stream'), | ||
util: require('util') | ||
}; | ||
@@ -16,3 +18,3 @@ ///////////////////////////////////// | ||
function isReadableStream(obj) { | ||
return obj instanceof stream.Stream && | ||
return obj instanceof npm.stream.Stream && | ||
typeof obj._read === 'function' && | ||
@@ -41,3 +43,3 @@ typeof obj._readableState === 'object'; | ||
var names = ['BatchError', 'PageError', 'SequenceError']; | ||
var msg = util.inspect(error); | ||
var msg = npm.util.inspect(error); | ||
if (error instanceof Error) { | ||
@@ -56,3 +58,18 @@ if (names.indexOf(error.name) === -1) { | ||
//////////////////////////////////////////////////////// | ||
// Adds prototype inspection, with support of the newer | ||
// Custom Inspection, which was added in Node.js 6.x | ||
function addInspection(type, cb) { | ||
// istanbul ignore next; | ||
if (npm.util.inspect.custom) { | ||
// Custom inspection is supported: | ||
type.prototype[npm.util.inspect.custom] = cb; | ||
} else { | ||
// Use classic inspection: | ||
type.prototype.inspect = cb; | ||
} | ||
} | ||
module.exports = { | ||
addInspection: addInspection, | ||
formatError: formatError, | ||
@@ -59,0 +76,0 @@ isPromise: isPromise, |
{ | ||
"name": "spex", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Specialized Promise Extensions", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"browserify": "browserify lib/index.js -s spexLib -o spex.js", | ||
"lint": "./node_modules/.bin/eslint ./lib ./test/**/Spec*.js" | ||
"lint": "./node_modules/.bin/eslint ./lib ./test/**/*Spec.js" | ||
}, | ||
@@ -45,11 +45,11 @@ "files": [ | ||
"devDependencies": { | ||
"bluebird": "~3.5.0", | ||
"browserify": "~14.4.0", | ||
"coveralls": "~2.11.16", | ||
"eslint": "~4.7.1", | ||
"bluebird": "~3.5.1", | ||
"browserify": "~14.5.0", | ||
"coveralls": "~3.0.0", | ||
"eslint": "~4.9.0", | ||
"istanbul": "~0.4.5", | ||
"jasmine-node": "~1.14.5", | ||
"jsdoc": "~3.5.5", | ||
"typescript": "~2.5.2" | ||
"typescript": "~2.5.3" | ||
} | ||
} |
## TypeScript for SPEX | ||
Complete TypeScript 2.0 declarations for the [spex] module. | ||
Complete TypeScript 2.x declarations for the [spex] module. | ||
@@ -5,0 +5,0 @@ ### Inclusion |
//////////////////////////////////////// | ||
// Requires SPEX v1.3.0 or later. | ||
// Requires SPEX v2.0.0 or later. | ||
//////////////////////////////////////// | ||
@@ -125,3 +125,3 @@ | ||
// API: http://vitaly-t.github.io/spex/stream.html#.read | ||
read(stream: any, receiver: (index: number, data: Array<any>, delay: number) => any, options?: spex.TStreamReadOptions): Promise<spex.TStreamReadResult>; | ||
read(stream: any, receiver: (index: number, data: Array<any>, delay: number) => any, options?: TStreamReadOptions): Promise<TStreamReadResult>; | ||
} | ||
@@ -128,0 +128,0 @@ |
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
65071
1601