Custom id function
Description
Create the ability to give the function a custom function for generating the id value.
Template:
function(item, params) { ... }
Function parameters
item: item in arr
params: Object, infos from the addIdToArray(...)
Example
The value of id is the hash from the item.
const addIdToArray = require('addidtoarray');
const customIdFunction = (item, params) => {
return {id: hash(item)};
}
addIdToArray(['Jeff', 'Maria'], 'name', customIdFunction);
/*
* result:
* [ { id: 'jsoj23...4ecoe', name: 'Jeff'}, ... ]
*/
Custom id function
Description
Create the ability to give the function a custom function for generating the id value.
Template:
Function parameters
item: item in arr
params: Object, infos from the addIdToArray(...)
Example
The value of id is the hash from the item.