@emuanalytics/flow-rdf-core 0.0.15
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/README.md +64 -0
- package/dist/flow-rdf-core.css +1 -0
- package/dist/index.cjs +3102 -0
- package/dist/index.d.cts +61 -0
- package/dist/index.d.mts +61 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.mjs +3062 -0
- package/dist/lib/map/plugins/index.cjs +1652 -0
- package/dist/lib/map/plugins/index.d.cts +309 -0
- package/dist/lib/map/plugins/index.d.mts +309 -0
- package/dist/lib/map/plugins/index.d.ts +309 -0
- package/dist/lib/map/plugins/index.mjs +1614 -0
- package/dist/lib/utils/index.cjs +45 -0
- package/dist/lib/utils/index.d.cts +39 -0
- package/dist/lib/utils/index.d.mts +39 -0
- package/dist/lib/utils/index.d.ts +39 -0
- package/dist/lib/utils/index.mjs +5 -0
- package/dist/shared/flow-rdf-core.08975378.d.cts +68 -0
- package/dist/shared/flow-rdf-core.08975378.d.mts +68 -0
- package/dist/shared/flow-rdf-core.08975378.d.ts +68 -0
- package/dist/shared/flow-rdf-core.278a260a.cjs +1364 -0
- package/dist/shared/flow-rdf-core.2e456f93.mjs +83 -0
- package/dist/shared/flow-rdf-core.3042be4a.cjs +93 -0
- package/dist/shared/flow-rdf-core.84eded74.cjs +34 -0
- package/dist/shared/flow-rdf-core.b4b16e78.mjs +1329 -0
- package/dist/shared/flow-rdf-core.b80085b4.mjs +66 -0
- package/dist/shared/flow-rdf-core.bd95d618.mjs +29 -0
- package/dist/shared/flow-rdf-core.c44cf082.cjs +88 -0
- package/dist/shared/flow-rdf-core.c9d2f730.d.cts +1815 -0
- package/dist/shared/flow-rdf-core.c9d2f730.d.mts +1815 -0
- package/dist/shared/flow-rdf-core.c9d2f730.d.ts +1815 -0
- package/package.json +106 -0
- package/plugins/package.json +7 -0
- package/utils/package.json +7 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const stringUtils = require('../../shared/flow-rdf-core.3042be4a.cjs');
|
|
4
|
+
const featureTypeChecks = require('../../shared/flow-rdf-core.84eded74.cjs');
|
|
5
|
+
const functional = require('../../shared/flow-rdf-core.c44cf082.cjs');
|
|
6
|
+
const lit = require('lit-html');
|
|
7
|
+
require('@turf/invariant');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.capitalize = stringUtils.capitalize;
|
|
12
|
+
exports.ensureArray = stringUtils.ensureArray;
|
|
13
|
+
exports.hasLength = stringUtils.hasLength;
|
|
14
|
+
exports.hasValue = stringUtils.hasValue;
|
|
15
|
+
exports.isArray = stringUtils.isArray;
|
|
16
|
+
exports.isArrayFull = stringUtils.isArrayFull;
|
|
17
|
+
exports.isArrayStrings = stringUtils.isArrayStrings;
|
|
18
|
+
exports.isBoolean = stringUtils.isBoolean;
|
|
19
|
+
exports.isDate = stringUtils.isDate;
|
|
20
|
+
exports.isDefined = stringUtils.isDefined;
|
|
21
|
+
exports.isFalse = stringUtils.isFalse;
|
|
22
|
+
exports.isFunction = stringUtils.isFunction;
|
|
23
|
+
exports.isIn = stringUtils.isIn;
|
|
24
|
+
exports.isNil = stringUtils.isNil;
|
|
25
|
+
exports.isNull = stringUtils.isNull;
|
|
26
|
+
exports.isNumber = stringUtils.isNumber;
|
|
27
|
+
exports.isNumeric = stringUtils.isNumeric;
|
|
28
|
+
exports.isObject = stringUtils.isObject;
|
|
29
|
+
exports.isObjectFull = stringUtils.isObjectFull;
|
|
30
|
+
exports.isPlainObject = stringUtils.isPlainObject;
|
|
31
|
+
exports.isString = stringUtils.isString;
|
|
32
|
+
exports.isStringFull = stringUtils.isStringFull;
|
|
33
|
+
exports.isTrue = stringUtils.isTrue;
|
|
34
|
+
exports.isURL = stringUtils.isURL;
|
|
35
|
+
exports.isUndefined = stringUtils.isUndefined;
|
|
36
|
+
exports.isValue = stringUtils.isValue;
|
|
37
|
+
exports.isLineString = featureTypeChecks.isLineString;
|
|
38
|
+
exports.isMultiPolygon = featureTypeChecks.isMultiPolygon;
|
|
39
|
+
exports.isPoint = featureTypeChecks.isPoint;
|
|
40
|
+
exports.isPolygon = featureTypeChecks.isPolygon;
|
|
41
|
+
exports.debounce = functional.debounce;
|
|
42
|
+
exports.debounceWithArgs = functional.debounceWithArgs;
|
|
43
|
+
exports.memoize = functional.memoize;
|
|
44
|
+
exports.throttle = functional.throttle;
|
|
45
|
+
exports.html = lit.html;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as GeoJSON from 'geojson';
|
|
2
|
+
export { d as debounce, a as debounceWithArgs, m as memoize, t as throttle } from '../../shared/flow-rdf-core.08975378.cjs';
|
|
3
|
+
export { html } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
declare const isUndefined: (val: unknown) => val is undefined;
|
|
6
|
+
declare const isNull: (val: unknown) => val is null;
|
|
7
|
+
declare const isNil: (val: unknown) => val is null | undefined;
|
|
8
|
+
declare const isDefined: <T>(val: T) => val is Exclude<T, null | undefined>;
|
|
9
|
+
declare const isString: (val: unknown) => val is string;
|
|
10
|
+
declare const hasLength: (val: unknown) => boolean;
|
|
11
|
+
declare const isStringFull: (val: unknown) => val is string;
|
|
12
|
+
declare const isArray: (val: unknown) => val is unknown[];
|
|
13
|
+
declare const isArrayFull: (val: unknown) => val is unknown[];
|
|
14
|
+
declare const isArrayStrings: (val: unknown) => val is string[];
|
|
15
|
+
declare const isObject: (val: unknown) => val is object;
|
|
16
|
+
declare const isObjectFull: (val: unknown) => boolean;
|
|
17
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
18
|
+
declare const isFalse: (val: unknown) => val is false;
|
|
19
|
+
declare const isTrue: (val: unknown) => val is true;
|
|
20
|
+
declare const isIn: (val: unknown, arr: any[]) => boolean;
|
|
21
|
+
declare const isBoolean: (val: unknown) => val is boolean;
|
|
22
|
+
declare const isNumeric: (val: unknown) => boolean;
|
|
23
|
+
declare const isDate: (val: unknown) => val is Date;
|
|
24
|
+
declare const isValue: (val: unknown) => boolean;
|
|
25
|
+
declare const hasValue: (val: unknown) => boolean;
|
|
26
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
27
|
+
declare function isPlainObject(o: unknown): boolean;
|
|
28
|
+
declare function isURL(val: unknown): val is string;
|
|
29
|
+
|
|
30
|
+
declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
|
|
31
|
+
|
|
32
|
+
declare const isPoint: (val: unknown) => val is GeoJSON.Point | GeoJSON.Feature<GeoJSON.Point, GeoJSON.GeoJsonProperties>;
|
|
33
|
+
declare const isLineString: (val: any) => val is GeoJSON.LineString | GeoJSON.Feature<GeoJSON.LineString, GeoJSON.GeoJsonProperties>;
|
|
34
|
+
declare const isPolygon: (val: any) => val is GeoJSON.Polygon | GeoJSON.Feature<GeoJSON.Polygon, GeoJSON.GeoJsonProperties>;
|
|
35
|
+
declare const isMultiPolygon: (val: any) => val is GeoJSON.MultiPolygon | GeoJSON.Feature<GeoJSON.MultiPolygon, GeoJSON.GeoJsonProperties>;
|
|
36
|
+
|
|
37
|
+
declare const capitalize: (str: string, lowerRest?: boolean) => string;
|
|
38
|
+
|
|
39
|
+
export { capitalize, ensureArray, hasLength, hasValue, isArray, isArrayFull, isArrayStrings, isBoolean, isDate, isDefined, isFalse, isFunction, isIn, isLineString, isMultiPolygon, isNil, isNull, isNumber, isNumeric, isObject, isObjectFull, isPlainObject, isPoint, isPolygon, isString, isStringFull, isTrue, isURL, isUndefined, isValue };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as GeoJSON from 'geojson';
|
|
2
|
+
export { d as debounce, a as debounceWithArgs, m as memoize, t as throttle } from '../../shared/flow-rdf-core.08975378.mjs';
|
|
3
|
+
export { html } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
declare const isUndefined: (val: unknown) => val is undefined;
|
|
6
|
+
declare const isNull: (val: unknown) => val is null;
|
|
7
|
+
declare const isNil: (val: unknown) => val is null | undefined;
|
|
8
|
+
declare const isDefined: <T>(val: T) => val is Exclude<T, null | undefined>;
|
|
9
|
+
declare const isString: (val: unknown) => val is string;
|
|
10
|
+
declare const hasLength: (val: unknown) => boolean;
|
|
11
|
+
declare const isStringFull: (val: unknown) => val is string;
|
|
12
|
+
declare const isArray: (val: unknown) => val is unknown[];
|
|
13
|
+
declare const isArrayFull: (val: unknown) => val is unknown[];
|
|
14
|
+
declare const isArrayStrings: (val: unknown) => val is string[];
|
|
15
|
+
declare const isObject: (val: unknown) => val is object;
|
|
16
|
+
declare const isObjectFull: (val: unknown) => boolean;
|
|
17
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
18
|
+
declare const isFalse: (val: unknown) => val is false;
|
|
19
|
+
declare const isTrue: (val: unknown) => val is true;
|
|
20
|
+
declare const isIn: (val: unknown, arr: any[]) => boolean;
|
|
21
|
+
declare const isBoolean: (val: unknown) => val is boolean;
|
|
22
|
+
declare const isNumeric: (val: unknown) => boolean;
|
|
23
|
+
declare const isDate: (val: unknown) => val is Date;
|
|
24
|
+
declare const isValue: (val: unknown) => boolean;
|
|
25
|
+
declare const hasValue: (val: unknown) => boolean;
|
|
26
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
27
|
+
declare function isPlainObject(o: unknown): boolean;
|
|
28
|
+
declare function isURL(val: unknown): val is string;
|
|
29
|
+
|
|
30
|
+
declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
|
|
31
|
+
|
|
32
|
+
declare const isPoint: (val: unknown) => val is GeoJSON.Point | GeoJSON.Feature<GeoJSON.Point, GeoJSON.GeoJsonProperties>;
|
|
33
|
+
declare const isLineString: (val: any) => val is GeoJSON.LineString | GeoJSON.Feature<GeoJSON.LineString, GeoJSON.GeoJsonProperties>;
|
|
34
|
+
declare const isPolygon: (val: any) => val is GeoJSON.Polygon | GeoJSON.Feature<GeoJSON.Polygon, GeoJSON.GeoJsonProperties>;
|
|
35
|
+
declare const isMultiPolygon: (val: any) => val is GeoJSON.MultiPolygon | GeoJSON.Feature<GeoJSON.MultiPolygon, GeoJSON.GeoJsonProperties>;
|
|
36
|
+
|
|
37
|
+
declare const capitalize: (str: string, lowerRest?: boolean) => string;
|
|
38
|
+
|
|
39
|
+
export { capitalize, ensureArray, hasLength, hasValue, isArray, isArrayFull, isArrayStrings, isBoolean, isDate, isDefined, isFalse, isFunction, isIn, isLineString, isMultiPolygon, isNil, isNull, isNumber, isNumeric, isObject, isObjectFull, isPlainObject, isPoint, isPolygon, isString, isStringFull, isTrue, isURL, isUndefined, isValue };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as GeoJSON from 'geojson';
|
|
2
|
+
export { d as debounce, a as debounceWithArgs, m as memoize, t as throttle } from '../../shared/flow-rdf-core.08975378.js';
|
|
3
|
+
export { html } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
declare const isUndefined: (val: unknown) => val is undefined;
|
|
6
|
+
declare const isNull: (val: unknown) => val is null;
|
|
7
|
+
declare const isNil: (val: unknown) => val is null | undefined;
|
|
8
|
+
declare const isDefined: <T>(val: T) => val is Exclude<T, null | undefined>;
|
|
9
|
+
declare const isString: (val: unknown) => val is string;
|
|
10
|
+
declare const hasLength: (val: unknown) => boolean;
|
|
11
|
+
declare const isStringFull: (val: unknown) => val is string;
|
|
12
|
+
declare const isArray: (val: unknown) => val is unknown[];
|
|
13
|
+
declare const isArrayFull: (val: unknown) => val is unknown[];
|
|
14
|
+
declare const isArrayStrings: (val: unknown) => val is string[];
|
|
15
|
+
declare const isObject: (val: unknown) => val is object;
|
|
16
|
+
declare const isObjectFull: (val: unknown) => boolean;
|
|
17
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
18
|
+
declare const isFalse: (val: unknown) => val is false;
|
|
19
|
+
declare const isTrue: (val: unknown) => val is true;
|
|
20
|
+
declare const isIn: (val: unknown, arr: any[]) => boolean;
|
|
21
|
+
declare const isBoolean: (val: unknown) => val is boolean;
|
|
22
|
+
declare const isNumeric: (val: unknown) => boolean;
|
|
23
|
+
declare const isDate: (val: unknown) => val is Date;
|
|
24
|
+
declare const isValue: (val: unknown) => boolean;
|
|
25
|
+
declare const hasValue: (val: unknown) => boolean;
|
|
26
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
27
|
+
declare function isPlainObject(o: unknown): boolean;
|
|
28
|
+
declare function isURL(val: unknown): val is string;
|
|
29
|
+
|
|
30
|
+
declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
|
|
31
|
+
|
|
32
|
+
declare const isPoint: (val: unknown) => val is GeoJSON.Point | GeoJSON.Feature<GeoJSON.Point, GeoJSON.GeoJsonProperties>;
|
|
33
|
+
declare const isLineString: (val: any) => val is GeoJSON.LineString | GeoJSON.Feature<GeoJSON.LineString, GeoJSON.GeoJsonProperties>;
|
|
34
|
+
declare const isPolygon: (val: any) => val is GeoJSON.Polygon | GeoJSON.Feature<GeoJSON.Polygon, GeoJSON.GeoJsonProperties>;
|
|
35
|
+
declare const isMultiPolygon: (val: any) => val is GeoJSON.MultiPolygon | GeoJSON.Feature<GeoJSON.MultiPolygon, GeoJSON.GeoJsonProperties>;
|
|
36
|
+
|
|
37
|
+
declare const capitalize: (str: string, lowerRest?: boolean) => string;
|
|
38
|
+
|
|
39
|
+
export { capitalize, ensureArray, hasLength, hasValue, isArray, isArrayFull, isArrayStrings, isBoolean, isDate, isDefined, isFalse, isFunction, isIn, isLineString, isMultiPolygon, isNil, isNull, isNumber, isNumeric, isObject, isObjectFull, isPlainObject, isPoint, isPolygon, isString, isStringFull, isTrue, isURL, isUndefined, isValue };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { c as capitalize, e as ensureArray, h as hasLength, w as hasValue, j as isArray, k as isArrayFull, l as isArrayStrings, s as isBoolean, u as isDate, d as isDefined, p as isFalse, x as isFunction, r as isIn, b as isNil, a as isNull, o as isNumber, t as isNumeric, m as isObject, n as isObjectFull, y as isPlainObject, f as isString, g as isStringFull, q as isTrue, z as isURL, i as isUndefined, v as isValue } from '../../shared/flow-rdf-core.b80085b4.mjs';
|
|
2
|
+
export { i as isLineString, a as isMultiPolygon, b as isPoint, c as isPolygon } from '../../shared/flow-rdf-core.bd95d618.mjs';
|
|
3
|
+
export { d as debounce, a as debounceWithArgs, m as memoize, t as throttle } from '../../shared/flow-rdf-core.2e456f93.mjs';
|
|
4
|
+
export { html } from 'lit-html';
|
|
5
|
+
import '@turf/invariant';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
3
|
+
* execution of handlers on events like resize and scroll.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
|
|
6
|
+
* are most useful.
|
|
7
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
|
|
8
|
+
* as-is, to `callback` when the throttled-function is executed.
|
|
9
|
+
* @param {object} [options] - An object to configure options.
|
|
10
|
+
* @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
|
|
11
|
+
* while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
|
|
12
|
+
* one final time after the last throttled-function call. (After the throttled-function has not been called for
|
|
13
|
+
* `delay` milliseconds, the internal counter is reset).
|
|
14
|
+
* @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
|
|
15
|
+
* immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
|
|
16
|
+
* callback will never executed if both noLeading = true and noTrailing = true.
|
|
17
|
+
* @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
|
|
18
|
+
* false (at end), schedule `callback` to execute after `delay` ms.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Func} A new, throttled, function.
|
|
21
|
+
*/
|
|
22
|
+
type Func<TArgs extends any[] = any[], TResult = any | void> = (...args: TArgs) => TResult;
|
|
23
|
+
type NoReturn<T extends Func> = Func<Parameters<T>, void>;
|
|
24
|
+
interface CancelOptions {
|
|
25
|
+
upcomingOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface Cancel {
|
|
28
|
+
cancel: (options?: CancelOptions) => void;
|
|
29
|
+
}
|
|
30
|
+
declare const doNotMemoize: unique symbol;
|
|
31
|
+
interface MemoizeOptions<TArgs extends any[], TKey> {
|
|
32
|
+
hash?: Func<TArgs, TKey | typeof doNotMemoize>;
|
|
33
|
+
context?: any;
|
|
34
|
+
}
|
|
35
|
+
declare function memoize<TArgs extends any[], TResult, TKey>(originalFunction: Func<TArgs, TResult>, options: MemoizeOptions<TArgs, TKey>): (...args: TArgs) => TResult;
|
|
36
|
+
interface ThrottleOptions {
|
|
37
|
+
delay: number;
|
|
38
|
+
noTrailing?: boolean;
|
|
39
|
+
noLeading?: boolean;
|
|
40
|
+
debounceMode?: boolean;
|
|
41
|
+
context?: any;
|
|
42
|
+
}
|
|
43
|
+
declare function throttle<T extends (...args: any[]) => any>(callback: T, options: ThrottleOptions): NoReturn<T> & Cancel;
|
|
44
|
+
/**
|
|
45
|
+
* Debounce execution of a function. Debouncing, unlike throttling,
|
|
46
|
+
* guarantees that a function is only executed a single time, either at the
|
|
47
|
+
* very beginning of a series of calls, or at the very end.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
50
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
|
51
|
+
* to `callback` when the debounced-function is executed.
|
|
52
|
+
* @param {object} [options] - An object to configure options.
|
|
53
|
+
* @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
|
54
|
+
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
|
55
|
+
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
|
56
|
+
*
|
|
57
|
+
* @returns {Func} A new, debounced function.
|
|
58
|
+
*/
|
|
59
|
+
interface DebounceOptions {
|
|
60
|
+
delay: number;
|
|
61
|
+
atBegin?: boolean;
|
|
62
|
+
context?: any;
|
|
63
|
+
}
|
|
64
|
+
declare function debounce<T extends (...args: any[]) => any>(callback: T, options: DebounceOptions): NoReturn<T> & Cancel;
|
|
65
|
+
type MemoizedDebounceOptions<TArgs extends any[], TKey> = DebounceOptions & MemoizeOptions<TArgs, TKey>;
|
|
66
|
+
declare function debounceWithArgs<TArgs extends any[], TKey>(fn: Func<TArgs, any>, options: MemoizedDebounceOptions<TArgs, TKey>): Func<TArgs, void>;
|
|
67
|
+
|
|
68
|
+
export { Func as F, debounceWithArgs as a, debounce as d, memoize as m, throttle as t };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
3
|
+
* execution of handlers on events like resize and scroll.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
|
|
6
|
+
* are most useful.
|
|
7
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
|
|
8
|
+
* as-is, to `callback` when the throttled-function is executed.
|
|
9
|
+
* @param {object} [options] - An object to configure options.
|
|
10
|
+
* @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
|
|
11
|
+
* while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
|
|
12
|
+
* one final time after the last throttled-function call. (After the throttled-function has not been called for
|
|
13
|
+
* `delay` milliseconds, the internal counter is reset).
|
|
14
|
+
* @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
|
|
15
|
+
* immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
|
|
16
|
+
* callback will never executed if both noLeading = true and noTrailing = true.
|
|
17
|
+
* @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
|
|
18
|
+
* false (at end), schedule `callback` to execute after `delay` ms.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Func} A new, throttled, function.
|
|
21
|
+
*/
|
|
22
|
+
type Func<TArgs extends any[] = any[], TResult = any | void> = (...args: TArgs) => TResult;
|
|
23
|
+
type NoReturn<T extends Func> = Func<Parameters<T>, void>;
|
|
24
|
+
interface CancelOptions {
|
|
25
|
+
upcomingOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface Cancel {
|
|
28
|
+
cancel: (options?: CancelOptions) => void;
|
|
29
|
+
}
|
|
30
|
+
declare const doNotMemoize: unique symbol;
|
|
31
|
+
interface MemoizeOptions<TArgs extends any[], TKey> {
|
|
32
|
+
hash?: Func<TArgs, TKey | typeof doNotMemoize>;
|
|
33
|
+
context?: any;
|
|
34
|
+
}
|
|
35
|
+
declare function memoize<TArgs extends any[], TResult, TKey>(originalFunction: Func<TArgs, TResult>, options: MemoizeOptions<TArgs, TKey>): (...args: TArgs) => TResult;
|
|
36
|
+
interface ThrottleOptions {
|
|
37
|
+
delay: number;
|
|
38
|
+
noTrailing?: boolean;
|
|
39
|
+
noLeading?: boolean;
|
|
40
|
+
debounceMode?: boolean;
|
|
41
|
+
context?: any;
|
|
42
|
+
}
|
|
43
|
+
declare function throttle<T extends (...args: any[]) => any>(callback: T, options: ThrottleOptions): NoReturn<T> & Cancel;
|
|
44
|
+
/**
|
|
45
|
+
* Debounce execution of a function. Debouncing, unlike throttling,
|
|
46
|
+
* guarantees that a function is only executed a single time, either at the
|
|
47
|
+
* very beginning of a series of calls, or at the very end.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
50
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
|
51
|
+
* to `callback` when the debounced-function is executed.
|
|
52
|
+
* @param {object} [options] - An object to configure options.
|
|
53
|
+
* @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
|
54
|
+
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
|
55
|
+
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
|
56
|
+
*
|
|
57
|
+
* @returns {Func} A new, debounced function.
|
|
58
|
+
*/
|
|
59
|
+
interface DebounceOptions {
|
|
60
|
+
delay: number;
|
|
61
|
+
atBegin?: boolean;
|
|
62
|
+
context?: any;
|
|
63
|
+
}
|
|
64
|
+
declare function debounce<T extends (...args: any[]) => any>(callback: T, options: DebounceOptions): NoReturn<T> & Cancel;
|
|
65
|
+
type MemoizedDebounceOptions<TArgs extends any[], TKey> = DebounceOptions & MemoizeOptions<TArgs, TKey>;
|
|
66
|
+
declare function debounceWithArgs<TArgs extends any[], TKey>(fn: Func<TArgs, any>, options: MemoizedDebounceOptions<TArgs, TKey>): Func<TArgs, void>;
|
|
67
|
+
|
|
68
|
+
export { Func as F, debounceWithArgs as a, debounce as d, memoize as m, throttle as t };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
3
|
+
* execution of handlers on events like resize and scroll.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
|
|
6
|
+
* are most useful.
|
|
7
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
|
|
8
|
+
* as-is, to `callback` when the throttled-function is executed.
|
|
9
|
+
* @param {object} [options] - An object to configure options.
|
|
10
|
+
* @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
|
|
11
|
+
* while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
|
|
12
|
+
* one final time after the last throttled-function call. (After the throttled-function has not been called for
|
|
13
|
+
* `delay` milliseconds, the internal counter is reset).
|
|
14
|
+
* @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
|
|
15
|
+
* immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
|
|
16
|
+
* callback will never executed if both noLeading = true and noTrailing = true.
|
|
17
|
+
* @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
|
|
18
|
+
* false (at end), schedule `callback` to execute after `delay` ms.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Func} A new, throttled, function.
|
|
21
|
+
*/
|
|
22
|
+
type Func<TArgs extends any[] = any[], TResult = any | void> = (...args: TArgs) => TResult;
|
|
23
|
+
type NoReturn<T extends Func> = Func<Parameters<T>, void>;
|
|
24
|
+
interface CancelOptions {
|
|
25
|
+
upcomingOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface Cancel {
|
|
28
|
+
cancel: (options?: CancelOptions) => void;
|
|
29
|
+
}
|
|
30
|
+
declare const doNotMemoize: unique symbol;
|
|
31
|
+
interface MemoizeOptions<TArgs extends any[], TKey> {
|
|
32
|
+
hash?: Func<TArgs, TKey | typeof doNotMemoize>;
|
|
33
|
+
context?: any;
|
|
34
|
+
}
|
|
35
|
+
declare function memoize<TArgs extends any[], TResult, TKey>(originalFunction: Func<TArgs, TResult>, options: MemoizeOptions<TArgs, TKey>): (...args: TArgs) => TResult;
|
|
36
|
+
interface ThrottleOptions {
|
|
37
|
+
delay: number;
|
|
38
|
+
noTrailing?: boolean;
|
|
39
|
+
noLeading?: boolean;
|
|
40
|
+
debounceMode?: boolean;
|
|
41
|
+
context?: any;
|
|
42
|
+
}
|
|
43
|
+
declare function throttle<T extends (...args: any[]) => any>(callback: T, options: ThrottleOptions): NoReturn<T> & Cancel;
|
|
44
|
+
/**
|
|
45
|
+
* Debounce execution of a function. Debouncing, unlike throttling,
|
|
46
|
+
* guarantees that a function is only executed a single time, either at the
|
|
47
|
+
* very beginning of a series of calls, or at the very end.
|
|
48
|
+
*
|
|
49
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
50
|
+
* @param {Func} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
|
51
|
+
* to `callback` when the debounced-function is executed.
|
|
52
|
+
* @param {object} [options] - An object to configure options.
|
|
53
|
+
* @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
|
54
|
+
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
|
55
|
+
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
|
56
|
+
*
|
|
57
|
+
* @returns {Func} A new, debounced function.
|
|
58
|
+
*/
|
|
59
|
+
interface DebounceOptions {
|
|
60
|
+
delay: number;
|
|
61
|
+
atBegin?: boolean;
|
|
62
|
+
context?: any;
|
|
63
|
+
}
|
|
64
|
+
declare function debounce<T extends (...args: any[]) => any>(callback: T, options: DebounceOptions): NoReturn<T> & Cancel;
|
|
65
|
+
type MemoizedDebounceOptions<TArgs extends any[], TKey> = DebounceOptions & MemoizeOptions<TArgs, TKey>;
|
|
66
|
+
declare function debounceWithArgs<TArgs extends any[], TKey>(fn: Func<TArgs, any>, options: MemoizedDebounceOptions<TArgs, TKey>): Func<TArgs, void>;
|
|
67
|
+
|
|
68
|
+
export { Func as F, debounceWithArgs as a, debounce as d, memoize as m, throttle as t };
|