mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
66
node_modules/p-map-series/index.d.ts
generated
vendored
Normal file
66
node_modules/p-map-series/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
declare const pMapSeries: {
|
||||
/**
|
||||
Map over promises serially.
|
||||
|
||||
@param input - Mapped over serially in the `mapper` function.
|
||||
@param mapper - Expected to return a value. If it's a `Promise`, it's awaited before continuing with the next iteration.
|
||||
@returns Fulfills when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject.
|
||||
|
||||
@example
|
||||
```
|
||||
import pMapSeries = require('p-map-series');
|
||||
|
||||
const keywords = [
|
||||
getTopKeyword() //=> Promise
|
||||
'rainbow',
|
||||
'pony'
|
||||
];
|
||||
|
||||
let scores = [];
|
||||
|
||||
const mapper = async keyword => {
|
||||
const score = await fetchScore(keyword);
|
||||
scores.push(score);
|
||||
return {keyword, score};
|
||||
});
|
||||
|
||||
(async () => {
|
||||
console.log(await pMapSeries(keywords, mapper));
|
||||
// [
|
||||
// {
|
||||
// keyword: 'unicorn',
|
||||
// score: 99
|
||||
// },
|
||||
// {
|
||||
// keyword: 'rainbow',
|
||||
// score: 70
|
||||
// },
|
||||
// {
|
||||
// keyword: 'pony',
|
||||
// score: 79
|
||||
// }
|
||||
// ]
|
||||
})();
|
||||
```
|
||||
*/
|
||||
<ValueType, MappedValueType>(
|
||||
input: Iterable<PromiseLike<ValueType> | ValueType>,
|
||||
mapper: (
|
||||
element: ValueType,
|
||||
index: number
|
||||
) => PromiseLike<MappedValueType> | MappedValueType
|
||||
): Promise<MappedValueType[]>;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function pMapSeries<ValueType, MappedValueType>(
|
||||
// input: Iterable<PromiseLike<ValueType> | ValueType>,
|
||||
// mapper: (
|
||||
// element: ValueType,
|
||||
// index: number
|
||||
// ) => PromiseLike<MappedValueType> | MappedValueType
|
||||
// ): Promise<MappedValueType[]>;
|
||||
// export = pMapSeries;
|
||||
default: typeof pMapSeries;
|
||||
};
|
||||
|
||||
export = pMapSeries;
|
||||
17
node_modules/p-map-series/index.js
generated
vendored
Normal file
17
node_modules/p-map-series/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const pMapSeries = async (iterable, mapper) => {
|
||||
const result = [];
|
||||
let index = 0;
|
||||
|
||||
for (const value of iterable) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
result.push(await mapper(await value, index++));
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = pMapSeries;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = pMapSeries;
|
||||
9
node_modules/p-map-series/license
generated
vendored
Normal file
9
node_modules/p-map-series/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
79
node_modules/p-map-series/package.json
generated
vendored
Normal file
79
node_modules/p-map-series/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"p-map-series@2.1.0",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "p-map-series@2.1.0",
|
||||
"_id": "p-map-series@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-dWDUxFLZ2gwH5pL9v+biyBoqkfI=",
|
||||
"_location": "/p-map-series",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "p-map-series@2.1.0",
|
||||
"name": "p-map-series",
|
||||
"escapedName": "p-map-series",
|
||||
"rawSpec": "2.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vite"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/p-map-series/-/p-map-series-2.1.0.tgz",
|
||||
"_spec": "2.1.0",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/p-map-series/issues"
|
||||
},
|
||||
"description": "Map over promises serially",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"delay": "^4.1.0",
|
||||
"time-span": "^3.0.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/p-map-series#readme",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"map",
|
||||
"collection",
|
||||
"iterable",
|
||||
"iterator",
|
||||
"fulfilled",
|
||||
"serial",
|
||||
"serially",
|
||||
"async",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "p-map-series",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/p-map-series.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "2.1.0"
|
||||
}
|
||||
85
node_modules/p-map-series/readme.md
generated
vendored
Normal file
85
node_modules/p-map-series/readme.md
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
# p-map-series [](https://travis-ci.org/sindresorhus/p-map-series)
|
||||
|
||||
> Map over promises serially
|
||||
|
||||
Useful as a side-effect mapper. Use [`p-map`](https://github.com/sindresorhus/p-map) if you don't need side-effects, as it's concurrent.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install p-map-series
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const pMapSeries = require('p-map-series');
|
||||
|
||||
const keywords = [
|
||||
getTopKeyword() //=> Promise
|
||||
'rainbow',
|
||||
'pony'
|
||||
];
|
||||
|
||||
let scores = [];
|
||||
|
||||
const mapper = async keyword => {
|
||||
const score = await fetchScore(keyword);
|
||||
scores.push(score);
|
||||
return {keyword, score};
|
||||
});
|
||||
|
||||
(async () => {
|
||||
console.log(await pMapSeries(keywords, mapper));
|
||||
/*
|
||||
[
|
||||
{
|
||||
keyword: 'unicorn',
|
||||
score: 99
|
||||
},
|
||||
{
|
||||
keyword: 'rainbow',
|
||||
score: 70
|
||||
},
|
||||
{
|
||||
keyword: 'pony',
|
||||
score: 79
|
||||
}
|
||||
]
|
||||
*/
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pMapSeries(input, mapper)
|
||||
|
||||
Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the `mapper` created promises fulfillment values.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<Promise | unknown>`
|
||||
|
||||
Mapped over serially in the `mapper` function.
|
||||
|
||||
#### mapper(element, index)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Expected to return a value. If it's a `Promise`, it's awaited before continuing with the next iteration.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [p-each-series](https://github.com/sindresorhus/p-each-series) - Iterate over promises serially
|
||||
- [p-reduce](https://github.com/sindresorhus/p-reduce) - Reduce a list of values using promises into a promise for a value
|
||||
- [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)
|
||||
Reference in New Issue
Block a user