@wiggindev/utils 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ exports.noop=function(){},exports.throttle=function(t,n){var o,r;return function(){return o||(o=!0,setTimeout(function(){return o=!1},n),r=t.apply(void 0,[].slice.call(arguments))),r}};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/noop.ts","../src/throttle.ts"],"sourcesContent":["export const noop = () => undefined;\n","import { AnyFunction } from './types';\n\ntype ThrottledFunction<C extends AnyFunction> = (\n ...args: Parameters<C>\n) => ReturnType<C>;\n\nexport const throttle = <C extends AnyFunction>(\n callback: C,\n limit: number\n): ThrottledFunction<C> => {\n let waiting: boolean;\n let prev: ReturnType<C>;\n return (...args: Parameters<C>) => {\n if (!waiting) {\n waiting = true;\n setTimeout(() => (waiting = false), limit);\n prev = callback.apply(this, args) as ReturnType<C>;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return prev;\n };\n};\n"],"names":["callback","limit","waiting","prev","setTimeout","apply","slice","call","arguments"],"mappings":"aAAoB,8BCMI,SACpBA,EACAC,GAEA,IAAIC,EACAC,EACJ,OAAO,WAOH,OANKD,IACDA,GAAU,EACVE,WAAW,WAAA,OAAOF,GAAU,GAAQD,GACpCE,EAAOH,EAASK,aACnB,GAAAC,MAAAC,KAAAC,aAEML"}
@@ -0,0 +1,3 @@
1
+ export type { LiteralUnion, AnyFunction } from './types';
2
+ export { throttle } from './throttle';
3
+ export { noop } from './noop';
@@ -0,0 +1,2 @@
1
+ const t=(t,e)=>{let o,p;return(...r)=>(o||(o=!0,setTimeout(()=>o=!1,e),p=t.apply(void 0,r)),p)},e=()=>{};export{e as noop,t as throttle};
2
+ //# sourceMappingURL=index.modern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.modern.js","sources":["../src/throttle.ts","../src/noop.ts"],"sourcesContent":["import { AnyFunction } from './types';\n\ntype ThrottledFunction<C extends AnyFunction> = (\n ...args: Parameters<C>\n) => ReturnType<C>;\n\nexport const throttle = <C extends AnyFunction>(\n callback: C,\n limit: number\n): ThrottledFunction<C> => {\n let waiting: boolean;\n let prev: ReturnType<C>;\n return (...args: Parameters<C>) => {\n if (!waiting) {\n waiting = true;\n setTimeout(() => (waiting = false), limit);\n prev = callback.apply(this, args) as ReturnType<C>;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return prev;\n };\n};\n","export const noop = () => undefined;\n"],"names":["throttle","callback","limit","waiting","prev","args","setTimeout","apply","this","noop"],"mappings":"AAMaA,MAAAA,EAAW,CACpBC,EACAC,KAEA,IAAIC,EACAC,EACJ,MAAO,IAAIC,KACFF,IACDA,GAAU,EACVG,WAAW,IAAOH,GAAU,EAAQD,GACpCE,EAAOH,EAASM,WAAMC,EAAMH,IAGzBD,ICnBFK,EAAO"}
@@ -0,0 +1,2 @@
1
+ var n=function(n,t){var r,u;return function(){return r||(r=!0,setTimeout(function(){return r=!1},t),u=n.apply(void 0,[].slice.call(arguments))),u}},t=function(){};export{t as noop,n as throttle};
2
+ //# sourceMappingURL=index.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.js","sources":["../src/throttle.ts","../src/noop.ts"],"sourcesContent":["import { AnyFunction } from './types';\n\ntype ThrottledFunction<C extends AnyFunction> = (\n ...args: Parameters<C>\n) => ReturnType<C>;\n\nexport const throttle = <C extends AnyFunction>(\n callback: C,\n limit: number\n): ThrottledFunction<C> => {\n let waiting: boolean;\n let prev: ReturnType<C>;\n return (...args: Parameters<C>) => {\n if (!waiting) {\n waiting = true;\n setTimeout(() => (waiting = false), limit);\n prev = callback.apply(this, args) as ReturnType<C>;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return prev;\n };\n};\n","export const noop = () => undefined;\n"],"names":["throttle","callback","limit","waiting","prev","setTimeout","apply","slice","call","arguments","noop"],"mappings":"IAMaA,EAAW,SACpBC,EACAC,GAEA,IAAIC,EACAC,EACJ,OAAO,WAOH,OANKD,IACDA,GAAU,EACVE,WAAW,WAAA,OAAOF,GAAU,GAAQD,GACpCE,EAAOH,EAASK,aACnB,GAAAC,MAAAC,KAAAC,aAEML,ICnBFM,EAAO"}
@@ -0,0 +1,2 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).utils={})}(this,function(e){var n=void 0;e.noop=function(){},e.throttle=function(e,t){var o,i;return function(){return o||(o=!0,setTimeout(function(){return o=!1},t),i=e.apply(n,[].slice.call(arguments))),i}}});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/noop.ts","../src/throttle.ts"],"sourcesContent":["export const noop = () => undefined;\n","import { AnyFunction } from './types';\n\ntype ThrottledFunction<C extends AnyFunction> = (\n ...args: Parameters<C>\n) => ReturnType<C>;\n\nexport const throttle = <C extends AnyFunction>(\n callback: C,\n limit: number\n): ThrottledFunction<C> => {\n let waiting: boolean;\n let prev: ReturnType<C>;\n return (...args: Parameters<C>) => {\n if (!waiting) {\n waiting = true;\n setTimeout(() => (waiting = false), limit);\n prev = callback.apply(this, args) as ReturnType<C>;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return prev;\n };\n};\n"],"names":["callback","limit","waiting","prev","setTimeout","apply","_this","slice","call","arguments"],"mappings":"mPAAoB,wBCMI,SACpBA,EACAC,GAEA,IAAIC,EACAC,EACJ,OAAO,WAOH,OANKD,IACDA,GAAU,EACVE,WAAW,WAAA,OAAOF,GAAU,GAAQD,GACpCE,EAAOH,EAASK,MAAMC,EACzB,GAAAC,MAAAC,KAAAC,aAEMN"}
package/dist/noop.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const noop: () => undefined;
@@ -0,0 +1,4 @@
1
+ import { AnyFunction } from './types';
2
+ declare type ThrottledFunction<C extends AnyFunction> = (...args: Parameters<C>) => ReturnType<C>;
3
+ export declare const throttle: <C extends AnyFunction>(callback: C, limit: number) => ThrottledFunction<C>;
4
+ export {};
@@ -0,0 +1 @@
1
+ export declare type AnyFunction = (...args: any[]) => any;
@@ -0,0 +1,4 @@
1
+ /** from type-fest: https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts */
2
+ declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
3
+ export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
4
+ export {};
@@ -0,0 +1,2 @@
1
+ export type { LiteralUnion } from './LiteralUnion';
2
+ export type { AnyFunction } from './AnyFunction';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wiggindev/utils",
3
3
  "description": "Various utilities that I use in my projects",
4
- "version": "0.2.13",
4
+ "version": "0.2.14",
5
5
  "author": {
6
6
  "name": "Andrew Wiggin",
7
7
  "email": "andrew@wiggin.dev",
@@ -29,7 +29,8 @@
29
29
  "scripts": {
30
30
  "clean": "rm -rf dist",
31
31
  "build": "yarn clean && microbundle",
32
- "dev": "microbundle watch"
32
+ "dev": "microbundle watch",
33
+ "prepack": "yarn build"
33
34
  },
34
35
  "devDependencies": {
35
36
  "microbundle": "^0.15.0"