Socket
Book a DemoInstallSign in
Socket

cheeky-async

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheeky-async

Some cheeky async versions of Array methods like map, filter and reduce. With support for sequential and parallel processing.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

cheeky-async

package version package downloads standard-readme compliant package license make a pull request

Some cheeky async versions of Array methods like map, filter and reduce. With support for sequential and parallel processing.

Table of Contents

Usage

import {map} from "cheeky-async"

await map([1, 2, 3], async (value) => {
  return value + (await getThingy())
})

Install

This project uses node and npm.

$ npm install cheeky-async
$ # OR
$ yarn add cheeky-async

API

Table of Contents

map

Invoke an async transform/mapping function on each item in an Array returning the resulting Array of transformed/mapped items. Async async transform/mapping function is invoked in parallel by default.

This is an async version of Array.prototype.map().

Parameters

  • array Array The Array to map over
  • mapper MapperFunction Async function, gets passed (value, index, array), returns the new value.
  • config Config Configuration

filter

Invoke an async predicate function on each item in an Array returning the resulting Array with all items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.

This is an async version of Array.prototype.filter().

Parameters

  • array Array The Array to map over
  • mapper PredicateFunction Async function, gets passed (value, index, array), returns the new value.
  • config Config Configuration

Returns Promise resulting mapped/transformed values.

every

Invoke an async predicate function on each item in an Array returning true/false depending on all items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.

This is an async version of Array.prototype.every().

Parameters

  • array Array The Array to map over
  • mapper PredicateFunction Async function, gets passed (value, index, array), returns the new value.
  • config Config Configuration

Returns Promise<Boolean> resulting mapped/transformed values.

some

Invoke an async predicate function on each item in an Array returning true/false depending on any items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.

This is an async version of Array.prototype.some().

Parameters

  • array Array The Array to map over
  • mapper PredicateFunction Async function, gets passed (value, index, array), returns the new value.
  • config Config Configuration

Returns Promise<Boolean> resulting mapped/transformed values.

reduce

Invoke an async reducer function on each item in an Array returning the resulting value. Async async reducer function is invoked in sequence by default.

This is an async version of Array.prototype.reduce().

Parameters

  • array Array The Array to reduce.
  • reducer reducerFunction Async function, gets passed (accumulator, value, index, array), returns the new accumulator.
  • config Config Configuration

Returns Promise resulting value.

Contribute

  • Fork it and create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am "Add some feature"
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

MIT

FAQs

Package last updated on 22 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts