@koine/utils 1.0.79 → 1.0.83

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/debounce.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { debounce as tsDebounce } from "ts-debounce";
2
+ export { type Options as DebounceOptions } from "ts-debounce";
3
+ export { type DebouncedFunction } from "ts-debounce";
4
+ /**
5
+ * Debounce function
6
+ *
7
+ * @category function
8
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
9
+ */
10
+ export declare const debounce: typeof tsDebounce;
11
+ export default debounce;
package/debounce.js ADDED
@@ -0,0 +1,9 @@
1
+ import { debounce as tsDebounce } from "ts-debounce";
2
+ /**
3
+ * Debounce function
4
+ *
5
+ * @category function
6
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
7
+ */
8
+ export var debounce = tsDebounce;
9
+ export default debounce;
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./clsx";
11
11
  export * from "./convertRange";
12
12
  export * from "./cookie";
13
13
  export * from "./createStorage";
14
+ export * from "./debounce";
14
15
  export * from "./decode";
15
16
  export * from "./Defer";
16
17
  export * from "./Emitter";
@@ -79,6 +80,7 @@ export * from "./matchSorter";
79
80
  export * from "./mergeObjects";
80
81
  export * from "./mergeUrlQueryParams";
81
82
  export * from "./moveSortableArrayItemByKey";
83
+ export * from "./navigateToHash";
82
84
  export * from "./navigateToHashParams";
83
85
  export * from "./navigateToMergedHashParams";
84
86
  export * from "./navigateToMergedParams";
@@ -108,6 +110,7 @@ export * from "./setCookie";
108
110
  export * from "./shuffle";
109
111
  export * from "./slugify";
110
112
  export * from "./swapMap";
113
+ export * from "./throttle";
111
114
  export * from "./titleCase";
112
115
  export * from "./toNumber";
113
116
  export * from "./toRgba";
package/index.js CHANGED
@@ -11,6 +11,7 @@ export * from "./clsx";
11
11
  export * from "./convertRange";
12
12
  export * from "./cookie";
13
13
  export * from "./createStorage";
14
+ export * from "./debounce";
14
15
  export * from "./decode";
15
16
  export * from "./Defer";
16
17
  export * from "./Emitter";
@@ -80,6 +81,7 @@ export * from "./matchSorter";
80
81
  export * from "./mergeObjects";
81
82
  export * from "./mergeUrlQueryParams";
82
83
  export * from "./moveSortableArrayItemByKey";
84
+ export * from "./navigateToHash";
83
85
  export * from "./navigateToHashParams";
84
86
  export * from "./navigateToMergedHashParams";
85
87
  export * from "./navigateToMergedParams";
@@ -110,6 +112,7 @@ export * from "./setCookie";
110
112
  export * from "./shuffle";
111
113
  export * from "./slugify";
112
114
  export * from "./swapMap";
115
+ export * from "./throttle";
113
116
  export * from "./titleCase";
114
117
  export * from "./toNumber";
115
118
  export * from "./toRgba";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * It updates the browser's location hash by replacing the history state.
3
+ * The non-silent standard way would simply be `location.hash = "#new-hash"`
4
+ *
5
+ * @category location
6
+ */
7
+ export declare function navigateToHash(hash?: string): void;
8
+ export default navigateToHash;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * It updates the browser's location hash by replacing the history state.
3
+ * The non-silent standard way would simply be `location.hash = "#new-hash"`
4
+ *
5
+ * @category location
6
+ */
7
+ export function navigateToHash(hash) {
8
+ if (hash === void 0) { hash = ""; }
9
+ var pathname = location.pathname, search = location.search;
10
+ history.replaceState(null, "", pathname + (search ? "?" + search : "") + "#" + hash);
11
+ }
12
+ export default navigateToHash;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debounce = void 0;
4
+ var ts_debounce_1 = require("ts-debounce");
5
+ /**
6
+ * Debounce function
7
+ *
8
+ * @category function
9
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
10
+ */
11
+ exports.debounce = ts_debounce_1.debounce;
12
+ exports.default = exports.debounce;
package/node/index.js CHANGED
@@ -14,6 +14,7 @@ tslib_1.__exportStar(require("./clsx"), exports);
14
14
  tslib_1.__exportStar(require("./convertRange"), exports);
15
15
  tslib_1.__exportStar(require("./cookie"), exports);
16
16
  tslib_1.__exportStar(require("./createStorage"), exports);
17
+ tslib_1.__exportStar(require("./debounce"), exports);
17
18
  tslib_1.__exportStar(require("./decode"), exports);
18
19
  tslib_1.__exportStar(require("./Defer"), exports);
19
20
  tslib_1.__exportStar(require("./Emitter"), exports);
@@ -83,6 +84,7 @@ tslib_1.__exportStar(require("./matchSorter"), exports);
83
84
  tslib_1.__exportStar(require("./mergeObjects"), exports);
84
85
  tslib_1.__exportStar(require("./mergeUrlQueryParams"), exports);
85
86
  tslib_1.__exportStar(require("./moveSortableArrayItemByKey"), exports);
87
+ tslib_1.__exportStar(require("./navigateToHash"), exports);
86
88
  tslib_1.__exportStar(require("./navigateToHashParams"), exports);
87
89
  tslib_1.__exportStar(require("./navigateToMergedHashParams"), exports);
88
90
  tslib_1.__exportStar(require("./navigateToMergedParams"), exports);
@@ -113,6 +115,7 @@ tslib_1.__exportStar(require("./setCookie"), exports);
113
115
  tslib_1.__exportStar(require("./shuffle"), exports);
114
116
  tslib_1.__exportStar(require("./slugify"), exports);
115
117
  tslib_1.__exportStar(require("./swapMap"), exports);
118
+ tslib_1.__exportStar(require("./throttle"), exports);
116
119
  tslib_1.__exportStar(require("./titleCase"), exports);
117
120
  tslib_1.__exportStar(require("./toNumber"), exports);
118
121
  tslib_1.__exportStar(require("./toRgba"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.navigateToHash = void 0;
4
+ /**
5
+ * It updates the browser's location hash by replacing the history state.
6
+ * The non-silent standard way would simply be `location.hash = "#new-hash"`
7
+ *
8
+ * @category location
9
+ */
10
+ function navigateToHash(hash) {
11
+ if (hash === void 0) { hash = ""; }
12
+ var pathname = location.pathname, search = location.search;
13
+ history.replaceState(null, "", pathname + (search ? "?" + search : "") + "#" + hash);
14
+ }
15
+ exports.navigateToHash = navigateToHash;
16
+ exports.default = navigateToHash;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throttle = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /**
6
+ * Throttle function (e.g. for resize / scroll handlers)
7
+ *
8
+ * @category function
9
+ * @see https://github.com/Mobius1/Rangeable/
10
+ */
11
+ function throttle(fn, limit, context) {
12
+ var wait;
13
+ return function () {
14
+ var args = [];
15
+ for (var _i = 0; _i < arguments.length; _i++) {
16
+ args[_i] = arguments[_i];
17
+ }
18
+ context = context || this;
19
+ if (!wait) {
20
+ fn.apply.apply(fn, tslib_1.__spreadArray([context], args, false));
21
+ wait = true;
22
+ return setTimeout(function () {
23
+ wait = false;
24
+ }, limit);
25
+ }
26
+ return;
27
+ };
28
+ }
29
+ exports.throttle = throttle;
30
+ exports.default = throttle;
package/package.json CHANGED
@@ -4,11 +4,12 @@
4
4
  "main": "./node/index.js",
5
5
  "typings": "./index.d.ts",
6
6
  "dependencies": {
7
+ "ts-debounce": "^4.0.0",
7
8
  "date-fns-tz": "^1.3.7",
8
9
  "tslib": "^2.4.0"
9
10
  },
10
11
  "peerDependencies": {},
11
- "version": "1.0.79",
12
+ "version": "1.0.83",
12
13
  "module": "./index.js",
13
14
  "types": "./index.d.ts"
14
15
  }
package/throttle.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Throttle function (e.g. for resize / scroll handlers)
3
+ *
4
+ * @category function
5
+ * @see https://github.com/Mobius1/Rangeable/
6
+ */
7
+ export declare function throttle<TFn extends Function, TContext>(fn: TFn, limit: number, context?: TContext): (this: TContext, ...args: any[]) => NodeJS.Timeout | undefined;
8
+ export default throttle;
package/throttle.js ADDED
@@ -0,0 +1,26 @@
1
+ import { __spreadArray } from "tslib";
2
+ /**
3
+ * Throttle function (e.g. for resize / scroll handlers)
4
+ *
5
+ * @category function
6
+ * @see https://github.com/Mobius1/Rangeable/
7
+ */
8
+ export function throttle(fn, limit, context) {
9
+ var wait;
10
+ return function () {
11
+ var args = [];
12
+ for (var _i = 0; _i < arguments.length; _i++) {
13
+ args[_i] = arguments[_i];
14
+ }
15
+ context = context || this;
16
+ if (!wait) {
17
+ fn.apply.apply(fn, __spreadArray([context], args, false));
18
+ wait = true;
19
+ return setTimeout(function () {
20
+ wait = false;
21
+ }, limit);
22
+ }
23
+ return;
24
+ };
25
+ }
26
+ export default throttle;