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

promise_mtd

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise_mtd - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

promise_mtd/filter.js

2

index.js

@@ -9,2 +9,4 @@ 'use strict';

promise_mtd.filter = require('./promise_mtd/filter.js');
promise_mtd.transform = require('./promise_mtd/transform.js');

@@ -11,0 +13,0 @@

2

package.json
{
"name": "promise_mtd",
"version": "1.0.3",
"version": "1.0.4",
"description": "Set of methods allowing simplify work with Promises in cycle. Methods: forEach, map, while, transform, parallel",

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

# promise_mtd
Set of methods allowing to simplify work with promises in cycle.
* Implementation of ```forEach``` and ```map``` for working with array data when it's needed to apply asynchronous function to each element.
* Implementation of ```forEach```, ```map```, ```filter``` for working with array data when it's needed to apply asynchronous function to each element.
* Method ```transform``` allows to iterate asynchronously over an array similarly to ```map```, but also it can skip unnecessary data.

@@ -53,2 +53,19 @@ * Implementation of cycle ```while``` for using with promise.

### filter(Array<any>, Function(el, index): Promise<Boolean>)
```Filter```
```js
const promiseMtd = require('promise_mtd');
void async function () {
let res = await promiseMtd.filter([ 0, 1, 2, 3 ], function(time, i) {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve(Boolean(i));
}, time*1000);
});
});
console.log(res); // [ 1, 2, 3 ]
}();
```
### parallel(Array<any>, Function(el, index))

@@ -136,7 +153,7 @@ Equivalent of ```Promise.all``` but with limit

// { t1: 2000, t2: 1000 }
console.log(await promise_mtd.all({ t1, t2 }));
console.log(await promiseMtd.all({ t1, t2 }));
// as Promise.all
// [ 2000, 1000 ]
console.log(await promise_mtd.all([ t1, t2 ]));
console.log(await promiseMtd.all([ t1, t2 ]));
} catch (err) {

@@ -143,0 +160,0 @@ console.log('Raise', err);

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