1.0.1 • Published 5 years ago

for-more v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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)
})