for-more

1.0.1 • Public • Published

for-more

npm version Gzip Size Monthly Downloads License: MIT

Multithread Synchronization Loop. Support Promise.

Install

npm install for-more --save
#or 
yarn add for-more

Import

require('for-more')
//or
var forMore = require('for-more')
//or
import 'for-more'
//or
import forMore from 'for-more'

Usage

// forMore([], options, hander, callback)
// [].forMore(options, handler, callback)
// [].forMore(options, handler).then().catch()
// [].forMore(lines, handler).then().catch()
// [].forMore(handler).then().catch()
 
[1, 2, 3].forMore(2, function(item, index, array) {
  return item * 2
})
.then(function(results) {
  console.log(results)
})
// [2, 4, 6]
 
[1, 2, 3].forMore(2, async function(item, index, array) {
  const html = await axios.get('http://www.google.com?q=' + item)
  return html.data
}, function(results) {
  console.log(results)
})
 
[1, 2, 3].forMore({
  lines: 2, // default is 1
  abort: true // default is false
}, async function(item, index, array) {
  const html = await axios.get('http://www.google.com?q=' + item)
  return html.data
}, function(results) {
  console.log(results)
})
 

Package Sidebar

Install

npm i for-more

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

6.1 kB

Total Files

4

Last publish

Collaborators

  • mlinquan