1.0.1 • Published 4 years ago

deep-map-with-key v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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

Build Status Coverage Status Maintainability Language grade: JavaScript 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

ParamTypeDescription
fnfunctionThe function to be called on every element of the input list
functorObject | ArrayThe 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 © saxjst

1.0.1

4 years ago

1.0.0

4 years ago