+18
-13
@@ -1,5 +0,3 @@ | ||
| import {Options} from 'p-map'; | ||
| import {type Options} from 'p-map'; | ||
| export type PromiseResult<Value> = Value extends PromiseLike<infer Result> ? Result : Value; | ||
| export type Mapper<ValueType, KeyType, MappedValueType> = ( | ||
@@ -44,21 +42,28 @@ value: ValueType, | ||
| */ | ||
| export default function pProps< | ||
| KeyType, | ||
| ValueType, | ||
| MappedValueType = PromiseResult<ValueType> | ||
| export default function pProps< // This overload exists to get more accurate results when the mapper is not defined. | ||
| InputType extends Record<PropertyKey, unknown>, | ||
| >( | ||
| map: ReadonlyMap<KeyType, ValueType>, | ||
| mapper?: Mapper<PromiseResult<ValueType>, KeyType, MappedValueType>, | ||
| map: InputType, | ||
| mapper?: undefined, | ||
| options?: Options | ||
| ): Promise<Map<KeyType, MappedValueType>>; | ||
| ): Promise<{[key in keyof InputType]: Awaited<InputType[key]>}>; | ||
| export default function pProps< | ||
| InputType extends Record<string, any>, | ||
| InputType extends Record<string, unknown>, | ||
| ValueType extends InputType[keyof InputType], | ||
| MappedValueType = PromiseResult<ValueType> | ||
| MappedValueType = Awaited<ValueType>, | ||
| >( | ||
| map: InputType, | ||
| mapper?: Mapper<PromiseResult<ValueType>, keyof InputType, MappedValueType>, | ||
| mapper?: Mapper<Awaited<ValueType>, keyof InputType, MappedValueType>, | ||
| options?: Options | ||
| ): Promise<{[key in keyof InputType]: MappedValueType}>; | ||
| export default function pProps< | ||
| KeyType, | ||
| ValueType, | ||
| MappedValueType = Awaited<ValueType>, | ||
| >( | ||
| map: ReadonlyMap<KeyType, ValueType>, | ||
| mapper?: Mapper<Awaited<ValueType>, KeyType, MappedValueType>, | ||
| options?: Options | ||
| ): Promise<Map<KeyType, MappedValueType>>; | ||
| export {Options} from 'p-map'; |
+1
-1
@@ -5,3 +5,3 @@ import pMap from 'p-map'; | ||
| const isMap = input instanceof Map; | ||
| const entries = isMap ? [...input.entries()] : Object.entries(input); | ||
| const entries = isMap ? [...input] : Object.entries(input); | ||
| const values = await pMap(entries, async ([key, value]) => mapper(await value, key), options); | ||
@@ -8,0 +8,0 @@ const mappedEntries = entries.map(([key], index) => [key, values[index]]); |
+11
-8
| { | ||
| "name": "p-props", | ||
| "version": "5.0.0", | ||
| "version": "6.0.0", | ||
| "description": "Like `Promise.all()` but for `Map` and `Object`", | ||
@@ -14,5 +14,8 @@ "license": "MIT", | ||
| "type": "module", | ||
| "exports": "./index.js", | ||
| "exports": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.js" | ||
| }, | ||
| "engines": { | ||
| "node": ">=12.20" | ||
| "node": ">=18" | ||
| }, | ||
@@ -43,10 +46,10 @@ "scripts": { | ||
| "dependencies": { | ||
| "p-map": "^5.0.0" | ||
| "p-map": "^6.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "ava": "^3.15.0", | ||
| "delay": "^5.0.0", | ||
| "tsd": "^0.17.0", | ||
| "xo": "^0.40.2" | ||
| "ava": "^5.3.1", | ||
| "delay": "^6.0.0", | ||
| "tsd": "^0.29.0", | ||
| "xo": "^0.56.0" | ||
| } | ||
| } |
+2
-2
@@ -9,5 +9,5 @@ # p-props | ||
| ```sh | ||
| npm install p-props | ||
| ``` | ||
| $ npm install p-props | ||
| ``` | ||
@@ -14,0 +14,0 @@ ## Usage |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
6580
3.38%68
9.68%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated