Manipulate your array into various output
$ npm install --save sd-array
const sdarray = require('sd-array');
let singleArray = ['a','b','a'];
let data = [
{
a : 2,
b : 2
},{
a : 1,
b : 3,
},{
a : 3,
b : 2
}
]
console.log(sdarray.uniqueSingleArray(singleArray)); // (array)
console.log(sdarray.uniqueArrayOfObject(data, 'b')) // (array , key)
console.log(sdarray.removeArrayByValue(singleArray,'a')) // (array, value)
Below are special / custom functions from this package
function | description | example | output |
---|---|---|---|
uniqueSingleArray(array) |
array -> return unique array |
[1,2,3,3,4,5,2] |
array ex : [1,3,4,5]
|
uniqueArrayOfObject(array, key) |
arrayOfObject ,key - > return unique array of object by key |
([{a : 1, b: 2 },{a: 1 , b : 3}],'b') |
arrayOfObject ex : [{a :1 , b:2}]
|
removeArrayByValue(array, value) |
array , value to remove -> return array with removed value |
(['a','b','c','d'],'c') |
array ex : ['a','b','d']
|
removeEmptyArray(array) |
array -> return array from null undefined or empty value |
[0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,] |
array ex : [0,1,2,3,3,4,4,5,6]
|
MIT © SDANALYZER