Skip to content

Creates a new functor with the results of calling a provided function on every element in the calling functor and its key

License

Notifications You must be signed in to change notification settings

WebForgeOSS/deep-map-with-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deep-map-with-key

Creates a new functor with the results of calling a provided function on every element in the calling functor and its key

tested with jest code style: prettier

Install

$ npm install deep-map-with-key

Usage

const { deepMapWithKey } = require("deep-map-with-key");

const double = (number) => number * 2;

const cart = {
  rice: 2,
    fruits: {
      apple: 4,
      orange: 8
    }
  }
};

deepMapWithKey(double, cart); //=> { rice: 4, fruits: { apple: 8, orange: 16 } }

API

deepMapWithKey ⇒ Object | Array

Creates a new functor with the results of calling a provided function on every element in the calling functor and its key

Returns: Object | Array - Returns a new value after applying rules
Sig: ((String, *) -> *) -> Object | Array -> Object | Array

Param Type Description
fn function The function to be called on every element of the input list
functor Object | Array The functor to iterate over

Example

const cart = { rice: 2, fruits: { apple: 4, orange: 8 } } };
const double = (number) => number * 2;
deepMapWithKey(double, cart); //=> { rice: 4, fruits: { apple: 8, orange: 16 } }

License

MIT © muceres

About

Creates a new functor with the results of calling a provided function on every element in the calling functor and its key

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published