UNPKG

1.17 kBSource Map (JSON)View Raw
1{"version":3,"sources":["useDebouncedFn.js"],"names":["defaultOptions","leading","trailing","useDebouncedFn","fn","wait","options","dependencies","debounced"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA,IAAMA,cAAc,GAAG;AACrBC,EAAAA,OAAO,EAAE,KADY;AAErBC,EAAAA,QAAQ,EAAE;AAFW,CAAvB;;AAUA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,EAAD,EAA4D;AAAA,MAAvDC,IAAuD,uEAAhD,GAAgD;AAAA,MAA3CC,OAA2C,uEAAjCN,cAAiC;AAAA,MAAjBO,YAAiB;AACjF,MAAMC,SAAS,GAAG,wBAASJ,EAAT,EAAaC,IAAb,EAAmBC,OAAnB,CAAlB;AAEA,SAAO,wBAAYE,SAAZ,EAAuBD,YAAvB,CAAP;AACD,CAJD;;eAOeJ,c","sourcesContent":["import { useCallback } from 'react';\nimport debounce from 'lodash.debounce';\n\nconst defaultOptions = {\n leading: false,\n trailing: true,\n};\n\n/**\n * Accepts a function and returns a new debounced yet memoized version of that same function that delays\n * its invoking by the defined time.\n * If time is not defined, its default value will be 250ms.\n */\nconst useDebouncedFn = (fn, wait = 100, options = defaultOptions, dependencies) => {\n const debounced = debounce(fn, wait, options);\n\n return useCallback(debounced, dependencies);\n};\n\n\nexport default useDebouncedFn;\n"],"file":"useDebouncedFn.js"}
\No newline at end of file