Socket
Book a DemoInstallSign in
Socket

contra-find

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

contra-find

Using contra, asynchronously find a value in a collection that matches a condition.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

contra-find

build status

Using contra, asynchronously find a value in a collection that matches a condition.

var λ = require('contra');
var find = require('contra-find');

var items = [
  [1, 2],
  [2, 3],
  [3, 4],
  [4, 5],
  [5, 6]
];

find(λ, items, function(item, next){

  console.log('item :', item);

  process.nextTick(function(){
    console.log('check:', item);
    next(undefined, item[0] === 3);
  });

}, function(err, item){
  console.log('item found!', item);
});

output

item : [ 1, 2 ]
check: [ 1, 2 ]
item : [ 2, 3 ]
check: [ 2, 3 ]
item : [ 3, 4 ]
check: [ 3, 4 ]
item found! [ 3, 4 ]

Notice that it iterates in series and stops as soon as the item is found.

License

MIT

Keywords

contra

FAQs

Package last updated on 29 Jun 2016

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