Comparing version 0.2.4 to 0.2.5
@@ -7,2 +7,5 @@ 'use strict'; | ||
* @description | ||
* **Alternative Syntax:** | ||
* `batch(values, {cb})` ⇒ `Promise` | ||
* | ||
* Settles (resolves or rejects) every $[mixed value] in the input array, and resolves | ||
@@ -16,2 +19,3 @@ * with an array of results, if all values have been resolved, or else rejects. | ||
* <img src="../images/batch.png" width="836px" height="210px" alt="batch"> | ||
* | ||
* @param {Array} values | ||
@@ -167,2 +171,11 @@ * Array of $[mixed values], to be resolved asynchronously, in no particular order. | ||
// `options` object-to-parameters wrapper; | ||
function _batch(values, cb) { | ||
if ($utils.hasProperties(cb, ['cb'])) { | ||
return batch(values, cb.cb); | ||
} else { | ||
return batch(values, cb); | ||
} | ||
} | ||
var $utils, $p; | ||
@@ -173,3 +186,3 @@ | ||
$p = config.promise; | ||
return batch; | ||
return _batch; | ||
}; |
@@ -7,2 +7,5 @@ 'use strict'; | ||
* @description | ||
* **Alternative Syntax:** | ||
* `page(source, {dest, limit})` ⇒ `Promise` | ||
* | ||
* Acquires pages (arrays of $[mixed values]) from the source function, one by one, | ||
@@ -199,2 +202,11 @@ * and resolves each page as a $[batch], till no more pages left or an error/reject occurs. | ||
// `options` object-to-parameters wrapper; | ||
function _page(source, dest, limit) { | ||
if ($utils.hasProperties(dest, ['dest', 'limit'])) { | ||
return page(source, dest.dest, dest.limit); | ||
} else { | ||
return page(source, dest, limit); | ||
} | ||
} | ||
var $spex, $utils, $p; | ||
@@ -206,3 +218,3 @@ | ||
$p = config.promise; | ||
return page; | ||
return _page; | ||
}; |
@@ -7,2 +7,5 @@ 'use strict'; | ||
* @description | ||
* **Alternative Syntax:** | ||
* `sequence(source, {dest, limit, track})` ⇒ `Promise` | ||
* | ||
* Acquires $[mixed values] from the source function, one at a time, and resolves them, | ||
@@ -13,2 +16,3 @@ * till either no more values left in the sequence or an error/reject occurs. | ||
* <img src="../images/sequence.png" width="561px" height="193px" alt="sequence"> | ||
* | ||
* @param {function} source | ||
@@ -188,2 +192,11 @@ * Expected to return the next $[mixed value] to be resolved. Returning or resolving | ||
// `options` object-to-parameters wrapper; | ||
function _sequence(source, dest, limit, track) { | ||
if ($utils.hasProperties(dest, ['dest', 'limit', 'track'])) { | ||
return sequence(source, dest.dest, dest.limit, dest.track); | ||
} else { | ||
return sequence(source, dest, limit, track); | ||
} | ||
} | ||
var $utils, $p; | ||
@@ -194,3 +207,3 @@ | ||
$p = config.promise; | ||
return sequence; | ||
return _sequence; | ||
}; |
@@ -7,6 +7,9 @@ 'use strict'; | ||
* @description | ||
* **Alternative Syntax:** | ||
* `read(stream, receiver, {closable, readSize})` ⇒ `Promise` | ||
* | ||
* Reads the entire stream, using **paused mode**, with support for both synchronous | ||
* and asynchronous data processing. | ||
* | ||
* **NOTE:** Once the method has finished, the onus is on the caller to release the stream | ||
* Once the method has finished, the onus is on the caller to release the stream | ||
* according to its protocol. | ||
@@ -168,2 +171,11 @@ * | ||
// `options` object-to-parameters wrapper; | ||
function _read(stream, receiver, closable, readSize) { | ||
if ($utils.hasProperties(closable, ['closable', 'readSize'])) { | ||
return read(stream, receiver, closable.closable, closable.readSize); | ||
} else { | ||
return read(stream, receiver, closable, readSize); | ||
} | ||
} | ||
var $utils, $p; | ||
@@ -174,3 +186,3 @@ | ||
$p = config.promise; | ||
return read; | ||
return _read; | ||
}; |
@@ -18,3 +18,3 @@ 'use strict'; | ||
//////////////////////////////////////////// | ||
// Check object for being a readable stream; | ||
// Checks object for being a readable stream; | ||
@@ -27,2 +27,16 @@ function isReadableStream(obj) { | ||
/////////////////////////////////////////// | ||
// Checks object for containing any of the | ||
// specified properties; | ||
function hasProperties(obj, params) { | ||
if (obj && obj instanceof Object) { | ||
for (var i = 0; i < params.length; i++) { | ||
if (params[i] in obj) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
//////////////////////////////////////////////////////////// | ||
@@ -78,2 +92,3 @@ // Sets an object property as read-only and non-enumerable. | ||
isReadableStream: isReadableStream, | ||
hasProperties: hasProperties, | ||
extend: extend, | ||
@@ -80,0 +95,0 @@ resolve: resolve |
{ | ||
"name": "spex", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Specialized Promise Extensions", | ||
@@ -46,5 +46,5 @@ "main": "lib/index.js", | ||
"grunt-jsdoc-to-markdown": "1.x", | ||
"istanbul": "0.3", | ||
"istanbul": "0.4", | ||
"jasmine-node": "1.x" | ||
} | ||
} |
@@ -65,3 +65,2 @@ 'use strict'; | ||
}) | ||
}); | ||
@@ -93,3 +92,3 @@ it("must reject correctly", function () { | ||
spex.batch([1, 2], cb) | ||
spex.batch([1, 2], {cb: cb}) | ||
.catch(function (reason) { | ||
@@ -96,0 +95,0 @@ r = reason; |
@@ -259,3 +259,3 @@ 'use strict'; | ||
beforeEach(function (done) { | ||
spex.page(source, null, limit) | ||
spex.page(source, {limit: limit}) | ||
.then(function (data) { | ||
@@ -262,0 +262,0 @@ result = data; |
@@ -145,3 +145,3 @@ 'use strict'; | ||
beforeEach(function (done) { | ||
spex.sequence(source, null, limit) | ||
spex.sequence(source, {limit: limit}) | ||
.then(function (data) { | ||
@@ -148,0 +148,0 @@ result = data; |
@@ -128,3 +128,3 @@ 'use strict'; | ||
beforeEach(function (done) { | ||
spex.stream.read(stm, receiver, true) | ||
spex.stream.read(stm, receiver, {closable: true}) | ||
.then(function (data) { | ||
@@ -155,3 +155,3 @@ result = data; | ||
beforeEach(function (done) { | ||
spex.stream.read(stm, receiver, false, 100) | ||
spex.stream.read(stm, receiver, {readSize: 100}) | ||
.then(function (data) { | ||
@@ -158,0 +158,0 @@ result = data; |
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
63534
1646