@koine/utils 1.0.87 → 1.0.89

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 CHANGED
@@ -1,11 +1,8 @@
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
1
  /**
5
- * Debounce function
2
+ * Debounce function (with `setTimeout`)
6
3
  *
7
4
  * @category function
8
- * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
5
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
9
6
  */
10
- export declare const debounce: typeof tsDebounce;
7
+ export declare function debounce<T extends (...args: any[]) => any>(fn: T, wait?: number, immediate?: boolean): (this: unknown, ...args: Parameters<T>) => void;
11
8
  export default debounce;
package/debounce.js CHANGED
@@ -1,9 +1,29 @@
1
- import { debounce as tsDebounce } from "ts-debounce";
2
1
  /**
3
- * Debounce function
2
+ * Debounce function (with `setTimeout`)
4
3
  *
5
4
  * @category function
6
- * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
5
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
7
6
  */
8
- export var debounce = tsDebounce;
7
+ export function debounce(fn, wait, immediate) {
8
+ var timeout;
9
+ return function () {
10
+ var args = [];
11
+ for (var _i = 0; _i < arguments.length; _i++) {
12
+ args[_i] = arguments[_i];
13
+ }
14
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
15
+ var context = this;
16
+ var later = function () {
17
+ timeout = null;
18
+ if (!immediate)
19
+ fn.apply(context, args);
20
+ };
21
+ var callNow = immediate && !timeout;
22
+ if (timeout)
23
+ clearTimeout(timeout);
24
+ timeout = setTimeout(later, wait);
25
+ if (callNow)
26
+ fn.apply(context, args);
27
+ };
28
+ }
9
29
  export default debounce;
@@ -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 (with `Promise`)
6
+ *
7
+ * @category function
8
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
9
+ */
10
+ export declare const debouncePromise: typeof tsDebounce;
11
+ export default debouncePromise;
@@ -0,0 +1,9 @@
1
+ import { debounce as tsDebounce } from "ts-debounce";
2
+ /**
3
+ * Debounce function (with `Promise`)
4
+ *
5
+ * @category function
6
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
7
+ */
8
+ export var debouncePromise = tsDebounce;
9
+ export default debouncePromise;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Debounce function (with `requestAnimationFrame`)
3
+ *
4
+ * (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
5
+ * @category function
6
+ * @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
7
+ */
8
+ export declare function debounceRaf<T extends (...args: any[]) => any>(this: unknown, fn: T): (this: unknown, ...args: Parameters<T>) => void;
9
+ export default debounceRaf;
package/debounceRaf.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Debounce function (with `requestAnimationFrame`)
3
+ *
4
+ * (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
5
+ * @category function
6
+ * @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
7
+ */
8
+ export function debounceRaf(fn) {
9
+ var timeout;
10
+ return function () {
11
+ var args = [];
12
+ for (var _i = 0; _i < arguments.length; _i++) {
13
+ args[_i] = arguments[_i];
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
16
+ var context = this;
17
+ // If there's a timer, cancel it
18
+ if (timeout) {
19
+ window.cancelAnimationFrame(timeout);
20
+ }
21
+ // Setup the new requestAnimationFrame()
22
+ timeout = window.requestAnimationFrame(function () {
23
+ fn.apply(context, args);
24
+ });
25
+ };
26
+ }
27
+ export default debounceRaf;
@@ -0,0 +1,5 @@
1
+ import { type GetMediaQueryWidthResolversBreakpoints } from "./getMediaQueryWidthResolvers";
2
+ export declare function getMediaQueryWidthTailwindScreens(breakpoints: GetMediaQueryWidthResolversBreakpoints): Record<string, {
3
+ raw: string;
4
+ }>;
5
+ export default getMediaQueryWidthTailwindScreens;
@@ -0,0 +1,29 @@
1
+ import { getMediaQueryWidthResolvers, } from "./getMediaQueryWidthResolvers";
2
+ export function getMediaQueryWidthTailwindScreens(breakpoints) {
3
+ var mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
4
+ // Object.keys(breakpoints).reduce((screens, br) => {
5
+ var screens = Object.keys(breakpoints).reduce(function (output, br, idx) {
6
+ var brNext = Object.keys(breakpoints)[idx + 1];
7
+ for (var resolverName in mqWidthResolvers) {
8
+ // this line is just for typescript..
9
+ var resolver = resolverName;
10
+ var resolverFn = mqWidthResolvers[resolver];
11
+ var raw = resolverFn(br);
12
+ if (raw) {
13
+ if (resolverName === "min") {
14
+ output["@".concat(br)] = { raw: raw };
15
+ }
16
+ if (resolverName === "between") {
17
+ if (brNext)
18
+ output["@".concat(resolverName, "-").concat(br, "_").concat(brNext)] = { raw: raw };
19
+ }
20
+ else {
21
+ output["@".concat(resolverName, "-").concat(br)] = { raw: raw };
22
+ }
23
+ }
24
+ }
25
+ return output;
26
+ }, {});
27
+ return screens;
28
+ }
29
+ export default getMediaQueryWidthTailwindScreens;
package/index.d.ts CHANGED
@@ -10,8 +10,9 @@ export * from "./clamp";
10
10
  export * from "./clsx";
11
11
  export * from "./convertRange";
12
12
  export * from "./cookie";
13
- export * from "./createStorage";
14
13
  export * from "./debounce";
14
+ export * from "./debounceRaf";
15
+ export * from "./debouncePromise";
15
16
  export * from "./decode";
16
17
  export * from "./Defer";
17
18
  export * from "./Emitter";
@@ -21,6 +22,7 @@ export * from "./findDuplicatedIndexes";
21
22
  export * from "./getEmptyArray";
22
23
  export * from "./getKeys";
23
24
  export * from "./getMediaQueryWidthResolvers";
25
+ export * from "./getMediaQueryWidthTailwindScreens";
24
26
  export * from "./getNonce";
25
27
  export * from "./getParamAmong";
26
28
  export * from "./getParamAsInt";
@@ -30,7 +32,6 @@ export * from "./getUrlHashParams";
30
32
  export * from "./getUrlHashPathname";
31
33
  export * from "./getUrlPathnameParts";
32
34
  export * from "./getUrlQueryParams";
33
- export * from "./getZonedDate";
34
35
  export * from "./imgEmptyPixel";
35
36
  export * from "./isAnyObject";
36
37
  export * from "./isArray";
@@ -50,10 +51,8 @@ export * from "./isFullArray";
50
51
  export * from "./isFullObject";
51
52
  export * from "./isFullString";
52
53
  export * from "./isFunction";
53
- export * from "./isIE";
54
54
  export * from "./isInt";
55
55
  export * from "./isMap";
56
- export * from "./isMobile";
57
56
  export * from "./isNaNValue";
58
57
  export * from "./isNegativeNumber";
59
58
  export * from "./isNullOrUndefined";
@@ -81,23 +80,15 @@ export * from "./matchSorter";
81
80
  export * from "./mergeObjects";
82
81
  export * from "./mergeUrlQueryParams";
83
82
  export * from "./moveSortableArrayItemByKey";
84
- export * from "./navigateToHash";
85
- export * from "./navigateToHashParams";
86
- export * from "./navigateToMergedHashParams";
87
- export * from "./navigateToMergedParams";
88
- export * from "./navigateToParams";
89
- export * from "./navigateWithoutUrlParam";
90
83
  export * from "./normaliseUrlPathname";
91
84
  export * from "./normaliseUrl";
92
85
  export * from "./objectPick";
93
86
  export * from "./objectOmit";
94
- export * from "./pageview";
95
87
  export * from "./parseCookie";
96
88
  export * from "./parseURL";
97
89
  export * from "./randomInt";
98
90
  export * from "./randomKey";
99
91
  export * from "./readCookie";
100
- export * from "./redirectTo";
101
92
  export * from "./removeAccents";
102
93
  export * from "./removeCookie";
103
94
  export * from "./removeDuplicatesByKey";
@@ -122,4 +113,4 @@ export * from "./updateLinkParams";
122
113
  export * from "./updateUrlQueryParams";
123
114
  export * from "./uuid";
124
115
  export * from "./wait";
125
- export type { Primitive, Class, Constructor, TypedArray, ObservableLike, Except, Mutable, Merge, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, RemoveIndexSignature, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, } from "type-fest";
116
+ export * from "type-fest";
package/index.js CHANGED
@@ -10,8 +10,9 @@ export * from "./clamp";
10
10
  export * from "./clsx";
11
11
  export * from "./convertRange";
12
12
  export * from "./cookie";
13
- export * from "./createStorage";
14
13
  export * from "./debounce";
14
+ export * from "./debounceRaf";
15
+ export * from "./debouncePromise";
15
16
  export * from "./decode";
16
17
  export * from "./Defer";
17
18
  export * from "./Emitter";
@@ -22,6 +23,7 @@ export * from "./findDuplicatedIndexes";
22
23
  export * from "./getEmptyArray";
23
24
  export * from "./getKeys";
24
25
  export * from "./getMediaQueryWidthResolvers";
26
+ export * from "./getMediaQueryWidthTailwindScreens";
25
27
  export * from "./getNonce";
26
28
  export * from "./getParamAmong";
27
29
  export * from "./getParamAsInt";
@@ -31,7 +33,6 @@ export * from "./getUrlHashParams";
31
33
  export * from "./getUrlHashPathname";
32
34
  export * from "./getUrlPathnameParts";
33
35
  export * from "./getUrlQueryParams";
34
- export * from "./getZonedDate";
35
36
  export * from "./imgEmptyPixel";
36
37
  export * from "./isAnyObject";
37
38
  export * from "./isArray";
@@ -51,10 +52,8 @@ export * from "./isFullArray";
51
52
  export * from "./isFullObject";
52
53
  export * from "./isFullString";
53
54
  export * from "./isFunction";
54
- export * from "./isIE";
55
55
  export * from "./isInt";
56
56
  export * from "./isMap";
57
- export * from "./isMobile";
58
57
  export * from "./isNaNValue";
59
58
  export * from "./isNegativeNumber";
60
59
  export * from "./isNullOrUndefined";
@@ -82,23 +81,15 @@ export * from "./matchSorter";
82
81
  export * from "./mergeObjects";
83
82
  export * from "./mergeUrlQueryParams";
84
83
  export * from "./moveSortableArrayItemByKey";
85
- export * from "./navigateToHash";
86
- export * from "./navigateToHashParams";
87
- export * from "./navigateToMergedHashParams";
88
- export * from "./navigateToMergedParams";
89
- export * from "./navigateToParams";
90
- export * from "./navigateWithoutUrlParam";
91
84
  export * from "./normaliseUrlPathname";
92
85
  export * from "./normaliseUrl";
93
86
  export * from "./objectPick";
94
87
  export * from "./objectOmit";
95
- export * from "./pageview";
96
88
  export * from "./parseCookie";
97
89
  export * from "./parseURL";
98
90
  export * from "./randomInt";
99
91
  export * from "./randomKey";
100
92
  export * from "./readCookie";
101
- export * from "./redirectTo";
102
93
  export * from "./removeAccents";
103
94
  export * from "./removeCookie";
104
95
  // export * from "./removeDuplicates";
@@ -124,3 +115,104 @@ export * from "./updateLinkParams";
124
115
  export * from "./updateUrlQueryParams";
125
116
  export * from "./uuid";
126
117
  export * from "./wait";
118
+ export * from "type-fest";
119
+ // export type {
120
+ // Primitive,
121
+ // Class,
122
+ // Constructor,
123
+ // TypedArray,
124
+ // Observer,
125
+ // ObservableLike,
126
+ // Except,
127
+ // Writable,
128
+ // Merge,
129
+ // // MergeDeep,
130
+ // MergeExclusive,
131
+ // RequireAtLeastOne,
132
+ // RequireExactlyOne,
133
+ // RequireAllOrNone,
134
+ // RemoveIndexSignature,
135
+ // PartialDeep,
136
+ // ReadonlyDeep,
137
+ // LiteralUnion,
138
+ // Opaque,
139
+ // InvariantOf,
140
+ // SetOptional,
141
+ // SetRequired,
142
+ // ValueOf,
143
+ // ConditionalKeys,
144
+ // ConditionalPick,
145
+ // ConditionalExcept,
146
+ // UnionToIntersection,
147
+ // LiteralToPrimitive,
148
+ // Stringified,
149
+ // IterableElement,
150
+ // Entry,
151
+ // Exact,
152
+ // Entries,
153
+ // SetReturnType,
154
+ // Simplify,
155
+ // Get,
156
+ // StringKeyOf,
157
+ // Schema,
158
+ // Jsonify,
159
+ // JsonPrimitive,
160
+ // JsonObject,
161
+ // JsonArray,
162
+ // JsonValue,
163
+ // Promisable,
164
+ // AsyncReturnType,
165
+ // Asyncify,
166
+ // Trim,
167
+ // Split,
168
+ // Includes,
169
+ // Join,
170
+ // LastArrayElement,
171
+ // FixedLengthArray,
172
+ // MultidimensionalArray,
173
+ // MultidimensionalReadonlyArray,
174
+ // PositiveInfinity,
175
+ // NegativeInfinity,
176
+ // Finite,
177
+ // Integer,
178
+ // Float,
179
+ // NegativeFloat,
180
+ // Negative,
181
+ // NonNegative,
182
+ // NegativeInteger,
183
+ // NonNegativeInteger,
184
+ // CamelCase,
185
+ // CamelCasedProperties,
186
+ // CamelCasedPropertiesDeep,
187
+ // KebabCase,
188
+ // KebabCasedProperties,
189
+ // KebabCasedPropertiesDeep,
190
+ // PascalCase,
191
+ // PascalCasedProperties,
192
+ // PascalCasedPropertiesDeep,
193
+ // SnakeCase,
194
+ // SnakeCasedProperties,
195
+ // SnakeCasedPropertiesDeep,
196
+ // ScreamingSnakeCase,
197
+ // DelimiterCase,
198
+ // DelimiterCasedProperties,
199
+ // DelimiterCasedPropertiesDeep,
200
+ // PackageJson,
201
+ // TsConfigJson,
202
+ // SetNonNullable,
203
+ // Spread,
204
+ // PartialOnUndefinedDeep,
205
+ // OptionalKeysOf,
206
+ // HasOptionalKeys,
207
+ // RequiredKeysOf,
208
+ // HasRequiredKeys,
209
+ // UnwrapOpaque ,
210
+ // EmptyObject,
211
+ // IsEmptyObject,
212
+ // TupleToUnion,
213
+ // OmitIndexSignature,
214
+ // PickIndexSignature,
215
+ // ConditionalPickDeep,
216
+ // ConditionalSimplify,
217
+ // ConditionalSimplifyDeep,
218
+ // } from "type-fest";
package/node/debounce.js CHANGED
@@ -1,12 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debounce = void 0;
4
- var ts_debounce_1 = require("ts-debounce");
5
4
  /**
6
- * Debounce function
5
+ * Debounce function (with `setTimeout`)
7
6
  *
8
7
  * @category function
9
- * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
8
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
10
9
  */
11
- exports.debounce = ts_debounce_1.debounce;
12
- exports.default = exports.debounce;
10
+ function debounce(fn, wait, immediate) {
11
+ var timeout;
12
+ return function () {
13
+ var args = [];
14
+ for (var _i = 0; _i < arguments.length; _i++) {
15
+ args[_i] = arguments[_i];
16
+ }
17
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
18
+ var context = this;
19
+ var later = function () {
20
+ timeout = null;
21
+ if (!immediate)
22
+ fn.apply(context, args);
23
+ };
24
+ var callNow = immediate && !timeout;
25
+ if (timeout)
26
+ clearTimeout(timeout);
27
+ timeout = setTimeout(later, wait);
28
+ if (callNow)
29
+ fn.apply(context, args);
30
+ };
31
+ }
32
+ exports.debounce = debounce;
33
+ exports.default = debounce;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debouncePromise = void 0;
4
+ var ts_debounce_1 = require("ts-debounce");
5
+ /**
6
+ * Debounce function (with `Promise`)
7
+ *
8
+ * @category function
9
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
10
+ */
11
+ exports.debouncePromise = ts_debounce_1.debounce;
12
+ exports.default = exports.debouncePromise;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debounceRaf = void 0;
4
+ /**
5
+ * Debounce function (with `requestAnimationFrame`)
6
+ *
7
+ * (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
8
+ * @category function
9
+ * @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
10
+ */
11
+ function debounceRaf(fn) {
12
+ var timeout;
13
+ return function () {
14
+ var args = [];
15
+ for (var _i = 0; _i < arguments.length; _i++) {
16
+ args[_i] = arguments[_i];
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
19
+ var context = this;
20
+ // If there's a timer, cancel it
21
+ if (timeout) {
22
+ window.cancelAnimationFrame(timeout);
23
+ }
24
+ // Setup the new requestAnimationFrame()
25
+ timeout = window.requestAnimationFrame(function () {
26
+ fn.apply(context, args);
27
+ });
28
+ };
29
+ }
30
+ exports.debounceRaf = debounceRaf;
31
+ exports.default = debounceRaf;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMediaQueryWidthTailwindScreens = void 0;
4
+ var getMediaQueryWidthResolvers_1 = require("./getMediaQueryWidthResolvers");
5
+ function getMediaQueryWidthTailwindScreens(breakpoints) {
6
+ var mqWidthResolvers = (0, getMediaQueryWidthResolvers_1.getMediaQueryWidthResolvers)(breakpoints);
7
+ // Object.keys(breakpoints).reduce((screens, br) => {
8
+ var screens = Object.keys(breakpoints).reduce(function (output, br, idx) {
9
+ var brNext = Object.keys(breakpoints)[idx + 1];
10
+ for (var resolverName in mqWidthResolvers) {
11
+ // this line is just for typescript..
12
+ var resolver = resolverName;
13
+ var resolverFn = mqWidthResolvers[resolver];
14
+ var raw = resolverFn(br);
15
+ if (raw) {
16
+ if (resolverName === "min") {
17
+ output["@".concat(br)] = { raw: raw };
18
+ }
19
+ if (resolverName === "between") {
20
+ if (brNext)
21
+ output["@".concat(resolverName, "-").concat(br, "_").concat(brNext)] = { raw: raw };
22
+ }
23
+ else {
24
+ output["@".concat(resolverName, "-").concat(br)] = { raw: raw };
25
+ }
26
+ }
27
+ }
28
+ return output;
29
+ }, {});
30
+ return screens;
31
+ }
32
+ exports.getMediaQueryWidthTailwindScreens = getMediaQueryWidthTailwindScreens;
33
+ exports.default = getMediaQueryWidthTailwindScreens;
package/node/index.js CHANGED
@@ -13,8 +13,9 @@ tslib_1.__exportStar(require("./clamp"), exports);
13
13
  tslib_1.__exportStar(require("./clsx"), exports);
14
14
  tslib_1.__exportStar(require("./convertRange"), exports);
15
15
  tslib_1.__exportStar(require("./cookie"), exports);
16
- tslib_1.__exportStar(require("./createStorage"), exports);
17
16
  tslib_1.__exportStar(require("./debounce"), exports);
17
+ tslib_1.__exportStar(require("./debounceRaf"), exports);
18
+ tslib_1.__exportStar(require("./debouncePromise"), exports);
18
19
  tslib_1.__exportStar(require("./decode"), exports);
19
20
  tslib_1.__exportStar(require("./Defer"), exports);
20
21
  tslib_1.__exportStar(require("./Emitter"), exports);
@@ -25,6 +26,7 @@ tslib_1.__exportStar(require("./findDuplicatedIndexes"), exports);
25
26
  tslib_1.__exportStar(require("./getEmptyArray"), exports);
26
27
  tslib_1.__exportStar(require("./getKeys"), exports);
27
28
  tslib_1.__exportStar(require("./getMediaQueryWidthResolvers"), exports);
29
+ tslib_1.__exportStar(require("./getMediaQueryWidthTailwindScreens"), exports);
28
30
  tslib_1.__exportStar(require("./getNonce"), exports);
29
31
  tslib_1.__exportStar(require("./getParamAmong"), exports);
30
32
  tslib_1.__exportStar(require("./getParamAsInt"), exports);
@@ -34,7 +36,6 @@ tslib_1.__exportStar(require("./getUrlHashParams"), exports);
34
36
  tslib_1.__exportStar(require("./getUrlHashPathname"), exports);
35
37
  tslib_1.__exportStar(require("./getUrlPathnameParts"), exports);
36
38
  tslib_1.__exportStar(require("./getUrlQueryParams"), exports);
37
- tslib_1.__exportStar(require("./getZonedDate"), exports);
38
39
  tslib_1.__exportStar(require("./imgEmptyPixel"), exports);
39
40
  tslib_1.__exportStar(require("./isAnyObject"), exports);
40
41
  tslib_1.__exportStar(require("./isArray"), exports);
@@ -54,10 +55,8 @@ tslib_1.__exportStar(require("./isFullArray"), exports);
54
55
  tslib_1.__exportStar(require("./isFullObject"), exports);
55
56
  tslib_1.__exportStar(require("./isFullString"), exports);
56
57
  tslib_1.__exportStar(require("./isFunction"), exports);
57
- tslib_1.__exportStar(require("./isIE"), exports);
58
58
  tslib_1.__exportStar(require("./isInt"), exports);
59
59
  tslib_1.__exportStar(require("./isMap"), exports);
60
- tslib_1.__exportStar(require("./isMobile"), exports);
61
60
  tslib_1.__exportStar(require("./isNaNValue"), exports);
62
61
  tslib_1.__exportStar(require("./isNegativeNumber"), exports);
63
62
  tslib_1.__exportStar(require("./isNullOrUndefined"), exports);
@@ -85,23 +84,15 @@ tslib_1.__exportStar(require("./matchSorter"), exports);
85
84
  tslib_1.__exportStar(require("./mergeObjects"), exports);
86
85
  tslib_1.__exportStar(require("./mergeUrlQueryParams"), exports);
87
86
  tslib_1.__exportStar(require("./moveSortableArrayItemByKey"), exports);
88
- tslib_1.__exportStar(require("./navigateToHash"), exports);
89
- tslib_1.__exportStar(require("./navigateToHashParams"), exports);
90
- tslib_1.__exportStar(require("./navigateToMergedHashParams"), exports);
91
- tslib_1.__exportStar(require("./navigateToMergedParams"), exports);
92
- tslib_1.__exportStar(require("./navigateToParams"), exports);
93
- tslib_1.__exportStar(require("./navigateWithoutUrlParam"), exports);
94
87
  tslib_1.__exportStar(require("./normaliseUrlPathname"), exports);
95
88
  tslib_1.__exportStar(require("./normaliseUrl"), exports);
96
89
  tslib_1.__exportStar(require("./objectPick"), exports);
97
90
  tslib_1.__exportStar(require("./objectOmit"), exports);
98
- tslib_1.__exportStar(require("./pageview"), exports);
99
91
  tslib_1.__exportStar(require("./parseCookie"), exports);
100
92
  tslib_1.__exportStar(require("./parseURL"), exports);
101
93
  tslib_1.__exportStar(require("./randomInt"), exports);
102
94
  tslib_1.__exportStar(require("./randomKey"), exports);
103
95
  tslib_1.__exportStar(require("./readCookie"), exports);
104
- tslib_1.__exportStar(require("./redirectTo"), exports);
105
96
  tslib_1.__exportStar(require("./removeAccents"), exports);
106
97
  tslib_1.__exportStar(require("./removeCookie"), exports);
107
98
  // export * from "./removeDuplicates";
@@ -127,3 +118,104 @@ tslib_1.__exportStar(require("./updateLinkParams"), exports);
127
118
  tslib_1.__exportStar(require("./updateUrlQueryParams"), exports);
128
119
  tslib_1.__exportStar(require("./uuid"), exports);
129
120
  tslib_1.__exportStar(require("./wait"), exports);
121
+ tslib_1.__exportStar(require("type-fest"), exports);
122
+ // export type {
123
+ // Primitive,
124
+ // Class,
125
+ // Constructor,
126
+ // TypedArray,
127
+ // Observer,
128
+ // ObservableLike,
129
+ // Except,
130
+ // Writable,
131
+ // Merge,
132
+ // // MergeDeep,
133
+ // MergeExclusive,
134
+ // RequireAtLeastOne,
135
+ // RequireExactlyOne,
136
+ // RequireAllOrNone,
137
+ // RemoveIndexSignature,
138
+ // PartialDeep,
139
+ // ReadonlyDeep,
140
+ // LiteralUnion,
141
+ // Opaque,
142
+ // InvariantOf,
143
+ // SetOptional,
144
+ // SetRequired,
145
+ // ValueOf,
146
+ // ConditionalKeys,
147
+ // ConditionalPick,
148
+ // ConditionalExcept,
149
+ // UnionToIntersection,
150
+ // LiteralToPrimitive,
151
+ // Stringified,
152
+ // IterableElement,
153
+ // Entry,
154
+ // Exact,
155
+ // Entries,
156
+ // SetReturnType,
157
+ // Simplify,
158
+ // Get,
159
+ // StringKeyOf,
160
+ // Schema,
161
+ // Jsonify,
162
+ // JsonPrimitive,
163
+ // JsonObject,
164
+ // JsonArray,
165
+ // JsonValue,
166
+ // Promisable,
167
+ // AsyncReturnType,
168
+ // Asyncify,
169
+ // Trim,
170
+ // Split,
171
+ // Includes,
172
+ // Join,
173
+ // LastArrayElement,
174
+ // FixedLengthArray,
175
+ // MultidimensionalArray,
176
+ // MultidimensionalReadonlyArray,
177
+ // PositiveInfinity,
178
+ // NegativeInfinity,
179
+ // Finite,
180
+ // Integer,
181
+ // Float,
182
+ // NegativeFloat,
183
+ // Negative,
184
+ // NonNegative,
185
+ // NegativeInteger,
186
+ // NonNegativeInteger,
187
+ // CamelCase,
188
+ // CamelCasedProperties,
189
+ // CamelCasedPropertiesDeep,
190
+ // KebabCase,
191
+ // KebabCasedProperties,
192
+ // KebabCasedPropertiesDeep,
193
+ // PascalCase,
194
+ // PascalCasedProperties,
195
+ // PascalCasedPropertiesDeep,
196
+ // SnakeCase,
197
+ // SnakeCasedProperties,
198
+ // SnakeCasedPropertiesDeep,
199
+ // ScreamingSnakeCase,
200
+ // DelimiterCase,
201
+ // DelimiterCasedProperties,
202
+ // DelimiterCasedPropertiesDeep,
203
+ // PackageJson,
204
+ // TsConfigJson,
205
+ // SetNonNullable,
206
+ // Spread,
207
+ // PartialOnUndefinedDeep,
208
+ // OptionalKeysOf,
209
+ // HasOptionalKeys,
210
+ // RequiredKeysOf,
211
+ // HasRequiredKeys,
212
+ // UnwrapOpaque ,
213
+ // EmptyObject,
214
+ // IsEmptyObject,
215
+ // TupleToUnion,
216
+ // OmitIndexSignature,
217
+ // PickIndexSignature,
218
+ // ConditionalPickDeep,
219
+ // ConditionalSimplify,
220
+ // ConditionalSimplifyDeep,
221
+ // } from "type-fest";
package/package.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "typings": "./index.d.ts",
6
6
  "dependencies": {
7
7
  "ts-debounce": "^4.0.0",
8
- "date-fns-tz": "^1.3.7",
8
+ "type-fest": "^3.1.0",
9
9
  "tslib": "^2.4.0"
10
10
  },
11
11
  "peerDependencies": {},
12
- "version": "1.0.87",
12
+ "version": "1.0.89",
13
13
  "module": "./index.js",
14
14
  "types": "./index.d.ts"
15
15
  }
package/typings.d.ts CHANGED
@@ -4,9 +4,6 @@
4
4
  * variables.
5
5
  */
6
6
 
7
- // eslint-disable-next-line no-var,@typescript-eslint/no-explicit-any
8
- declare var gtag: (...args: any[]) => any;
9
-
10
7
  // declare type NullableRecord<T> = {
11
8
  // [K in keyof T]: T[K] | null;
12
9
  // };
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStorage = void 0;
4
- var tslib_1 = require("tslib");
5
- var decode_1 = require("./decode");
6
- var encode_1 = require("./encode");
7
- var isBrowser_1 = require("./isBrowser");
8
- var isNullOrUndefined_1 = require("./isNullOrUndefined");
9
- var isString_1 = require("./isString");
10
- /**
11
- * Utility to create a storage instance to interact with `localStorage` using
12
- * encrypted (encoded) key/values.
13
- */
14
- var createStorage = function (config) {
15
- var methodsMap = { g: "getItem", s: "setItem", r: "removeItem" };
16
- /**
17
- * Super minifiable localStorage wrapper with SSR safety
18
- */
19
- var ls = function (method, key, value) {
20
- return isBrowser_1.isBrowser
21
- ? localStorage[methodsMap[method]](key, value)
22
- : function () {
23
- if (process.env["NODE_ENV"] !== "production") {
24
- console.warn("[@koine/utils] createStorage: localStorage does not exists in this environment.");
25
- }
26
- };
27
- };
28
- var keys = Object.keys(config).reduce(function (map, key) {
29
- var _a;
30
- return (tslib_1.__assign(tslib_1.__assign({}, map), (_a = {}, _a[key] = (0, encode_1.encode)(key), _a)));
31
- }, {});
32
- return {
33
- /**
34
- * Get all storage value (it uses `localStorage.get()`).
35
- *
36
- * Unparseable values with `JSON.parse()` return their value as it is.
37
- * If the given `key` argument is not found `null` is returned.
38
- */
39
- get: function (key) {
40
- var stored = ls("g", keys[key]);
41
- if (stored) {
42
- stored = (0, decode_1.decode)(stored);
43
- try {
44
- return JSON.parse(stored);
45
- }
46
- catch (_e) {
47
- return stored;
48
- }
49
- }
50
- return null;
51
- },
52
- /**
53
- * Get all storage values (it uses `localStorage.get()`).
54
- *
55
- * `undefined` and `null` values are not returned.
56
- */
57
- getAll: function () {
58
- var all = {};
59
- for (var key in keys) {
60
- var value = this.get(key);
61
- if (!(0, isNullOrUndefined_1.isNullOrUndefined)(value)) {
62
- all[key] = value;
63
- }
64
- }
65
- return all;
66
- },
67
- /**
68
- * Set a storage value (it uses `localStorage.set()`).
69
- *
70
- * Non-string values are stringified with `JSON.stringify()`
71
- */
72
- set: function (key, value) {
73
- ls("s", keys[key], (0, isString_1.isString)(value) ? (0, encode_1.encode)(value) : (0, encode_1.encode)(JSON.stringify(value)));
74
- },
75
- /**
76
- * Set all given storage values (it uses `localStorage.set()`).
77
- *
78
- * Non-string values are stringified with `JSON.stringify()`, `undefined`
79
- * and `null` values are removed from the storage
80
- */
81
- setMany: function (newValues) {
82
- for (var key in newValues) {
83
- var value = newValues[key];
84
- if (!(0, isNullOrUndefined_1.isNullOrUndefined)(value)) {
85
- this.set(key, value);
86
- }
87
- else {
88
- this.remove(key);
89
- }
90
- }
91
- },
92
- /**
93
- * Check if a storage value is _truthy_ (it uses `localStorage.get()`).
94
- */
95
- has: function (key) {
96
- var stored = ls("g", keys[key]);
97
- return !!stored;
98
- },
99
- /**
100
- * Remove a storage value (it uses `localStorage.remove()`).
101
- */
102
- remove: function (key) {
103
- ls("r", keys[key]);
104
- },
105
- /**
106
- * Clear all storage values (it uses `localStorage.remove()`).
107
- */
108
- clear: function () {
109
- for (var key in keys) {
110
- ls("r", keys[key]);
111
- }
112
- },
113
- /**
114
- * Watch a storage value changes, this needs to be executed only in browser
115
- * context (it uses `window.addEventListener("storage")`).
116
- *
117
- * Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
118
- */
119
- watch: function (keyToWatch, onRemoved, onAdded) {
120
- var handler = function (event) {
121
- var key = event.key, oldValue = event.oldValue, newValue = event.newValue;
122
- if (key === keys[keyToWatch]) {
123
- if (oldValue && !newValue) {
124
- onRemoved === null || onRemoved === void 0 ? void 0 : onRemoved();
125
- }
126
- else if (!oldValue && newValue) {
127
- onAdded === null || onAdded === void 0 ? void 0 : onAdded();
128
- }
129
- }
130
- };
131
- if (!isBrowser_1.isBrowser)
132
- return function () { return void 0; };
133
- window.addEventListener("storage", handler);
134
- return function () {
135
- window.removeEventListener("storage", handler);
136
- };
137
- },
138
- };
139
- };
140
- exports.createStorage = createStorage;
141
- exports.default = exports.createStorage;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getZonedDate = void 0;
4
- var tslib_1 = require("tslib");
5
- var utcToZonedTime_1 = tslib_1.__importDefault(require("date-fns-tz/utcToZonedTime"));
6
- var isBrowser_1 = tslib_1.__importDefault(require("./isBrowser"));
7
- /**
8
- * It returns a `Date` object from a date `string` adjusted on the user timeZone,
9
- * if a timeZone is not provided we try getting it from the `Intl` browwser native
10
- * API. It gracefully falls back returning a _non-timezone-based_ `Date`.
11
- *
12
- * @category date
13
- *
14
- * @resources
15
- * - to get the timeZone client side see [this article](https://attacomsian.com/blog/javascript-current-timezone)
16
- * - for converting the date based on the time zone [date-fns docs](https://date-fns.org/v2.27.0/docs/Time-Zones) and [date-fns-tz docs](https://github.com/marnusw/date-fns-tz)
17
- *
18
- * @param dateString A parseable date as string, `Z` is automatically suffixed if not present to correctly get time zone based time from a UTC date.
19
- * @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
20
- */
21
- function getZonedDate(dateString, timeZone) {
22
- if (dateString === void 0) { dateString = ""; }
23
- if (!dateString.endsWith("Z"))
24
- dateString += "Z";
25
- if (!timeZone && isBrowser_1.default) {
26
- try {
27
- timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
28
- }
29
- catch (e) {
30
- if (process.env["NODE_ENV"] !== "production") {
31
- console.warn("[@koine/utils:getZonedDate] failed reading timeZone, error", e);
32
- }
33
- // no need to do anything here, it just means `Intl` failed, probably
34
- // because the browser does not support it
35
- }
36
- }
37
- return timeZone
38
- ? (0, utcToZonedTime_1.default)(new Date(dateString), timeZone)
39
- : new Date(dateString);
40
- }
41
- exports.getZonedDate = getZonedDate;
42
- exports.default = getZonedDate;
package/node/isIE.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isIE = void 0;
4
- var isServer_1 = require("./isServer");
5
- /**
6
- * @category detect
7
- * @category is
8
- * @see https://stackoverflow.com/a/21712356/12285349
9
- */
10
- function isIE(ssrValue) {
11
- if (ssrValue === void 0) { ssrValue = true; }
12
- if (isServer_1.isServer) {
13
- return ssrValue;
14
- }
15
- var ua = window.navigator.userAgent;
16
- if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0) {
17
- return true;
18
- }
19
- return false;
20
- }
21
- exports.isIE = isIE;
22
- exports.default = isIE;
package/node/isMobile.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMobile = void 0;
4
- var isServer_1 = require("./isServer");
5
- /**
6
- * @category detect
7
- * @category is
8
- * @see https://stackoverflow.com/a/3540295
9
- */
10
- function isMobile(ssrValue) {
11
- if (ssrValue === void 0) { ssrValue = true; }
12
- if (isServer_1.isServer) {
13
- return ssrValue;
14
- }
15
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
16
- // return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
17
- // || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)
18
- }
19
- exports.isMobile = isMobile;
20
- exports.default = isMobile;
@@ -1,16 +0,0 @@
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;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateToHashParams = void 0;
4
- var tslib_1 = require("tslib");
5
- var buildUrlQueryString_1 = tslib_1.__importDefault(require("./buildUrlQueryString"));
6
- var getUrlHashPathname_1 = tslib_1.__importDefault(require("./getUrlHashPathname"));
7
- /**
8
- * It updates the `location.hash` with the given query params, it uses `location.hash`
9
- * if a second argument `hash` is not provded
10
- *
11
- * @category location
12
- */
13
- function navigateToHashParams(params, hash) {
14
- if (params === void 0) { params = {}; }
15
- if (hash === void 0) { hash = ""; }
16
- var useLocation = !hash;
17
- hash = hash || location.hash;
18
- var hashQueryLess = (0, getUrlHashPathname_1.default)(hash);
19
- var queryString = typeof params === "string" ? params : (0, buildUrlQueryString_1.default)(params);
20
- var newHash = "#/" + hashQueryLess + queryString;
21
- if (useLocation) {
22
- location.hash = newHash;
23
- }
24
- return newHash;
25
- }
26
- exports.navigateToHashParams = navigateToHashParams;
27
- exports.default = navigateToHashParams;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateToMergedHashParams = void 0;
4
- var tslib_1 = require("tslib");
5
- var getUrlHashParams_1 = tslib_1.__importDefault(require("./getUrlHashParams"));
6
- var mergeUrlQueryParams_1 = tslib_1.__importDefault(require("./mergeUrlQueryParams"));
7
- var navigateToHashParams_1 = tslib_1.__importDefault(require("./navigateToHashParams"));
8
- /**
9
- * It updates the "query params" within the `location.hash`, it uses `location`
10
- *
11
- * @category location
12
- */
13
- function navigateToMergedHashParams(params, hash) {
14
- if (params === void 0) { params = {}; }
15
- if (hash === void 0) { hash = ""; }
16
- return (0, navigateToHashParams_1.default)((0, mergeUrlQueryParams_1.default)((0, getUrlHashParams_1.default)(hash), params), hash);
17
- }
18
- exports.navigateToMergedHashParams = navigateToMergedHashParams;
19
- exports.default = navigateToMergedHashParams;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateToMergedParams = void 0;
4
- var tslib_1 = require("tslib");
5
- var getUrlQueryParams_1 = tslib_1.__importDefault(require("./getUrlQueryParams"));
6
- var mergeUrlQueryParams_1 = tslib_1.__importDefault(require("./mergeUrlQueryParams"));
7
- var navigateToParams_1 = tslib_1.__importDefault(require("./navigateToParams"));
8
- /**
9
- * Merge current URL query parameters with the given ones, it uses `history`.
10
- *
11
- * @category location
12
- * @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
13
- */
14
- function navigateToMergedParams(params, replace) {
15
- if (params === void 0) { params = {}; }
16
- return (0, navigateToParams_1.default)((0, mergeUrlQueryParams_1.default)((0, getUrlQueryParams_1.default)(), params), replace);
17
- }
18
- exports.navigateToMergedParams = navigateToMergedParams;
19
- exports.default = navigateToMergedParams;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateToParams = void 0;
4
- var tslib_1 = require("tslib");
5
- var buildUrlQueryString_1 = tslib_1.__importDefault(require("./buildUrlQueryString"));
6
- var isBrowser_1 = tslib_1.__importDefault(require("./isBrowser"));
7
- /**
8
- * Change current URL query parameters, it uses `history`.
9
- *
10
- * @category location
11
- * @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
12
- * @returns The query string with initial `?`
13
- */
14
- function navigateToParams(params, replace) {
15
- if (params === void 0) { params = {}; }
16
- var queryString = typeof params === "string" ? params : (0, buildUrlQueryString_1.default)(params);
17
- if (isBrowser_1.default) {
18
- history[replace ? "replaceState" : "pushState"](null, "", location.pathname + queryString);
19
- }
20
- return queryString;
21
- }
22
- exports.navigateToParams = navigateToParams;
23
- exports.default = navigateToParams;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateWithoutUrlParam = void 0;
4
- var tslib_1 = require("tslib");
5
- var getUrlQueryParams_1 = tslib_1.__importDefault(require("./getUrlQueryParams"));
6
- var navigateToParams_1 = tslib_1.__importDefault(require("./navigateToParams"));
7
- /**
8
- * Remove URL query parameter, it uses `history`
9
- *
10
- * @category location
11
- * @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
12
- */
13
- function navigateWithoutUrlParam(paramName, replace) {
14
- var params = {};
15
- var currentParams = (0, getUrlQueryParams_1.default)();
16
- for (var key in currentParams) {
17
- if (key !== paramName) {
18
- params[key] = currentParams[key];
19
- }
20
- }
21
- return (0, navigateToParams_1.default)(params, replace);
22
- }
23
- exports.navigateWithoutUrlParam = navigateWithoutUrlParam;
24
- exports.default = navigateWithoutUrlParam;
package/node/pageview.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pageview = void 0;
4
- var tslib_1 = require("tslib");
5
- var isUndefined_1 = tslib_1.__importDefault(require("./isUndefined"));
6
- /**
7
- * @category analytics-google
8
- */
9
- var pageview = function () {
10
- var args = [];
11
- for (var _i = 0; _i < arguments.length; _i++) {
12
- args[_i] = arguments[_i];
13
- }
14
- if (!(0, isUndefined_1.default)(window) && !(0, isUndefined_1.default)(window.gtag)) {
15
- window.gtag("event", "page_view", {
16
- page_path: args[0] || location.pathname,
17
- page_title: args[1] || document.title,
18
- page_location: args[2] || location.href,
19
- // send_to: '<GA_MEASUREMENT_ID>'
20
- });
21
- }
22
- };
23
- exports.pageview = pageview;
24
- // export type GtmEventArgs = [
25
- // eventCategory?: string,
26
- // eventAction?: string,
27
- // eventLabel?: string,
28
- // eventValue?: string
29
- // ];
30
- // export const event = (...args: GtmEventArgs) => {
31
- // if (!isUndefined(window) && !isUndefined(window.gtag)) {
32
- // window.gtag("send", "event", ...args);
33
- // }
34
- // };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redirectTo = void 0;
4
- var tslib_1 = require("tslib");
5
- var buildUrlQueryString_1 = tslib_1.__importDefault(require("./buildUrlQueryString"));
6
- var isBrowser_1 = tslib_1.__importDefault(require("./isBrowser"));
7
- /**
8
- * Redirect to url with params {optionally}, removes eventual trailing question
9
- * marks from the given URL, it uses `location`
10
- *
11
- * @category location
12
- */
13
- function redirectTo(url, params) {
14
- if (isBrowser_1.default) {
15
- var queryString = (0, buildUrlQueryString_1.default)(params);
16
- location.href = url.replace(/\?+$/g, "") + queryString;
17
- }
18
- }
19
- exports.redirectTo = redirectTo;
20
- exports.default = redirectTo;