Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

map-anything

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-anything - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

16

dist/index.es.js
/**
* Map each value of an object with provided function, just like `Array.map`
*
* @template T
* @param {T} target
* @param {(value: T, propName: keyof T, array: T[keyof T][]) => any} mapFunction
* @returns {Record<string, any>}
*/

@@ -15,3 +10,12 @@ function mapObject(target, mapFunction) {

}
/**
* Map each value of a map with provided function, just like `Array.map`
*/
function mapMap(target, mapFunction) {
return [...target.entries()].reduce((carry, [key, value], index, array) => {
carry.set(key, mapFunction(value, key, array));
return carry;
}, new Map());
}
export { mapObject };
export { mapMap, mapObject };
/**
* Map each value of an object with provided function, just like `Array.map`
*
* @template T
* @param {T} target
* @param {(value: T, propName: keyof T, array: T[keyof T][]) => any} mapFunction
* @returns {Record<string, any>}
*/
export declare function mapObject<T extends Record<string, any>, MapFunction extends (value: T[keyof T], propName: keyof T, array: T[keyof T][]) => any>(target: T, mapFunction: MapFunction): {
export declare function mapObject<T extends Record<string | number | symbol, unknown>, MapFunction extends (value: T[keyof T], propName: keyof T, array: T[keyof T][]) => any>(target: T, mapFunction: MapFunction): {
[key in keyof T]: ReturnType<typeof mapFunction>;
};
export declare type KeyOfMap<M extends Map<unknown, unknown>> = M extends Map<infer K, unknown> ? K : never;
export declare type ValueOfMap<M extends Map<unknown, unknown>> = M extends Map<unknown, infer V> ? V : never;
/**
* Map each value of a map with provided function, just like `Array.map`
*/
export declare function mapMap<T extends Map<unknown, unknown>, MapFunction extends (value: ValueOfMap<T>, propName: KeyOfMap<T>, array: ValueOfMap<T>[]) => any>(target: T, mapFunction: MapFunction): Map<KeyOfMap<T>, ReturnType<typeof mapFunction>>;

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "2.0.2",
"version": "2.1.0",
"description": "Array.map but for objects with good TypeScript support. A small and simple integration.",

@@ -8,0 +8,0 @@ "module": "./dist/index.es.js",

@@ -33,11 +33,16 @@ # Map anything 🗺

## Meet the family
## Meet the family (more tiny utils with TS support)
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
- [is-what 🙉](https://github.com/mesqueeb/is-what)
- [is-where 🙈](https://github.com/mesqueeb/is-where)
- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
- [check-anything 👁](https://github.com/mesqueeb/check-anything)
- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)
- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)
- [map-anything 🗺](https://github.com/mesqueeb/map-anything)
- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
- [find-and-replace-anything 🎣](https://github.com/mesqueeb/find-and-replace-anything)
- [compare-anything 🛰](https://github.com/mesqueeb/compare-anything)
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
- [case-anything 🐫](https://github.com/mesqueeb/case-anything)
- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
- [is-what 🙉](https://github.com/mesqueeb/is-what)
- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)

@@ -44,0 +49,0 @@ ## Usage

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc