javascriptnpm
v1.0.8
Published
To simplyfly small javascript functions.
Downloads
2
Readme
What is this?
To simplyfly small javascript functions.
Instalation
npm i javascriptnpm --save
Then...
import { updateObject, updateArray, shortArray, getIndexBy } from 'javascriptnpm';
let obj = {name:'Nimesh Deuja'}
let newObj = updateObject(obj, {age:'32'}) // return object {name:'Nimesh Deuja',age:'32'}
let arr = [{name:'Nimesh Deuja'}]
let newArr = updateArray(arr, {name:'Abhisekh Deuja'}) // return array [{name:'Nimesh Deuja'},{name:'Abhisekh Deuja'}]
let arr = [{name:'Nimesh Deuja'},{name:'Abhisekh Deuja'}]
let newArr = shortArray(arr, 'name', 'ASC') // return array [{name:'Abhisekh Deuja'},{name:'Nimesh Deuja'}]
let arr = [{name:'Abhisekh Deuja'},{name:'Nimesh Deuja'}]
let index = getIndexBy(arr, 'name', 'Nimesh Deuja') // return 1
let fullName = 'Nimesh Deuja'
let shortName = shortNameGenerate(fullName) // return 'ND'
Options
updateObject take 2 params, All params are mandatory.
- obj - object
- ObjectToAdd - Object to add in obj
updateArray take 2 params, All params are mandatory.
- arr - Array
- ObjectToAdd - Object to add in arr
shortArray take 3 params, All params are mandatory.
- arr - Array
- sortBy - 'string' key name that you want to short
- type - Take 'string' for ascending 'ASC' and for descending 'DESC'
getIndexBy take 3 params, All params are mandatory.
- arr - Array
- indexBy - 'string' key name that you want to get indexOf
- indexOf - 'string' value that you want to get index
shortNameGenerate take 1 params, All params are mandatory.
- name - - 'string' Full Name