Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okunishinishi/node-arrayfilter
Node.js module for array filtering.
https://github.com/okunishinishi/node-arrayfilter
Last synced: 2 months ago
JSON representation
Node.js module for array filtering.
- Host: GitHub
- URL: https://github.com/okunishinishi/node-arrayfilter
- Owner: okunishinishi
- License: mit
- Created: 2015-08-16T14:05:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-22T11:19:13.000Z (about 9 years ago)
- Last Synced: 2024-10-29T08:28:11.927Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/arrayfilter
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
arrayfilter
==========[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url][bd_repo_url]: https://github.com/okunishinishi/node-arrayfilter
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-arrayfilter
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-arrayfilter.svg?style=flat
[bd_license_url]: https://github.com/okunishinishi/node-arrayfilter/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-arrayfilter
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-arrayfilter.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-arrayfilter.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-arrayfilter
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-arrayfilter.svg
[bd_npm_url]: http://www.npmjs.org/package/arrayfilter
[bd_npm_shield_url]: http://img.shields.io/npm/v/arrayfilter.svg?style=flat
[bd_bower_badge_url]: https://img.shields.io/bower/v/arrayfilter.svg?style=flatArray filtering utility.
```bash
npm install arrayfilter --save
```+ [Accepting By Type](#accepting-by-type)
+ [Accepting By Pattern](#accepting-by-pattern)
+ [Rejecting Empty Entries](#rejecting-empty-entries)
+ [Rejecting Duplicated Entries](#rejecting-duplicated-entries)
+ [Rejecting By Pattern](#rejecting-by-pattern)
+ [Rejecting By Type](#rejecting-by-type)### Accepting By Type
`arrayfilter.typeAccept(type)` create a function which accepts entries by type matching.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let acceptString = arrayfilter.typeAccept('string');// Execute filtering.
let values = ['foo', {}, 123].filter(acceptString);
console.log(values); // -> ['foo']```
### Accepting By Pattern
`arrayfilter.patternAccept(pattern)` create a function which accepts entries by regex (or string) matching.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let acceptFo = arrayfilter.patternAccept(/^fo/);// Execute filtering.
let values = ['foo', 'bar', 'baz'].filter(acceptFo);
console.log(values); // -> ['foo']```
### Rejecting Empty Entries
`arrayfilter.emptyReject()` create a function which rejects empty with rejects null, undefined and empty string.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let rejectEmpty = arrayfilter.emptyReject();// Execute filtering.
let values = ['foo', '', null, 'bar', undefined].filter(rejectEmpty);
console.log(values); // -> ['foo', 'bar']```
### Rejecting Duplicated Entries
`arrayfilter.duplicateReject()` create a function which rejects empty with rejects null, undefined and empty string.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let duplicateReject = arrayfilter.duplicateReject();// Execute filtering.
let values = ['foo', 'bar', 'foo'].filter(duplicateReject);
console.log(values); // -> ['foo', 'bar']```
### Rejecting By Pattern
`arrayfilter.patternReject(pattern)` create a function which rejects entries by regex (or string) matching.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let rejectFo = arrayfilter.patternReject(/^fo/);// Execute filtering.
let values = ['foo', 'bar', 'baz'].filter(rejectFo);
console.log(values); // -> ['bar', 'baz']```
### Rejecting By Type
`arrayfilter.typeReject(type)` create a function which rejects entries by type matching.
```Javascript
"use strict";const arrayfilter = require('arrayfilter');
// Define a filter function.
let rejectString = arrayfilter.typeReject('object');// Execute filtering.
let values = ['foo', {}, {}].filter(rejectString);
console.log(values); // -> ['foo']```
License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-arrayfilter/blob/master/LICENSE).Links
------+ [arrayreduce](https://github.com/okunishinishi/node-arrayreduce)
+ [arraysort](https://github.com/okunishinishi/node-arraysort)