UNPKG

2.49 kBSource Map (JSON)View Raw
1{"version":3,"file":"debounceAll.js","sourceRoot":"","sources":["src/debounceAll.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AAE7C,qCAAqF;AACrF,6CAAmD;AAGnD,IAAM,SAAS,GAAG,0BAAgB,CAAC,eAAe,CAChD,IAAI,yBAAe,CAAC,QAAQ,EAAE,IAAI,gCAAkB,EAAE,CAAC,CACxD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAA4B,IAAa,EAAE,OAAyB;IAClE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,kCAEC;AACuB,kCAAW;AACnC,kBAAe,SAAS,CAAC","sourcesContent":["import debounce = require('lodash/debounce');\n\nimport { DecoratorConfig, DecoratorFactory, LodashMethodDecorator } from './factory';\nimport { PreValueApplicator } from './applicators';\nimport { DebounceOptions } from './shared';\n\nconst decorator = DecoratorFactory.createDecorator(\n new DecoratorConfig(debounce, new PreValueApplicator())\n);\n\n/**\n * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.\n * The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them.\n * Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function.\n * Subsequent calls to the debounced function return the result of the last func invocation.\n *\n * The debounce state is shared across all instances of the class.\n *\n * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.\n *\n * If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.\n *\n * @param {number} [wait=0] The number in milliseconds to delay.\n * @param {DebounceOptions} [options] The options object.\n * @example\n *\n * class MyClass {\n * value = 100;\n *\n * @DebounceAll(10)\n * add(a) {\n * this.value += a;\n * }\n * }\n *\n * const myClass = new MyClass();\n *\n * myClass.add(10);\n * myClass.add(50);\n * myClass.add(20);\n *\n * myClass.value; // => 100;\n *\n * setTimeout(() => {\n * myClass.value; // => 120;\n * }, 11);\n */\nexport function DebounceAll(wait?: number, options?: DebounceOptions): LodashMethodDecorator {\n return decorator(wait, options);\n}\nexport { DebounceAll as debounceAll };\nexport default decorator;\n"]}
\No newline at end of file