@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 +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.modern.js +2 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/noop.d.ts +1 -0
- package/dist/throttle.d.ts +4 -0
- package/dist/types/AnyFunction.d.ts +1 -0
- package/dist/types/LiteralUnion.d.ts +4 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +3 -2
package/dist/index.cjs
ADDED
@@ -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"}
|
package/dist/index.d.ts
ADDED
@@ -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 @@
|
|
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 @@
|
|
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 {};
|
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.
|
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"
|