JSPM

times-loop

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 103
  • Score
    100M100P100Q89902F
  • License MIT

run a function n times, both sync and async functions are supported

Package Exports

  • times-loop

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (times-loop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

times-loop Build Status

run a function n times, returns results as an array

Usage

Supports both ESM and CommonJS

// esm
import times from 'times-loop`
// commonjs
const times = require('times-loop').default

Simple Example

import times from 'times-loop'

var results = times(6, function (i) {
  console.log(i)
  return i
})
// prints: 0 1 2 3 4 5

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]

Promise Example: Parallel

runs promise results in parallel

import { timesParallel } from 'times-loop'

const results = await timesParallel(6, function (i) {
  return Promise.resolve(i)
})

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]

Promise Example: Series

runs promise results in series

import { timeSeries } from 'times-loop'

const results = await timeSeries(6, function (i) {
  return Promise.resolve(i)
})

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]

License

MIT