Comparing version 5.0.0 to 6.0.0
@@ -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'; |
@@ -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]]); |
{ | ||
"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" | ||
} | ||
} |
@@ -9,5 +9,5 @@ # p-props | ||
```sh | ||
npm install p-props | ||
``` | ||
$ npm install p-props | ||
``` | ||
@@ -14,0 +14,0 @@ ## Usage |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6580
68
+ Addedp-map@6.0.0(transitive)
- Removedaggregate-error@4.0.1(transitive)
- Removedclean-stack@4.2.0(transitive)
- Removedescape-string-regexp@5.0.0(transitive)
- Removedindent-string@5.0.0(transitive)
- Removedp-map@5.5.0(transitive)
Updatedp-map@^6.0.0