somefilter

2018-10-23 admin

somefilter是什么

什么是somefilter,Right-to-left conditional function composition. Get some result of filter functions calls.

somefilter使用教程帮助文档

somefilter License NPM version Dependency Status Build Status Coverage Status

Right-to-left conditional function composition. Get some result of filter functions call.

Install

npm i somefilter --save

How to use?

const somefilter = require('somefilter');
const notEmpty = ({length} = 0) => length;
const find = (array, condition) => array.filter(condition);
const findZero = array => find(array, a => !a);
const findPositive = array => find(array, a => a > 0);
const findNumbers = somefilter(notEmpty, [findPositive, findZero]);
findNumbers([1, 2, -1, -3]);
// returns
[1, 2];
findNumbers([1, 2, -1, -3, 0, 0, 0]);
// returns
[0, 0, 0];

Environments

In old node.js environments that not fully supports es2015, somefilter could be used with:

var somefilter = require('somefilter/legacy');

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:RSS iis7站长之家

文章标题:somefilter

回到顶部