Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aliencreations/alien-node-list-utils
Collection of array helpers.
https://github.com/aliencreations/alien-node-list-utils
Last synced: about 1 month ago
JSON representation
Collection of array helpers.
- Host: GitHub
- URL: https://github.com/aliencreations/alien-node-list-utils
- Owner: AlienCreations
- License: mit
- Created: 2016-03-30T19:18:06.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-13T21:25:39.000Z (over 1 year ago)
- Last Synced: 2024-12-06T12:46:24.886Z (about 2 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# alien-node-list-utils
Helper functions for arrays on NodeJS. The functions are pure and curried with Ramda.[![Build Status](https://travis-ci.org/AlienCreations/alien-node-list-utils.svg?branch=master)](https://travis-ci.org/AlienCreations/alien-node-list-utils) [![Coverage Status](https://coveralls.io/repos/AlienCreations/alien-node-list-utils/badge.svg?branch=master&service=github)](https://coveralls.io/github/AlienCreations/alien-node-list-utils?branch=master) [![npm version](http://img.shields.io/npm/v/alien-node-list-utils.svg)](https://npmjs.org/package/alien-node-list-utils) [![Dependency Status](https://david-dm.org/AlienCreations/alien-node-list-utils.svg)](https://david-dm.org/AlienCreations/alien-node-list-utils)
## Install
```
$ npm install alien-node-list-utils --save
```Run the specs
```
$ npm test
```## Methods
#### filterOutItem
Given a list and an item, returns a copy of the list absent said item.```js
var listUtils = require('alien-node-list-utils'),
list = ['a', 'b', 'c', 'd'];
listUtils.filterOutItem('b', list); // ['a', 'c', 'd']```
#### filterOutObject
Given a key, value, and list, returns a copy of the list absent the object(s) which match said k/v pair.```js
var listUtils = require('alien-node-list-utils'),
list = [{ foo : 'bar'}, {baz : 'bat'}, {buz : 'but'}];
listUtils.filterOutObject('baz', 'bat', list); // [{ foo : 'bar'}, {buz : 'but'}]```
#### maybeDropLastItem
Given a qualifying drop length and a list, returns a new list who's last item is dropped if the list
length exceeds or equals provided drop length```js
var listUtils = require('alien-node-list-utils'),
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],
list2 = ['x', 'y', 'z'];listUtils.maybeDropLastItem(5, list1); // ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
listUtils.maybeDropLastItem(5, list2); // ['x', 'y', 'z']```
#### sortAsc
Simple ascending sorter function```js
var listUtils = require('alien-node-list-utils'),
list = ['b', 'd', 'a', 'c'];listUtils.sortAsc(list1); // ['a', 'b', 'c', 'd']
```
#### sortDesc
Simple descending sorter function```js
var listUtils = require('alien-node-list-utils'),
list = ['b', 'd', 'a', 'c'];listUtils.sortDesc(list1); // ['d', 'c', 'b', 'a']
```