UNPKG

2.44 kBSource Map (JSON)View Raw
1{"version":3,"file":"debounce.js","sourceRoot":"","sources":["src/debounce.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AAE7C,qCAA+E;AAC/E,6CAAmD;AAGnD,IAAM,SAAS,GAAG,0BAAgB,CAAC,uBAAuB,CACxD,IAAI,yBAAe,CAAC,QAAQ,EAAE,IAAI,gCAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAC1E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,kBAAyB,IAAa,EAAE,OAAyB;IAC/D,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,4BAEC;AACoB,4BAAQ;AAC7B,kBAAe,SAAS,CAAC","sourcesContent":["import debounce = require('lodash/debounce');\n\nimport { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';\nimport { PreValueApplicator } from './applicators';\nimport { DebounceOptions } from './shared';\n\nconst decorator = DecoratorFactory.createInstanceDecorator(\n new DecoratorConfig(debounce, new PreValueApplicator(), { setter: true })\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 * 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 * @Debounce(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 Debounce(wait?: number, options?: DebounceOptions): LodashDecorator {\n return decorator(wait, options);\n}\nexport { Debounce as debounce };\nexport default decorator;\n"]}
\No newline at end of file