Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. const aliasProperty = (source, target) => object => {
  2. object[target] = object[source];
  3. return object;
  4. };
  5.  
  6. // Example
  7.  
  8. const aliasIdToValue = aliasProperty('id', 'value');
  9.  
  10. aliasIdToValue({ id: 123, name: 'Hello' });
  11.  
  12. const categories = [
  13. { id: 123, name: 'Hello' },
  14. { id: 456, name: 'Bye' }
  15. ];
  16.  
  17. categories.map(aliasIdToValue);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement