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.1.2 to 2.2.0

8

dist/index.d.ts

@@ -7,2 +7,8 @@ /**

};
/**
* Map each value of an object with provided function, just like `Array.map`
*/
declare function mapObjectAsync<T extends Record<string | number | symbol, unknown>, MapFunction extends (value: T[keyof T], propName: keyof T, array: T[keyof T][]) => Promise<any>>(target: T, mapFunction: MapFunction): Promise<{
[key in keyof T]: Awaited<ReturnType<typeof mapFunction>>;
}>;
type KeyOfMap<M extends Map<unknown, unknown>> = M extends Map<infer K, unknown> ? K : never;

@@ -15,2 +21,2 @@ type ValueOfMap<M extends Map<unknown, unknown>> = M extends Map<unknown, infer V> ? V : never;

export { KeyOfMap, ValueOfMap, mapMap, mapObject };
export { type KeyOfMap, type ValueOfMap, mapMap, mapObject, mapObjectAsync };

@@ -7,2 +7,14 @@ function mapObject(target, mapFunction) {

}
async function mapObjectAsync(target, mapFunction) {
const entries = Object.entries(target);
const promises = entries.map(async ([key, value]) => {
const newValue = await mapFunction(value, key, target);
return [key, newValue];
});
const results = await Promise.all(promises);
return results.reduce((carry, [key, value]) => {
carry[key] = value;
return carry;
}, {});
}
function mapMap(target, mapFunction) {

@@ -15,2 +27,2 @@ return [...target.entries()].reduce((carry, [key, value], index, array) => {

export { mapMap, mapObject };
export { mapMap, mapObject, mapObjectAsync };

28

package.json
{
"name": "map-anything",
"version": "2.1.2",
"version": "2.2.0",
"description": "Array.map but for objects with good TypeScript support. A small and simple integration.",

@@ -35,15 +35,15 @@ "type": "module",

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"del-cli": "^5.0.0",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-tree-shaking": "^1.10.0",
"np": "^7.7.0",
"prettier": "^2.8.8",
"rollup": "^3.23.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"typescript": "^4.9.5",
"vitest": "^0.31.0"
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"del-cli": "^5.1.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-tree-shaking": "^1.12.0",
"np": "^8.0.4",
"prettier": "^3.1.0",
"rollup": "^4.5.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0",
"typescript": "^5.3.2",
"vitest": "^0.34.6"
},

@@ -50,0 +50,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

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