@mado/utils 0.4.0 → 0.4.1
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/capitalize.cjs +0 -2
- package/dist/capitalize.cjs.map +1 -1
- package/dist/capitalize.js +0 -2
- package/dist/capitalize.js.map +1 -1
- package/dist/debounce.cjs +1 -2
- package/dist/debounce.cjs.map +1 -1
- package/dist/debounce.d.cts +2 -1
- package/dist/debounce.d.ts +2 -1
- package/dist/debounce.js +1 -2
- package/dist/debounce.js.map +1 -1
- package/dist/index.cjs +19 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/invariant.cjs +14 -7
- package/dist/invariant.cjs.map +1 -1
- package/dist/invariant.js +14 -7
- package/dist/invariant.js.map +1 -1
- package/dist/is-nil.cjs +0 -2
- package/dist/is-nil.cjs.map +1 -1
- package/dist/is-nil.js +0 -2
- package/dist/is-nil.js.map +1 -1
- package/dist/is-object-like.cjs +1 -3
- package/dist/is-object-like.cjs.map +1 -1
- package/dist/is-object-like.js +1 -3
- package/dist/is-object-like.js.map +1 -1
- package/dist/is-plain-object.cjs +2 -4
- package/dist/is-plain-object.cjs.map +1 -1
- package/dist/is-plain-object.js +0 -2
- package/dist/is-plain-object.js.map +1 -1
- package/dist/remember.cjs +1 -3
- package/dist/remember.cjs.map +1 -1
- package/dist/remember.js +1 -3
- package/dist/remember.js.map +1 -1
- package/dist/storage-available.cjs +4 -3
- package/dist/storage-available.cjs.map +1 -1
- package/dist/storage-available.js +4 -3
- package/dist/storage-available.js.map +1 -1
- package/package.json +25 -19
package/dist/capitalize.cjs
CHANGED
package/dist/capitalize.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"capitalize.cjs","sources":["../src/capitalize.ts"],"sourcesContent":["export function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n"],"names":["capitalize","str","charAt","toUpperCase","substring"],"mappings":";;AAAO,SAASA,UAAUA,CAACC,GAAW,EAAU;AAC9C,EAAA,OAAOA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAGF,GAAG,CAACG,SAAS,CAAC,CAAC,CAAC;AACvD;;"}
|
package/dist/capitalize.js
CHANGED
package/dist/capitalize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"capitalize.js","sources":["../src/capitalize.ts"],"sourcesContent":["export function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n"],"names":["capitalize","str","charAt","toUpperCase","substring"],"mappings":"AAAO,SAASA,UAAUA,CAACC,GAAW,EAAU;AAC9C,EAAA,OAAOA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAGF,GAAG,CAACG,SAAS,CAAC,CAAC,CAAC;AACvD;;"}
|
package/dist/debounce.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/debounce.ts
|
|
4
3
|
function debounce(func, wait = 166) {
|
|
5
4
|
let timeout;
|
|
6
5
|
function debounced(...args) {
|
|
7
6
|
clearTimeout(timeout);
|
|
8
7
|
timeout = setTimeout(() => {
|
|
8
|
+
// @ts-ignore
|
|
9
9
|
func.apply(this, args);
|
|
10
10
|
}, wait);
|
|
11
11
|
}
|
|
@@ -17,4 +17,3 @@ function debounce(func, wait = 166) {
|
|
|
17
17
|
|
|
18
18
|
exports.debounce = debounce;
|
|
19
19
|
//# sourceMappingURL=debounce.cjs.map
|
|
20
|
-
//# sourceMappingURL=debounce.cjs.map
|
package/dist/debounce.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debounce.cjs","sources":["../src/debounce.ts"],"sourcesContent":["export interface Cancelable {\n cancel: () => void;\n}\n\nexport function debounce<T extends (...args: any[]) => any>(func: T, wait = 166): T & Cancelable {\n let timeout: ReturnType<typeof setTimeout>;\n\n function debounced(...args: Parameters<T>) {\n clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n // @ts-ignore\n func.apply(this, args);\n }, wait);\n }\n\n debounced.cancel = () => {\n clearTimeout(timeout);\n };\n\n return debounced as T & Cancelable;\n}\n"],"names":["debounce","func","wait","timeout","debounced","args","clearTimeout","setTimeout","apply","cancel"],"mappings":";;AAIO,SAASA,QAAQA,CAAoCC,IAAO,EAAEC,IAAI,GAAG,GAAG,EAAkB;AAC/F,EAAA,IAAIC,OAAsC;AAE1C,EAAA,SAASC,SAASA,CAAC,GAAGC,IAAmB,EAAE;IACzCC,YAAY,CAACH,OAAO,CAAC;IAErBA,OAAO,GAAGI,UAAU,CAAC,MAAM;AACzB;AACAN,MAAAA,IAAI,CAACO,KAAK,CAAC,IAAI,EAAEH,IAAI,CAAC;IACxB,CAAC,EAAEH,IAAI,CAAC;AACV,EAAA;EAEAE,SAAS,CAACK,MAAM,GAAG,MAAM;IACvBH,YAAY,CAACH,OAAO,CAAC;EACvB,CAAC;AAED,EAAA,OAAOC,SAAS;AAClB;;"}
|
package/dist/debounce.d.cts
CHANGED
package/dist/debounce.d.ts
CHANGED
package/dist/debounce.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// src/debounce.ts
|
|
2
1
|
function debounce(func, wait = 166) {
|
|
3
2
|
let timeout;
|
|
4
3
|
function debounced(...args) {
|
|
5
4
|
clearTimeout(timeout);
|
|
6
5
|
timeout = setTimeout(() => {
|
|
6
|
+
// @ts-ignore
|
|
7
7
|
func.apply(this, args);
|
|
8
8
|
}, wait);
|
|
9
9
|
}
|
|
@@ -15,4 +15,3 @@ function debounce(func, wait = 166) {
|
|
|
15
15
|
|
|
16
16
|
export { debounce };
|
|
17
17
|
//# sourceMappingURL=debounce.js.map
|
|
18
|
-
//# sourceMappingURL=debounce.js.map
|
package/dist/debounce.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debounce.js","sources":["../src/debounce.ts"],"sourcesContent":["export interface Cancelable {\n cancel: () => void;\n}\n\nexport function debounce<T extends (...args: any[]) => any>(func: T, wait = 166): T & Cancelable {\n let timeout: ReturnType<typeof setTimeout>;\n\n function debounced(...args: Parameters<T>) {\n clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n // @ts-ignore\n func.apply(this, args);\n }, wait);\n }\n\n debounced.cancel = () => {\n clearTimeout(timeout);\n };\n\n return debounced as T & Cancelable;\n}\n"],"names":["debounce","func","wait","timeout","debounced","args","clearTimeout","setTimeout","apply","cancel"],"mappings":"AAIO,SAASA,QAAQA,CAAoCC,IAAO,EAAEC,IAAI,GAAG,GAAG,EAAkB;AAC/F,EAAA,IAAIC,OAAsC;AAE1C,EAAA,SAASC,SAASA,CAAC,GAAGC,IAAmB,EAAE;IACzCC,YAAY,CAACH,OAAO,CAAC;IAErBA,OAAO,GAAGI,UAAU,CAAC,MAAM;AACzB;AACAN,MAAAA,IAAI,CAACO,KAAK,CAAC,IAAI,EAAEH,IAAI,CAAC;IACxB,CAAC,EAAEH,IAAI,CAAC;AACV,EAAA;EAEAE,SAAS,CAACK,MAAM,GAAG,MAAM;IACvBH,YAAY,CAACH,OAAO,CAAC;EACvB,CAAC;AAED,EAAA,OAAOC,SAAS;AAClB;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,63 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
3
|
+
var capitalize = require('./capitalize.cjs');
|
|
4
|
+
var debounce = require('./debounce.cjs');
|
|
5
|
+
var invariant = require('./invariant.cjs');
|
|
6
|
+
var isNil = require('./is-nil.cjs');
|
|
7
|
+
var isObjectLike = require('./is-object-like.cjs');
|
|
8
|
+
var isPlainObject = require('./is-plain-object.cjs');
|
|
9
|
+
var remember = require('./remember.cjs');
|
|
10
|
+
var storageAvailable = require('./storage-available.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
Object.keys(invariant_cjs).forEach(function (k) {
|
|
27
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return invariant_cjs[k]; }
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
Object.keys(isNil_cjs).forEach(function (k) {
|
|
33
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () { return isNil_cjs[k]; }
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
Object.keys(isObjectLike_cjs).forEach(function (k) {
|
|
39
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () { return isObjectLike_cjs[k]; }
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
Object.keys(isPlainObject_cjs).forEach(function (k) {
|
|
45
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return isPlainObject_cjs[k]; }
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
Object.keys(remember_cjs).forEach(function (k) {
|
|
51
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () { return remember_cjs[k]; }
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
Object.keys(storageAvailable_cjs).forEach(function (k) {
|
|
57
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function () { return storageAvailable_cjs[k]; }
|
|
60
|
-
});
|
|
61
|
-
});
|
|
14
|
+
exports.capitalize = capitalize.capitalize;
|
|
15
|
+
exports.debounce = debounce.debounce;
|
|
16
|
+
exports.InvariantError = invariant.InvariantError;
|
|
17
|
+
exports.invariant = invariant.invariant;
|
|
18
|
+
exports.invariantResponse = invariant.invariantResponse;
|
|
19
|
+
exports.isInvariantError = invariant.isInvariantError;
|
|
20
|
+
exports.isNil = isNil.isNil;
|
|
21
|
+
exports.isObjectLike = isObjectLike.isObjectLike;
|
|
22
|
+
exports.isPlainObject = isPlainObject.isPlainObject;
|
|
23
|
+
exports.remember = remember.remember;
|
|
24
|
+
exports.storageAvailable = storageAvailable.storageAvailable;
|
|
62
25
|
//# sourceMappingURL=index.cjs.map
|
|
63
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
export { capitalize } from './capitalize.js';
|
|
2
|
+
export { debounce } from './debounce.js';
|
|
3
|
+
export { InvariantError, invariant, invariantResponse, isInvariantError } from './invariant.js';
|
|
4
|
+
export { isNil } from './is-nil.js';
|
|
5
|
+
export { isObjectLike } from './is-object-like.js';
|
|
6
|
+
export { isPlainObject } from './is-plain-object.js';
|
|
7
|
+
export { remember } from './remember.js';
|
|
8
|
+
export { storageAvailable } from './storage-available.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/dist/invariant.cjs
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var InvariantError = class extends Error {
|
|
3
|
+
class InvariantError extends Error {
|
|
5
4
|
constructor(message) {
|
|
6
5
|
super(message);
|
|
7
|
-
this.name =
|
|
6
|
+
this.name = 'InvariantError';
|
|
8
7
|
}
|
|
9
|
-
}
|
|
8
|
+
}
|
|
10
9
|
function isInvariantError(error) {
|
|
11
10
|
return error instanceof InvariantError;
|
|
12
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @throws {InvariantError}
|
|
15
|
+
*/
|
|
13
16
|
function invariant(condition, message) {
|
|
14
17
|
if (!condition) {
|
|
15
|
-
throw new InvariantError(typeof message ===
|
|
18
|
+
throw new InvariantError(typeof message === 'function' ? message() : message);
|
|
16
19
|
}
|
|
17
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @throws {Response}
|
|
24
|
+
*/
|
|
18
25
|
function invariantResponse(condition, message, responseInit) {
|
|
19
26
|
if (!condition) {
|
|
20
|
-
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
28
|
+
throw new Response(typeof message === 'function' ? message() : message, {
|
|
21
29
|
status: 400,
|
|
22
30
|
...responseInit
|
|
23
31
|
});
|
|
@@ -29,4 +37,3 @@ exports.invariant = invariant;
|
|
|
29
37
|
exports.invariantResponse = invariantResponse;
|
|
30
38
|
exports.isInvariantError = isInvariantError;
|
|
31
39
|
//# sourceMappingURL=invariant.cjs.map
|
|
32
|
-
//# sourceMappingURL=invariant.cjs.map
|
package/dist/invariant.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"invariant.cjs","sources":["../src/invariant.ts"],"sourcesContent":["export class InvariantError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = 'InvariantError';\n }\n}\n\nexport function isInvariantError(error: unknown): error is InvariantError {\n return error instanceof InvariantError;\n}\n\n/**\n * @throws {InvariantError}\n */\nexport function invariant(condition: unknown, message: string | (() => string)): asserts condition {\n if (!condition) {\n throw new InvariantError(typeof message === 'function' ? message() : message);\n }\n}\n\n/**\n * @throws {Response}\n */\nexport function invariantResponse(\n condition: unknown,\n message: string | (() => string),\n responseInit?: ResponseInit,\n): asserts condition {\n if (!condition) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw new Response(typeof message === 'function' ? message() : message, {\n status: 400,\n ...responseInit,\n });\n }\n}\n"],"names":["InvariantError","Error","constructor","message","name","isInvariantError","error","invariant","condition","invariantResponse","responseInit","Response","status"],"mappings":";;AAAO,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IAEd,IAAI,CAACC,IAAI,GAAG,gBAAgB;AAC9B,EAAA;AACF;AAEO,SAASC,gBAAgBA,CAACC,KAAc,EAA2B;EACxE,OAAOA,KAAK,YAAYN,cAAc;AACxC;;AAEA;AACA;AACA;AACO,SAASO,SAASA,CAACC,SAAkB,EAAEL,OAAgC,EAAqB;EACjG,IAAI,CAACK,SAAS,EAAE;AACd,IAAA,MAAM,IAAIR,cAAc,CAAC,OAAOG,OAAO,KAAK,UAAU,GAAGA,OAAO,EAAE,GAAGA,OAAO,CAAC;AAC/E,EAAA;AACF;;AAEA;AACA;AACA;AACO,SAASM,iBAAiBA,CAC/BD,SAAkB,EAClBL,OAAgC,EAChCO,YAA2B,EACR;EACnB,IAAI,CAACF,SAAS,EAAE;AACd;AACA,IAAA,MAAM,IAAIG,QAAQ,CAAC,OAAOR,OAAO,KAAK,UAAU,GAAGA,OAAO,EAAE,GAAGA,OAAO,EAAE;AACtES,MAAAA,MAAM,EAAE,GAAG;MACX,GAAGF;AACL,KAAC,CAAC;AACJ,EAAA;AACF;;;;;"}
|
package/dist/invariant.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
var InvariantError = class extends Error {
|
|
1
|
+
class InvariantError extends Error {
|
|
3
2
|
constructor(message) {
|
|
4
3
|
super(message);
|
|
5
|
-
this.name =
|
|
4
|
+
this.name = 'InvariantError';
|
|
6
5
|
}
|
|
7
|
-
}
|
|
6
|
+
}
|
|
8
7
|
function isInvariantError(error) {
|
|
9
8
|
return error instanceof InvariantError;
|
|
10
9
|
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @throws {InvariantError}
|
|
13
|
+
*/
|
|
11
14
|
function invariant(condition, message) {
|
|
12
15
|
if (!condition) {
|
|
13
|
-
throw new InvariantError(typeof message ===
|
|
16
|
+
throw new InvariantError(typeof message === 'function' ? message() : message);
|
|
14
17
|
}
|
|
15
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @throws {Response}
|
|
22
|
+
*/
|
|
16
23
|
function invariantResponse(condition, message, responseInit) {
|
|
17
24
|
if (!condition) {
|
|
18
|
-
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
26
|
+
throw new Response(typeof message === 'function' ? message() : message, {
|
|
19
27
|
status: 400,
|
|
20
28
|
...responseInit
|
|
21
29
|
});
|
|
@@ -24,4 +32,3 @@ function invariantResponse(condition, message, responseInit) {
|
|
|
24
32
|
|
|
25
33
|
export { InvariantError, invariant, invariantResponse, isInvariantError };
|
|
26
34
|
//# sourceMappingURL=invariant.js.map
|
|
27
|
-
//# sourceMappingURL=invariant.js.map
|
package/dist/invariant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"invariant.js","sources":["../src/invariant.ts"],"sourcesContent":["export class InvariantError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = 'InvariantError';\n }\n}\n\nexport function isInvariantError(error: unknown): error is InvariantError {\n return error instanceof InvariantError;\n}\n\n/**\n * @throws {InvariantError}\n */\nexport function invariant(condition: unknown, message: string | (() => string)): asserts condition {\n if (!condition) {\n throw new InvariantError(typeof message === 'function' ? message() : message);\n }\n}\n\n/**\n * @throws {Response}\n */\nexport function invariantResponse(\n condition: unknown,\n message: string | (() => string),\n responseInit?: ResponseInit,\n): asserts condition {\n if (!condition) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw new Response(typeof message === 'function' ? message() : message, {\n status: 400,\n ...responseInit,\n });\n }\n}\n"],"names":["InvariantError","Error","constructor","message","name","isInvariantError","error","invariant","condition","invariantResponse","responseInit","Response","status"],"mappings":"AAAO,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IAEd,IAAI,CAACC,IAAI,GAAG,gBAAgB;AAC9B,EAAA;AACF;AAEO,SAASC,gBAAgBA,CAACC,KAAc,EAA2B;EACxE,OAAOA,KAAK,YAAYN,cAAc;AACxC;;AAEA;AACA;AACA;AACO,SAASO,SAASA,CAACC,SAAkB,EAAEL,OAAgC,EAAqB;EACjG,IAAI,CAACK,SAAS,EAAE;AACd,IAAA,MAAM,IAAIR,cAAc,CAAC,OAAOG,OAAO,KAAK,UAAU,GAAGA,OAAO,EAAE,GAAGA,OAAO,CAAC;AAC/E,EAAA;AACF;;AAEA;AACA;AACA;AACO,SAASM,iBAAiBA,CAC/BD,SAAkB,EAClBL,OAAgC,EAChCO,YAA2B,EACR;EACnB,IAAI,CAACF,SAAS,EAAE;AACd;AACA,IAAA,MAAM,IAAIG,QAAQ,CAAC,OAAOR,OAAO,KAAK,UAAU,GAAGA,OAAO,EAAE,GAAGA,OAAO,EAAE;AACtES,MAAAA,MAAM,EAAE,GAAG;MACX,GAAGF;AACL,KAAC,CAAC;AACJ,EAAA;AACF;;"}
|
package/dist/is-nil.cjs
CHANGED
package/dist/is-nil.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-nil.cjs","sources":["../src/is-nil.ts"],"sourcesContent":["export function isNil(value: unknown): value is null | undefined {\n return value == null;\n}\n"],"names":["isNil","value"],"mappings":";;AAAO,SAASA,KAAKA,CAACC,KAAc,EAA6B;EAC/D,OAAOA,KAAK,IAAI,IAAI;AACtB;;"}
|
package/dist/is-nil.js
CHANGED
package/dist/is-nil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-nil.js","sources":["../src/is-nil.ts"],"sourcesContent":["export function isNil(value: unknown): value is null | undefined {\n return value == null;\n}\n"],"names":["isNil","value"],"mappings":"AAAO,SAASA,KAAKA,CAACC,KAAc,EAA6B;EAC/D,OAAOA,KAAK,IAAI,IAAI;AACtB;;"}
|
package/dist/is-object-like.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/is-object-like.ts
|
|
4
3
|
function isObjectLike(value) {
|
|
5
|
-
return typeof value ===
|
|
4
|
+
return typeof value === 'object' && value !== null;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
exports.isObjectLike = isObjectLike;
|
|
9
8
|
//# sourceMappingURL=is-object-like.cjs.map
|
|
10
|
-
//# sourceMappingURL=is-object-like.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-object-like.cjs","sources":["../src/is-object-like.ts"],"sourcesContent":["export function isObjectLike(value: unknown): value is object {\n return typeof value === 'object' && value !== null;\n}\n"],"names":["isObjectLike","value"],"mappings":";;AAAO,SAASA,YAAYA,CAACC,KAAc,EAAmB;AAC5D,EAAA,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AACpD;;"}
|
package/dist/is-object-like.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// src/is-object-like.ts
|
|
2
1
|
function isObjectLike(value) {
|
|
3
|
-
return typeof value ===
|
|
2
|
+
return typeof value === 'object' && value !== null;
|
|
4
3
|
}
|
|
5
4
|
|
|
6
5
|
export { isObjectLike };
|
|
7
6
|
//# sourceMappingURL=is-object-like.js.map
|
|
8
|
-
//# sourceMappingURL=is-object-like.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-object-like.js","sources":["../src/is-object-like.ts"],"sourcesContent":["export function isObjectLike(value: unknown): value is object {\n return typeof value === 'object' && value !== null;\n}\n"],"names":["isObjectLike","value"],"mappings":"AAAO,SAASA,YAAYA,CAACC,KAAc,EAAmB;AAC5D,EAAA,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AACpD;;"}
|
package/dist/is-plain-object.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var isObjectLike = require('./is-object-like.cjs');
|
|
4
4
|
|
|
5
|
-
// src/is-plain-object.ts
|
|
6
5
|
function isPlainObject(value) {
|
|
7
|
-
if (!
|
|
6
|
+
if (!isObjectLike.isObjectLike(value)) {
|
|
8
7
|
return false;
|
|
9
8
|
}
|
|
10
9
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -13,4 +12,3 @@ function isPlainObject(value) {
|
|
|
13
12
|
|
|
14
13
|
exports.isPlainObject = isPlainObject;
|
|
15
14
|
//# sourceMappingURL=is-plain-object.cjs.map
|
|
16
|
-
//# sourceMappingURL=is-plain-object.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-plain-object.cjs","sources":["../src/is-plain-object.ts"],"sourcesContent":["import { isObjectLike } from './is-object-like';\n\nexport function isPlainObject(value: unknown): value is object {\n if (!isObjectLike(value)) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return (\n (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) &&\n !(Symbol.toStringTag in value) &&\n !(Symbol.iterator in value)\n );\n}\n"],"names":["isPlainObject","value","isObjectLike","prototype","Object","getPrototypeOf","Symbol","toStringTag","iterator"],"mappings":";;;;AAEO,SAASA,aAAaA,CAACC,KAAc,EAAmB;AAC7D,EAAA,IAAI,CAACC,yBAAY,CAACD,KAAK,CAAC,EAAE;AACxB,IAAA,OAAO,KAAK;AACd,EAAA;AAEA,EAAA,MAAME,SAAS,GAAGC,MAAM,CAACC,cAAc,CAACJ,KAAK,CAAC;AAE9C,EAAA,OACE,CAACE,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKC,MAAM,CAACD,SAAS,IAAIC,MAAM,CAACC,cAAc,CAACF,SAAS,CAAC,KAAK,IAAI,KAClG,EAAEG,MAAM,CAACC,WAAW,IAAIN,KAAK,CAAC,IAC9B,EAAEK,MAAM,CAACE,QAAQ,IAAIP,KAAK,CAAC;AAE/B;;"}
|
package/dist/is-plain-object.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isObjectLike } from './is-object-like.js';
|
|
2
2
|
|
|
3
|
-
// src/is-plain-object.ts
|
|
4
3
|
function isPlainObject(value) {
|
|
5
4
|
if (!isObjectLike(value)) {
|
|
6
5
|
return false;
|
|
@@ -11,4 +10,3 @@ function isPlainObject(value) {
|
|
|
11
10
|
|
|
12
11
|
export { isPlainObject };
|
|
13
12
|
//# sourceMappingURL=is-plain-object.js.map
|
|
14
|
-
//# sourceMappingURL=is-plain-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-plain-object.js","sources":["../src/is-plain-object.ts"],"sourcesContent":["import { isObjectLike } from './is-object-like';\n\nexport function isPlainObject(value: unknown): value is object {\n if (!isObjectLike(value)) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return (\n (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) &&\n !(Symbol.toStringTag in value) &&\n !(Symbol.iterator in value)\n );\n}\n"],"names":["isPlainObject","value","isObjectLike","prototype","Object","getPrototypeOf","Symbol","toStringTag","iterator"],"mappings":";;AAEO,SAASA,aAAaA,CAACC,KAAc,EAAmB;AAC7D,EAAA,IAAI,CAACC,YAAY,CAACD,KAAK,CAAC,EAAE;AACxB,IAAA,OAAO,KAAK;AACd,EAAA;AAEA,EAAA,MAAME,SAAS,GAAGC,MAAM,CAACC,cAAc,CAACJ,KAAK,CAAC;AAE9C,EAAA,OACE,CAACE,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKC,MAAM,CAACD,SAAS,IAAIC,MAAM,CAACC,cAAc,CAACF,SAAS,CAAC,KAAK,IAAI,KAClG,EAAEG,MAAM,CAACC,WAAW,IAAIN,KAAK,CAAC,IAC9B,EAAEK,MAAM,CAACE,QAAQ,IAAIP,KAAK,CAAC;AAE/B;;"}
|
package/dist/remember.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/remember.ts
|
|
4
3
|
function remember(name, getValue) {
|
|
5
4
|
const ctx = globalThis;
|
|
6
5
|
if (!ctx.__remember) {
|
|
7
|
-
ctx.__remember =
|
|
6
|
+
ctx.__remember = new Map();
|
|
8
7
|
}
|
|
9
8
|
if (!ctx.__remember.has(name)) {
|
|
10
9
|
ctx.__remember.set(name, getValue());
|
|
@@ -14,4 +13,3 @@ function remember(name, getValue) {
|
|
|
14
13
|
|
|
15
14
|
exports.remember = remember;
|
|
16
15
|
//# sourceMappingURL=remember.cjs.map
|
|
17
|
-
//# sourceMappingURL=remember.cjs.map
|
package/dist/remember.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"remember.cjs","sources":["../src/remember.ts"],"sourcesContent":["declare namespace globalThis {\n // eslint-disable-next-line no-var\n var __remember: Map<string, any> | undefined;\n}\n\nexport function remember<T>(name: string, getValue: () => T): T {\n const ctx = globalThis;\n\n if (!ctx.__remember) {\n ctx.__remember = new Map();\n }\n\n if (!ctx.__remember.has(name)) {\n ctx.__remember.set(name, getValue());\n }\n\n return ctx.__remember.get(name) as T;\n}\n"],"names":["remember","name","getValue","ctx","globalThis","__remember","Map","has","set","get"],"mappings":";;AAKO,SAASA,QAAQA,CAAIC,IAAY,EAAEC,QAAiB,EAAK;EAC9D,MAAMC,GAAG,GAAGC,UAAU;AAEtB,EAAA,IAAI,CAACD,GAAG,CAACE,UAAU,EAAE;AACnBF,IAAAA,GAAG,CAACE,UAAU,GAAG,IAAIC,GAAG,EAAE;AAC5B,EAAA;EAEA,IAAI,CAACH,GAAG,CAACE,UAAU,CAACE,GAAG,CAACN,IAAI,CAAC,EAAE;IAC7BE,GAAG,CAACE,UAAU,CAACG,GAAG,CAACP,IAAI,EAAEC,QAAQ,EAAE,CAAC;AACtC,EAAA;AAEA,EAAA,OAAOC,GAAG,CAACE,UAAU,CAACI,GAAG,CAACR,IAAI,CAAC;AACjC;;"}
|
package/dist/remember.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// src/remember.ts
|
|
2
1
|
function remember(name, getValue) {
|
|
3
2
|
const ctx = globalThis;
|
|
4
3
|
if (!ctx.__remember) {
|
|
5
|
-
ctx.__remember =
|
|
4
|
+
ctx.__remember = new Map();
|
|
6
5
|
}
|
|
7
6
|
if (!ctx.__remember.has(name)) {
|
|
8
7
|
ctx.__remember.set(name, getValue());
|
|
@@ -12,4 +11,3 @@ function remember(name, getValue) {
|
|
|
12
11
|
|
|
13
12
|
export { remember };
|
|
14
13
|
//# sourceMappingURL=remember.js.map
|
|
15
|
-
//# sourceMappingURL=remember.js.map
|
package/dist/remember.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"remember.js","sources":["../src/remember.ts"],"sourcesContent":["declare namespace globalThis {\n // eslint-disable-next-line no-var\n var __remember: Map<string, any> | undefined;\n}\n\nexport function remember<T>(name: string, getValue: () => T): T {\n const ctx = globalThis;\n\n if (!ctx.__remember) {\n ctx.__remember = new Map();\n }\n\n if (!ctx.__remember.has(name)) {\n ctx.__remember.set(name, getValue());\n }\n\n return ctx.__remember.get(name) as T;\n}\n"],"names":["remember","name","getValue","ctx","globalThis","__remember","Map","has","set","get"],"mappings":"AAKO,SAASA,QAAQA,CAAIC,IAAY,EAAEC,QAAiB,EAAK;EAC9D,MAAMC,GAAG,GAAGC,UAAU;AAEtB,EAAA,IAAI,CAACD,GAAG,CAACE,UAAU,EAAE;AACnBF,IAAAA,GAAG,CAACE,UAAU,GAAG,IAAIC,GAAG,EAAE;AAC5B,EAAA;EAEA,IAAI,CAACH,GAAG,CAACE,UAAU,CAACE,GAAG,CAACN,IAAI,CAAC,EAAE;IAC7BE,GAAG,CAACE,UAAU,CAACG,GAAG,CAACP,IAAI,EAAEC,QAAQ,EAAE,CAAC;AACtC,EAAA;AAEA,EAAA,OAAOC,GAAG,CAACE,UAAU,CAACI,GAAG,CAACR,IAAI,CAAC;AACjC;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage MDN}
|
|
5
|
+
*/
|
|
4
6
|
function storageAvailable(type) {
|
|
5
7
|
let storage;
|
|
6
8
|
try {
|
|
@@ -10,10 +12,9 @@ function storageAvailable(type) {
|
|
|
10
12
|
storage.removeItem(x);
|
|
11
13
|
return true;
|
|
12
14
|
} catch (e) {
|
|
13
|
-
return e instanceof DOMException && e.name ===
|
|
15
|
+
return e instanceof DOMException && e.name === 'QuotaExceededError' && !!storage && storage.length !== 0;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
exports.storageAvailable = storageAvailable;
|
|
18
20
|
//# sourceMappingURL=storage-available.cjs.map
|
|
19
|
-
//# sourceMappingURL=storage-available.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"storage-available.cjs","sources":["../src/storage-available.ts"],"sourcesContent":["/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage MDN}\n */\nexport function storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean {\n let storage;\n\n try {\n storage = window[type];\n\n const x = `__${type}__`;\n storage.setItem(x, x);\n storage.removeItem(x);\n\n return true;\n } catch (e) {\n return e instanceof DOMException && e.name === 'QuotaExceededError' && !!storage && storage.length !== 0;\n }\n}\n"],"names":["storageAvailable","type","storage","window","x","setItem","removeItem","e","DOMException","name","length"],"mappings":";;AAAA;AACA;AACA;AACO,SAASA,gBAAgBA,CAACC,IAAuC,EAAW;AACjF,EAAA,IAAIC,OAAO;EAEX,IAAI;AACFA,IAAAA,OAAO,GAAGC,MAAM,CAACF,IAAI,CAAC;AAEtB,IAAA,MAAMG,CAAC,GAAG,CAAA,EAAA,EAAKH,IAAI,CAAA,EAAA,CAAI;AACvBC,IAAAA,OAAO,CAACG,OAAO,CAACD,CAAC,EAAEA,CAAC,CAAC;AACrBF,IAAAA,OAAO,CAACI,UAAU,CAACF,CAAC,CAAC;AAErB,IAAA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOG,CAAC,EAAE;AACV,IAAA,OAAOA,CAAC,YAAYC,YAAY,IAAID,CAAC,CAACE,IAAI,KAAK,oBAAoB,IAAI,CAAC,CAACP,OAAO,IAAIA,OAAO,CAACQ,MAAM,KAAK,CAAC;AAC1G,EAAA;AACF;;"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage MDN}
|
|
3
|
+
*/
|
|
2
4
|
function storageAvailable(type) {
|
|
3
5
|
let storage;
|
|
4
6
|
try {
|
|
@@ -8,10 +10,9 @@ function storageAvailable(type) {
|
|
|
8
10
|
storage.removeItem(x);
|
|
9
11
|
return true;
|
|
10
12
|
} catch (e) {
|
|
11
|
-
return e instanceof DOMException && e.name ===
|
|
13
|
+
return e instanceof DOMException && e.name === 'QuotaExceededError' && !!storage && storage.length !== 0;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export { storageAvailable };
|
|
16
18
|
//# sourceMappingURL=storage-available.js.map
|
|
17
|
-
//# sourceMappingURL=storage-available.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"storage-available.js","sources":["../src/storage-available.ts"],"sourcesContent":["/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage MDN}\n */\nexport function storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean {\n let storage;\n\n try {\n storage = window[type];\n\n const x = `__${type}__`;\n storage.setItem(x, x);\n storage.removeItem(x);\n\n return true;\n } catch (e) {\n return e instanceof DOMException && e.name === 'QuotaExceededError' && !!storage && storage.length !== 0;\n }\n}\n"],"names":["storageAvailable","type","storage","window","x","setItem","removeItem","e","DOMException","name","length"],"mappings":"AAAA;AACA;AACA;AACO,SAASA,gBAAgBA,CAACC,IAAuC,EAAW;AACjF,EAAA,IAAIC,OAAO;EAEX,IAAI;AACFA,IAAAA,OAAO,GAAGC,MAAM,CAACF,IAAI,CAAC;AAEtB,IAAA,MAAMG,CAAC,GAAG,CAAA,EAAA,EAAKH,IAAI,CAAA,EAAA,CAAI;AACvBC,IAAAA,OAAO,CAACG,OAAO,CAACD,CAAC,EAAEA,CAAC,CAAC;AACrBF,IAAAA,OAAO,CAACI,UAAU,CAACF,CAAC,CAAC;AAErB,IAAA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOG,CAAC,EAAE;AACV,IAAA,OAAOA,CAAC,YAAYC,YAAY,IAAID,CAAC,CAACE,IAAI,KAAK,oBAAoB,IAAI,CAAC,CAACP,OAAO,IAAIA,OAAO,CAACQ,MAAM,KAAK,CAAC;AAC1G,EAAA;AACF;;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mado/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"homepage": "https://github.com/doinki/mado/tree/main/packages/mado-utils#readme",
|
|
5
|
+
"bugs": "https://github.com/doinki/mado/issues",
|
|
4
6
|
"license": "MIT",
|
|
5
|
-
"
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "doinki",
|
|
9
|
+
"email": "doinki94@gmail.com",
|
|
10
|
+
"url": "https://github.com/doinki"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/doinki/mado.git",
|
|
15
|
+
"directory": "packages/mado-utils"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
6
20
|
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
7
22
|
"main": "./dist/index.cjs",
|
|
8
23
|
"module": "./dist/index.js",
|
|
9
24
|
"types": "./dist/index.d.ts",
|
|
@@ -20,29 +35,20 @@
|
|
|
20
35
|
},
|
|
21
36
|
"./package.json": "./package.json"
|
|
22
37
|
},
|
|
23
|
-
"author": {
|
|
24
|
-
"email": "doinki94@gmail.com",
|
|
25
|
-
"name": "doinki",
|
|
26
|
-
"url": "https://github.com/doinki"
|
|
27
|
-
},
|
|
28
|
-
"bugs": "https://github.com/doinki/mado/issues",
|
|
29
|
-
"files": [
|
|
30
|
-
"dist"
|
|
31
|
-
],
|
|
32
|
-
"homepage": "https://github.com/doinki/mado/tree/main/packages/mado-utils#readme",
|
|
33
|
-
"repository": {
|
|
34
|
-
"directory": "packages/mado-utils",
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/doinki/mado.git"
|
|
37
|
-
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@babel/runtime": "^7.29.10"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@vitest/coverage-istanbul": "^5.0.5",
|
|
46
|
+
"happy-dom": "^21.0.3"
|
|
47
|
+
},
|
|
41
48
|
"scripts": {
|
|
42
|
-
"build": "
|
|
49
|
+
"build": "rimraf dist && rollup -c --environment NODE_ENV:production",
|
|
43
50
|
"test": "vitest run",
|
|
44
51
|
"test:coverage": "vitest run --coverage",
|
|
45
|
-
"lint": "eslint",
|
|
46
52
|
"publint": "publint",
|
|
47
53
|
"typecheck": "tsc --noEmit"
|
|
48
54
|
}
|