Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom id function #2

Closed
LetsMelon opened this issue Nov 2, 2020 · 3 comments
Closed

Custom id function #2

LetsMelon opened this issue Nov 2, 2020 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@LetsMelon
Copy link
Owner

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'}, ... ]
 */
@LetsMelon LetsMelon added the enhancement New feature or request label Nov 2, 2020
@LetsMelon LetsMelon added this to the v1.2.0 milestone Nov 3, 2020
@LetsMelon
Copy link
Owner Author

LetsMelon commented Nov 3, 2020

Development branch: develop

Todos:

  • add customIdFunction as parameter
  • write tests
  • write into README.md + example
  • change CHANGELOG.md

@LetsMelon
Copy link
Owner Author

customIdFunction not in the table at Usage/Parameter in README.md

@LetsMelon
Copy link
Owner Author

2020-11-04: See changes in branch 'develop' or in CHANGELOGS.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant