Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joeyism/node-jslib
A module that loads some modules that are useful in javascript
https://github.com/joeyism/node-jslib
Last synced: 5 days ago
JSON representation
A module that loads some modules that are useful in javascript
- Host: GitHub
- URL: https://github.com/joeyism/node-jslib
- Owner: joeyism
- Created: 2015-08-14T19:13:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-26T04:06:58.000Z (about 9 years ago)
- Last Synced: 2024-10-07T17:20:04.897Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/jslib
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JS Lib
A module that loads some modules that are useful in javascript, for objects and arrays
## Installation
> npm install --save jslib
## Usage
* [`xcept`](#xcep)
* [`kontains`](#kontains)
* [`keyway`](#keyway)
* [`isUnique`](#isUnique)
* [`getUnique`](#getUnique)### [xcept](https://github.com/joeyism/node-xcept)
**Object**
Omit object key-values
{ "a": "some value", "b": "other value", "c": "more value" }.omit(a).omit(c) // { "b": "other value" }
{ "a": "some value", "b": "other value", "c": "more value" }.except(a).except(c) // { "b": "other value" }**Array**
Omit array elements
[1, 2, 3, 4, 5].omit(1).omit(2).omit(3) // [4, 5]
[1, 2, 3, 4, 5].except(1).except(2).except(3) // [4, 5]### [kontains](https://github.com/joeyism/node-kontains)
**Object**
Checks if an object contains an element
{"elm1": "one", "elm2": "two"}.contains("elm1") // true
{"elm1": "one", "elm2": "two"}.contains("elm2") // true
{"elm1": "one", "elm2": "two"}.contains("one") // false
{"elm1": "one", "elm2": "two"}.contains("ELM2") // false**Array**
Checks if an array contains an element
[1, 2, 3].contains(1) // true
[1, 2, 3].contains(one) // false### [keyway](https://github.com/joeyism/node-keyway)
Transforms an array into an object
var arr = ["one", "two"];
obj = Array.keyway(arr) // obj = { "one": "", "two": ""}
obj = arr.keyway() // obj = { "one": "", "two": ""}### [isUnique](https://github.com/joeyism/node-isUnique)
Returns true if the array only has unique elements. Otherwise, return false[1].isUnique() // true
[1,2].isUnique() // true
[1,1].isUnique() // false### [getUnique](https://github.com/joeyism/node-isUnique)
Gets the unique version of the array. If there are two matching elements, the latter is removed[1].getUnique() // [1]
[1,1].getUnique() // [1]
[1,2].getUnique() // [1,2]
[1,2,1,2].getUnique() // [1,2]
[1,2,2,2].getUnique() // [1,2]## Versions
**1.1.0**
* added isUnique and getUnique**1.0.0**
* First working commit