for-more
v1.0.1
Published
Multithread Synchronization Loop. Support Promise.
Downloads
5
Maintainers
Readme
for-more
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)
})