Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spex

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spex - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

3

docs/code/batch.md

@@ -24,5 +24,6 @@ <a name="batch"></a>

<ul>
<li><code>index</code> = index of the value in the array</li>
<li><code>index</code> = index of the value in the source array</li>
<li><code>success</code> - indicates whether the value was resolved (<code>true</code>), or rejected (<code>false</code>)</li>
<li><code>data</code> = resolved data, if <code>success</code>=<code>true</code>, or else the rejection reason</li>
<li><code>delay</code> = number of milliseconds since the last call (<code>undefined</code> when <code>index=0</code>)</li>
</ul>

@@ -29,0 +30,0 @@ <p>The function is called with the same <code>this</code> context as the calling method.</p>

@@ -24,2 +24,3 @@ <a name="page"></a>

<li><code>data</code> = previously returned page, resolved as a <a href="batch.md">batch</a> (<code>undefined</code> when <code>index=0</code>)</li>
<li><code>delay</code> = number of milliseconds since the last call (<code>undefined</code> when <code>index=0</code>)</li>
</ul>

@@ -44,2 +45,3 @@ <p>If the function throws an error or returns a rejected promise, the method rejects with

<li><code>data</code> = page data resolved as a <a href="batch.md">batch</a></li>
<li><code>delay</code> = number of milliseconds since the last call (<code>undefined</code> when <code>index=0</code>)</li>
</ul>

@@ -46,0 +48,0 @@ <p>The function is called with the same <code>this</code> context as the calling method.</p>

@@ -23,2 +23,3 @@ <a name="sequence"></a>

<li><code>data</code> = resolved data from the previous call (<code>undefined</code> when <code>index=0</code>)</li>
<li><code>delay</code> = number of milliseconds since the last call (<code>undefined</code> when <code>index=0</code>)</li>
</ul>

@@ -42,2 +43,3 @@ <p>The function is called with the same <code>this</code> context as the calling method.</p>

<li><code>data</code> = the data resolved</li>
<li><code>delay</code> = number of milliseconds since the last call (<code>undefined</code> when <code>index=0</code>)</li>
</ul>

@@ -44,0 +46,0 @@ <p>The function is called with the same <code>this</code> context as the calling method.</p>

@@ -23,5 +23,6 @@ 'use strict';

* Parameters:
* - `index` = index of the value in the array
* - `index` = index of the value in the source array
* - `success` - indicates whether the value was resolved (`true`), or rejected (`false`)
* - `data` = resolved data, if `success`=`true`, or else the rejection reason
* - `delay` = number of milliseconds since the last call (`undefined` when `index=0`)
*

@@ -77,3 +78,3 @@ * The function is called with the same `this` context as the calling method.

return $p(function (resolve, reject) {
var errors = [], sorted = false, remaining = values.length,
var cbTime, errors = [], sorted = false, remaining = values.length,
result = new Array(remaining);

@@ -92,5 +93,7 @@ values.forEach(function (item, i) {

if (cb) {
var cbResult;
var cbResult, cbNow = Date.now(),
cbDelay = idx ? (cbNow - cbTime) : undefined;
cbTime = cbNow;
try {
cbResult = cb.call(self, idx, pass, data);
cbResult = cb.call(self, idx, pass, data, cbDelay);
} catch (e) {

@@ -97,0 +100,0 @@ setError(e);

@@ -22,2 +22,3 @@ 'use strict';

* - `data` = previously returned page, resolved as a $[batch] (`undefined` when `index=0`)
* - `delay` = number of milliseconds since the last call (`undefined` when `index=0`)
*

@@ -43,2 +44,3 @@ * If the function throws an error or returns a rejected promise, the method rejects with

* - `data` = page data resolved as a $[batch]
* - `delay` = number of milliseconds since the last call (`undefined` when `index=0`)
*

@@ -105,3 +107,3 @@ * The function is called with the same `this` context as the calling method.

var self = this, request, start = Date.now(), total = 0;
var self = this, request, srcTime, destTime, start = Date.now(), total = 0;

@@ -111,3 +113,6 @@ return $p(function (resolve, reject) {

function loop(idx) {
$utils.resolve.call(self, source, [idx, request], function (value) {
var srcNow = Date.now(),
srcDelay = idx ? (srcNow - srcTime) : undefined;
srcTime = srcNow;
$utils.resolve.call(self, source, [idx, request, srcDelay], function (value) {
if (value === undefined) {

@@ -122,5 +127,7 @@ success();

if (dest) {
var destResult;
var destResult, destNow = Date.now(),
destDelay = idx ? (destNow - destTime) : undefined;
destTime = destNow;
try {
destResult = dest.call(self, idx, data);
destResult = dest.call(self, idx, data, destDelay);
} catch (err) {

@@ -127,0 +134,0 @@ fail({

@@ -17,2 +17,3 @@ 'use strict';

* - `data` = resolved data from the previous call (`undefined` when `index=0`)
* - `delay` = number of milliseconds since the last call (`undefined` when `index=0`)
*

@@ -36,2 +37,3 @@ * The function is called with the same `this` context as the calling method.

* - `data` = the data resolved
* - `delay` = number of milliseconds since the last call (`undefined` when `index=0`)
*

@@ -92,3 +94,3 @@ * The function is called with the same `this` context as the calling method.

var self = this, data, result = [], start = Date.now();
var self = this, data, srcTime, destTime, result = [], start = Date.now();

@@ -98,3 +100,6 @@ return $p(function (resolve, reject) {

function loop(idx) {
$utils.resolve.call(self, source, [idx, data], function (value, delayed) {
var srcNow = Date.now(),
srcDelay = idx ? (srcNow - srcTime) : undefined;
srcTime = srcNow;
$utils.resolve.call(self, source, [idx, data, srcDelay], function (value, delayed) {
data = value;

@@ -108,5 +113,7 @@ if (data === undefined) {

if (dest) {
var destResult;
var destResult, destNow = Date.now(),
destDelay = idx ? (destNow - destTime) : undefined;
destTime = destNow;
try {
destResult = dest.call(self, idx, data);
destResult = dest.call(self, idx, data, destDelay);
} catch (e) {

@@ -113,0 +120,0 @@ reject({

{
"name": "spex",
"version": "0.1.4",
"version": "0.1.5",
"description": "Specialized Promise Extensions",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -40,5 +40,5 @@ # Specialized Promise Extensions

* Methods
- [batch]
- [page]
- [sequence]
- [batch]
- [page]
- [sequence]

@@ -45,0 +45,0 @@ [Module]:https://github.com/vitaly-t/spex/blob/master/docs/code/module.md

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc