Socket
Book a DemoInstallSign in
Socket

poly-find

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

poly-find

Polymorphic curried list lookup for functional style JS

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

poly-find

Polymorphic curried list lookup for functional style JS

Motivation

Javascript isn't very consistent when it comes to lists. Native list processing functions only work with arrays, not with objects. Neverhtless, objects are being used as lists as often because of their amazing ability to provide non-numerical indexes to their elements. So, every time we want to find an element in an object-based collection (say, coming from an AJAX request), we have to write almost identical loops in order to perform that operations.

Poly-find works equally well with both arrays and objects so you never have to write those annoying loops again.

Features

  • Works with objects and arrays
  • Automatically curried

Installation

npm install poly-find

Usage

var find = require('poly-find');

var object = {
  a: 100,
  b: 200,
  c: 300,
  d: 400
};

var array = [100, 200, 300, 400];

function greaterThen100(number) {
  return number > 100;
}

// Basic find
var result = find(greaterThen100, object);
// -> 200

result = find(greaterThen100, array);
// -> 200


// Pipeline-style usage
getDataAsPromise()
    .then(find(greaterThen100))
    .then(console.log)
// -> 200

Keywords

find

FAQs

Package last updated on 30 Jul 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.