Skip to content

Commit

Permalink
Require Node.js 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 29, 2020
1 parent 4362c38 commit 58a4bf8
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ declare function pProps<
ValueType,
MappedValueType = pProps.PromiseResult<ValueType>
>(
map: Map<KeyType, ValueType>,
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
map: ReadonlyMap<KeyType, ValueType>,
mapper?: pProps.Mapper<pProps.PromiseResult<ValueType>, KeyType, MappedValueType>,
options?: pProps.Options
): Promise<Map<KeyType, MappedValueType>>;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const object = async (map, mapper, options) => {
return result;
};

// eslint-disable-next-line default-param-last
const pProps = (input, mapper = (value => value), options) => {
return input instanceof Map ?
map(input, mapper, options) :
Expand Down
11 changes: 6 additions & 5 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {expectType} from 'tsd';
import {expectType, expectAssignable} from 'tsd';
import pProps = require('.');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const options: pProps.Options = {};

expectType<Promise<{[key in 'foo']: string}>>(pProps({foo: 'bar'}));
Expand Down Expand Up @@ -36,7 +37,7 @@ expectType<Promise<{[key in 'unicorn' | 'foo']: string | number}>>(
expectType<Promise<{[key in 'unicorn' | 'foo']: boolean}>>(
pProps(hashMap, (value, key) => {
expectType<string | number>(value);
expectType<string>(key);
expectAssignable<string>(key);
return Math.random() > 0.5 ? false : Promise.resolve(true);
})
);
Expand All @@ -45,7 +46,7 @@ expectType<Promise<{[key in 'unicorn' | 'foo']: boolean}>>(
hashMap,
(value, key) => {
expectType<string | number>(value);
expectType<string>(key);
expectAssignable<string>(key);
return Math.random() > 0.5 ? false : Promise.resolve(true);
},
{
Expand All @@ -70,7 +71,7 @@ pProps(map).then(result => {
expectType<Promise<Map<number, string>>>(pProps(map));
expectType<Promise<Map<number, number>>>(
pProps(map, (value, key) => {
expectType<string | Promise<string>>(value);
expectType<string>(value);
expectType<number>(key);
return Math.random() > 0.5 ? 1 : Promise.resolve(2);
})
Expand All @@ -79,7 +80,7 @@ expectType<Promise<Map<number, number>>>(
pProps(
map,
(value, key) => {
expectType<string | Promise<string>>(value);
expectType<string>(value);
expectType<number>(key);
return Math.random() > 0.5 ? 1 : Promise.resolve(2);
},
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"description": "Like `Promise.all()` but for `Map` and `Object`",
"license": "MIT",
"repository": "sindresorhus/p-props",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd"
Expand Down Expand Up @@ -41,7 +42,7 @@
"devDependencies": {
"ava": "^2.0.0",
"delay": "^4.2.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"tsd": "^0.11.0",
"xo": "^0.30.0"
}
}
13 changes: 2 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# p-props [![Build Status](https://travis-ci.org/sindresorhus/p-props.svg?branch=master)](https://travis-ci.org/sindresorhus/p-props)
# p-props [![Build Status](https://travis-ci.com/sindresorhus/p-props.svg?branch=master)](https://travis-ci.com/sindresorhus/p-props)

> Like [`Promise.all()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) but for `Map` and `Object`
Useful when you need to run multiple promises concurrently and keep track of the fulfilled values by name.


## Install

```
$ npm install p-props
```


## Usage

```js
Expand Down Expand Up @@ -43,10 +41,9 @@ const got = require('got');
})();
```


## API

### pProps(map, [mapper], [options])
### pProps(map, mapper?, options?)

Returns a `Promise` that is fulfilled when all promises in `map` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is the same as `map`, but with a fulfilled version of each entry value, or the fulfilled value returned from `mapper`, if defined.

Expand All @@ -68,14 +65,8 @@ Type: `object`

See the [`p-map` options](https://github.com/sindresorhus/p-map#options).


## Related

- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
- [More…](https://github.com/sindresorhus/promise-fun)


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

0 comments on commit 58a4bf8

Please sign in to comment.