Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # p-locate [![Build Status](https://travis-ci.org/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.org/sindresorhus/p-locate)
  2. > Get the first fulfilled promise that satisfies the provided testing function
  3. Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
  4. ## Install
  5. ```
  6. $ npm install p-locate
  7. ```
  8. ## Usage
  9. Here we find the first file that exists on disk, in array order.
  10. ```js
  11. const pathExists = require('path-exists');
  12. const pLocate = require('p-locate');
  13. const files = [
  14. 'unicorn.png',
  15. 'rainbow.png', // Only this one actually exists on disk
  16. 'pony.png'
  17. ];
  18. (async () => {
  19. const foundPath = await pLocate(files, file => pathExists(file));
  20. console.log(foundPath);
  21. //=> 'rainbow'
  22. })();
  23. ```
  24. *The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
  25. ## API
  26. ### pLocate(input, tester, [options])
  27. Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
  28. #### input
  29. Type: `Iterable<Promise | unknown>`
  30. An iterable of promises/values to test.
  31. #### tester(element)
  32. Type: `Function`
  33. This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
  34. #### options
  35. Type: `Object`
  36. ##### concurrency
  37. Type: `number`<br>
  38. Default: `Infinity`<br>
  39. Minimum: `1`
  40. Number of concurrently pending promises returned by `tester`.
  41. ##### preserveOrder
  42. Type: `boolean`<br>
  43. Default: `true`
  44. Preserve `input` order when searching.
  45. Disable this to improve performance if you don't care about the order.
  46. ## Related
  47. - [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
  48. - [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
  49. - [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled
  50. - [More…](https://github.com/sindresorhus/promise-fun)
  51. ## License
  52. MIT © [Sindre Sorhus](https://sindresorhus.com)