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.

detect.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _createTester = require('./internal/createTester');
  6. var _createTester2 = _interopRequireDefault(_createTester);
  7. var _eachOf = require('./eachOf');
  8. var _eachOf2 = _interopRequireDefault(_eachOf);
  9. var _awaitify = require('./internal/awaitify');
  10. var _awaitify2 = _interopRequireDefault(_awaitify);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /**
  13. * Returns the first value in `coll` that passes an async truth test. The
  14. * `iteratee` is applied in parallel, meaning the first iteratee to return
  15. * `true` will fire the detect `callback` with that result. That means the
  16. * result might not be the first item in the original `coll` (in terms of order)
  17. * that passes the test.
  18. * If order within the original `coll` is important, then look at
  19. * [`detectSeries`]{@link module:Collections.detectSeries}.
  20. *
  21. * @name detect
  22. * @static
  23. * @memberOf module:Collections
  24. * @method
  25. * @alias find
  26. * @category Collections
  27. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  28. * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
  29. * The iteratee must complete with a boolean value as its result.
  30. * Invoked with (item, callback).
  31. * @param {Function} [callback] - A callback which is called as soon as any
  32. * iteratee returns `true`, or after all the `iteratee` functions have finished.
  33. * Result will be the first item in the array that passes the truth test
  34. * (iteratee) or the value `undefined` if none passed. Invoked with
  35. * (err, result).
  36. * @returns A Promise, if no callback is passed
  37. * @example
  38. *
  39. * async.detect(['file1','file2','file3'], function(filePath, callback) {
  40. * fs.access(filePath, function(err) {
  41. * callback(null, !err)
  42. * });
  43. * }, function(err, result) {
  44. * // result now equals the first file in the list that exists
  45. * });
  46. */
  47. function detect(coll, iteratee, callback) {
  48. return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
  49. }
  50. exports.default = (0, _awaitify2.default)(detect, 3);
  51. module.exports = exports['default'];