New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

avec

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avec

Eventual ES5 array operations using promises

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

avec

Eventual ES5 array operations using promises

installation

$ npm install avec

usage

Think of it like using native ES5 Array.prototype methods on Promised arrays.

var documents = getPromisedArrayOfStuffFromDB()
avec(documents).forEach(function (document) {
  console.dir(document)
})

avec(documents)
  .filter(x)
  .map(x)
  .reduce(x)
  .then(function (aggregate) {
    console.log('we can string things together')
    // the neat thing about promises is that there's no `value()`
    // or finalizer method to call, since each step of the way
    // returns a valid promises/a `thenable` promise.
  })

api

avec(promisedCollection)

Begins a promise chain.

Supported Array.prototype methods:

forEach, filter, map, reduce, reduceRight, every, some, concat, reverse, sort, indexOf, lastIndexOf, shift, unshift, pop, push, slice, splice

The return value for each of these is the a Promise of whatever the return value would be on a synchronous array.

avec(promise, continuation)

like calling promise.then(continuation), except continuation's this is also set to the promise value. This allows for slightly more fluid syntax:

var document = getDocumentAsPromise(5)

avec(document, function () {
  console.log('We got ' + this.title)
})

This is pretty much an ergonomic function I wanted when writing scripts.

avec.each(promisedArray, iterator), alias avec.chaque, avec.forEach

Like calling promise.then(function (val) { val.forEach(iterator) }), Use when you're expecting an array value that you want to iterate over.

avec.map(promisedArray, scalarFunction

Like calling promise.then(function (val) { return val.map(scalarFunction) }). Returns a Promise

running the unit tests

In package root directory:

$ npm install
$ npm test

contributors

jden jason@denizac.org

license

MIT. (c) 2013 Agile Diagnosis hello@agilediagnosis.com See LICENSE.md

Keywords

FAQs

Package last updated on 28 Feb 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc