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.

index.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. const taskManager = require("./managers/tasks");
  3. const async_1 = require("./providers/async");
  4. const stream_1 = require("./providers/stream");
  5. const sync_1 = require("./providers/sync");
  6. const settings_1 = require("./settings");
  7. const utils = require("./utils");
  8. async function FastGlob(source, options) {
  9. assertPatternsInput(source);
  10. const works = getWorks(source, async_1.default, options);
  11. const result = await Promise.all(works);
  12. return utils.array.flatten(result);
  13. }
  14. // https://github.com/typescript-eslint/typescript-eslint/issues/60
  15. // eslint-disable-next-line no-redeclare
  16. (function (FastGlob) {
  17. function sync(source, options) {
  18. assertPatternsInput(source);
  19. const works = getWorks(source, sync_1.default, options);
  20. return utils.array.flatten(works);
  21. }
  22. FastGlob.sync = sync;
  23. function stream(source, options) {
  24. assertPatternsInput(source);
  25. const works = getWorks(source, stream_1.default, options);
  26. /**
  27. * The stream returned by the provider cannot work with an asynchronous iterator.
  28. * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
  29. * This affects performance (+25%). I don't see best solution right now.
  30. */
  31. return utils.stream.merge(works);
  32. }
  33. FastGlob.stream = stream;
  34. function generateTasks(source, options) {
  35. assertPatternsInput(source);
  36. const patterns = [].concat(source);
  37. const settings = new settings_1.default(options);
  38. return taskManager.generate(patterns, settings);
  39. }
  40. FastGlob.generateTasks = generateTasks;
  41. function isDynamicPattern(source, options) {
  42. assertPatternsInput(source);
  43. const settings = new settings_1.default(options);
  44. return utils.pattern.isDynamicPattern(source, settings);
  45. }
  46. FastGlob.isDynamicPattern = isDynamicPattern;
  47. function escapePath(source) {
  48. assertPatternsInput(source);
  49. return utils.path.escape(source);
  50. }
  51. FastGlob.escapePath = escapePath;
  52. })(FastGlob || (FastGlob = {}));
  53. function getWorks(source, _Provider, options) {
  54. const patterns = [].concat(source);
  55. const settings = new settings_1.default(options);
  56. const tasks = taskManager.generate(patterns, settings);
  57. const provider = new _Provider(settings);
  58. return tasks.map(provider.read, provider);
  59. }
  60. function assertPatternsInput(input) {
  61. const source = [].concat(input);
  62. const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
  63. if (!isValidSource) {
  64. throw new TypeError('Patterns must be a string (non empty) or an array of strings');
  65. }
  66. }
  67. module.exports = FastGlob;