nav tabs on admin dashboard
This commit is contained in:
+8
-5
@@ -8,7 +8,10 @@ class EndError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
// the input can also be a promise, so we `Promise.all()` them both
|
||||
// The input can also be a promise, so we `Promise.resolve()` it
|
||||
const testElement = (el, tester) => Promise.resolve(el).then(tester);
|
||||
|
||||
// The input can also be a promise, so we `Promise.all()` them both
|
||||
const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0])));
|
||||
|
||||
module.exports = (iterable, tester, opts) => {
|
||||
@@ -19,13 +22,13 @@ module.exports = (iterable, tester, opts) => {
|
||||
|
||||
const limit = pLimit(opts.concurrency);
|
||||
|
||||
// start all the promises concurrently with optional limit
|
||||
const items = Array.from(iterable).map(el => [el, limit(() => Promise.resolve(el).then(tester))]);
|
||||
// Start all the promises concurrently with optional limit
|
||||
const items = [...iterable].map(el => [el, limit(testElement, el, tester)]);
|
||||
|
||||
// check the promises either serially or concurrently
|
||||
// Check the promises either serially or concurrently
|
||||
const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity);
|
||||
|
||||
return Promise.all(items.map(el => checkLimit(() => finder(el))))
|
||||
return Promise.all(items.map(el => checkLimit(finder, el)))
|
||||
.then(() => {})
|
||||
.catch(err => err instanceof EndError ? err.value : Promise.reject(err));
|
||||
};
|
||||
|
||||
+4
-16
@@ -1,21 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
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:
|
||||
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 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.
|
||||
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.
|
||||
|
||||
+14
-17
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"_from": "p-locate@^2.0.0",
|
||||
"_id": "p-locate@2.0.0",
|
||||
"_from": "p-locate@^3.0.0",
|
||||
"_id": "p-locate@3.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
|
||||
"_integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
|
||||
"_location": "/p-locate",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "p-locate@^2.0.0",
|
||||
"raw": "p-locate@^3.0.0",
|
||||
"name": "p-locate",
|
||||
"escapedName": "p-locate",
|
||||
"rawSpec": "^2.0.0",
|
||||
"rawSpec": "^3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
"fetchSpec": "^3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/locate-path"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
|
||||
"_shasum": "20a0103b222a70c8fd39cc2e580680f3dde5ec43",
|
||||
"_spec": "p-locate@^2.0.0",
|
||||
"_resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
|
||||
"_shasum": "322d69a05c0264b25997d9f40cd8a891ab0064a4",
|
||||
"_spec": "p-locate@^3.0.0",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\locate-path",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
@@ -32,19 +32,19 @@
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"p-limit": "^1.1.0"
|
||||
"p-limit": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Get the first fulfilled promise that satisfies the provided testing function",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"delay": "^1.3.1",
|
||||
"delay": "^3.0.0",
|
||||
"in-range": "^1.0.0",
|
||||
"time-span": "^1.0.0",
|
||||
"time-span": "^2.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
@@ -79,8 +79,5 @@
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "2.0.0",
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
"version": "3.0.0"
|
||||
}
|
||||
|
||||
+6
-4
@@ -8,7 +8,7 @@ Think of it like an async version of [`Array#find`](https://developer.mozilla.or
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save p-locate
|
||||
$ npm install p-locate
|
||||
```
|
||||
|
||||
|
||||
@@ -22,14 +22,16 @@ const pLocate = require('p-locate');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // only this one actually exists on disk
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
pLocate(files, file => pathExists(file)).then(foundPath => {
|
||||
(async () => {
|
||||
const foundPath = await pLocate(files, file => pathExists(file));
|
||||
|
||||
console.log(foundPath);
|
||||
//=> 'rainbow'
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
|
||||
|
||||
Reference in New Issue
Block a user