From 58a4bf8b07e21ea9b6a916d788ca7d8415099a36 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 29 Apr 2020 12:41:05 +0800 Subject: [PATCH] Require Node.js 10 --- .travis.yml | 2 +- index.d.ts | 3 ++- index.js | 1 + index.test-d.ts | 11 ++++++----- license | 2 +- package.json | 9 +++++---- readme.md | 13 ++----------- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index f98fed0..9d7745e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '14' - '12' - '10' - - '8' diff --git a/index.d.ts b/index.d.ts index 5e5e0a3..e70a1af 100644 --- a/index.d.ts +++ b/index.d.ts @@ -52,7 +52,8 @@ declare function pProps< ValueType, MappedValueType = pProps.PromiseResult >( - map: Map, + // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types + map: ReadonlyMap, mapper?: pProps.Mapper, KeyType, MappedValueType>, options?: pProps.Options ): Promise>; diff --git a/index.js b/index.js index bd4dcea..1d1b704 100644 --- a/index.js +++ b/index.js @@ -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) : diff --git a/index.test-d.ts b/index.test-d.ts index 648d073..65b9c8d 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -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>(pProps({foo: 'bar'})); @@ -36,7 +37,7 @@ expectType>( expectType>( pProps(hashMap, (value, key) => { expectType(value); - expectType(key); + expectAssignable(key); return Math.random() > 0.5 ? false : Promise.resolve(true); }) ); @@ -45,7 +46,7 @@ expectType>( hashMap, (value, key) => { expectType(value); - expectType(key); + expectAssignable(key); return Math.random() > 0.5 ? false : Promise.resolve(true); }, { @@ -70,7 +71,7 @@ pProps(map).then(result => { expectType>>(pProps(map)); expectType>>( pProps(map, (value, key) => { - expectType>(value); + expectType(value); expectType(key); return Math.random() > 0.5 ? 1 : Promise.resolve(2); }) @@ -79,7 +80,7 @@ expectType>>( pProps( map, (value, key) => { - expectType>(value); + expectType(value); expectType(key); return Math.random() > 0.5 ? 1 : Promise.resolve(2); }, diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (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: diff --git a/package.json b/package.json index dc66318..90356c3 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" } } diff --git a/readme.md b/readme.md index 2b520c9..78f3f76 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -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. @@ -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)