Object

delProps

delProps ( value, item ) > Object

value maybe a string or an array string. Return a new instance of item without declared values

const item = { name: 'Gandalf', age: 'unknow', type: 'magical', weapon: undefined }
const item1 = delProps('type', item) //return { name: 'Gandalf', age: 'unknow', weapon: undefined }
const item2 = delProps(['type', 'age', 'weapon'], item) //return { name: 'Gandalf'}
const deletedProps = delProps(['type', 'weapon'])
deletedProps(item) //return  {name: 'Gandalf', age: 'unknow'}

extract

extract( props, item ) > Object value maybe a string or an array string. Return a new instance of item with declared values

const item = { name: 'Gandalf', age: 'unknow', type: 'magical', weapon: undefined }
const item1 = extract('type', item) //return { type: 'magical' }
const item2 = extract(['type', 'age', 'weapon'], item) //return{ age: 'unknow', type: 'magical', weapon: undefined }
const extractProps = extract(['type', 'weapon'])
extractProps(item) //return  {type: 'magical', weapon: undefined }

getProps

getProps( values, item ) > Any | Array

get values of object. Values can be a string or a String Array.

const item = { name: 'Gandalf', age: 'unknow', type: 'magical', weapon: undefined }
getProps('name', item)).toBe('Gandalf') //return 'Gandalf'
getProps([ 'name', 'age', 'weapon' ], item) //return [ 'Gandalf', 'unknow', undefined ])

has

has( value ) > Boolean

return true if object has value

const item = { name: 'Gandalf', age: 'unknow' }
has('name', item) //return true
has('attack', item) //return false

merge

merge(item1, item2) > Object | Array

merge two object or array

const item = { name: 'Gandalf', age: 'unknow' }
const weapon = { type: 'magic' }
merge(item, weapon) //return { name: 'Gandalf', age: 'unknow', type: 'magic' }

mergeAll

mergeAll( array) > Object

merge all object in array

const items = [ { name: 'Gandalf', age: 'unknow' }, { type: 'magic' } ]
mergeAll(items) //return { name: 'Gandalf', age: 'unknow', type: 'magic' }

modify

modify(property, value, item) > Object

change object property

const item = { name: 'Gandalf', age: 'unknow' }
modify('name', 'Sauron', item) //return { name: 'Sauron', age: 'unknow' }

export { default as has } from './has' export { default as getProps } from './getProps' export { default as delProps } from './delProps' export { default as modify } from './modify' export { default as merge } from './merge' export { default as mergeAll } from './mergeAll'