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.d.ts 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. declare class AbortErrorClass extends Error {
  2. readonly name: 'AbortError';
  3. /**
  4. Abort pending execution. All unresolved promised are rejected with a `AbortError` error.
  5. */
  6. constructor();
  7. }
  8. type PromiseResolve<ValueType> = ValueType extends PromiseLike<infer ValueType> ? Promise<ValueType> : Promise<ValueType>;
  9. declare namespace pThrottle {
  10. type ThrottledFunction<Argument extends readonly unknown[], ReturnValue> = ((
  11. ...arguments: Argument
  12. ) => PromiseResolve<ReturnValue>) & {
  13. /**
  14. Whether future function calls should be throttled or count towards throttling thresholds.
  15. @default true
  16. */
  17. isEnabled: boolean;
  18. /**
  19. Abort pending executions. All unresolved promises are rejected with a `pThrottle.AbortError` error.
  20. */
  21. abort(): void;
  22. };
  23. interface Options {
  24. /**
  25. Maximum number of calls within an `interval`.
  26. */
  27. readonly limit: number;
  28. /**
  29. Timespan for `limit` in milliseconds.
  30. */
  31. readonly interval: number;
  32. /**
  33. Use a strict, more resource intensive, throttling algorithm. The default algorithm uses a windowed approach that will work correctly in most cases, limiting the total number of calls at the specified limit per interval window. The strict algorithm throttles each call individually, ensuring the limit is not exceeded for any interval.
  34. @default false
  35. */
  36. readonly strict?: boolean;
  37. }
  38. type AbortError = AbortErrorClass;
  39. }
  40. declare const pThrottle: {
  41. AbortError: typeof AbortErrorClass;
  42. /**
  43. [Throttle](https://css-tricks.com/debouncing-throttling-explained-examples/) promise-returning/async/normal functions.
  44. @returns A throttled version of `fn`.
  45. Both the `limit` and `interval` options must be specified.
  46. @example
  47. ```
  48. import pThrottle from 'p-throttle';
  49. const throttle = pThrottle({
  50. limit: 2,
  51. interval: 1000
  52. });
  53. const throttled = throttle(async index => {
  54. return index * 2;
  55. });
  56. for (let i = 1; i <= 6; i++) {
  57. throttled(i).then(console.log);
  58. }
  59. ```
  60. */
  61. (
  62. options: pThrottle.Options
  63. ): <Argument extends readonly unknown[], ReturnValue>(function_: (...arguments: Argument) => ReturnValue) => pThrottle.ThrottledFunction<Argument, ReturnValue>;
  64. };
  65. export = pThrottle;