@bccampus/utils 0.2.2 → 0.3.0
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 +3 -8
- package/dist/array/chunk.cjs +13 -5
- package/dist/array/chunk.d.ts +7 -0
- package/dist/array/chunk.js +14 -7
- package/dist/array/chunk.test.d.ts +1 -0
- package/dist/date/iso-date-time/constants.cjs +27 -0
- package/dist/date/iso-date-time/constants.d.ts +9 -0
- package/dist/date/iso-date-time/constants.js +19 -0
- package/dist/date/iso-date-time/index.cjs +8 -0
- package/dist/date/iso-date-time/index.d.ts +5 -0
- package/dist/date/iso-date-time/index.js +3 -0
- package/dist/date/iso-date-time/iso-date-time.arithmetic.test.d.ts +1 -0
- package/dist/date/iso-date-time/iso-date-time.cjs +232 -0
- package/dist/date/{iso-date-time.d.ts → iso-date-time/iso-date-time.d.ts} +3 -32
- package/dist/date/iso-date-time/iso-date-time.format.test.d.ts +1 -0
- package/dist/date/iso-date-time/iso-date-time.js +231 -0
- package/dist/date/iso-date-time/iso-date-time.test.d.ts +1 -0
- package/dist/date/iso-date-time/types.cjs +0 -0
- package/dist/date/iso-date-time/types.d.ts +25 -0
- package/dist/date/iso-date-time/types.js +0 -0
- package/dist/duration/add-durations.cjs +5 -8
- package/dist/duration/add-durations.js +5 -9
- package/dist/duration/duration.test.d.ts +1 -0
- package/dist/duration/is-duration.cjs +4 -3
- package/dist/duration/is-duration.js +5 -5
- package/dist/duration/to-number.cjs +11 -10
- package/dist/duration/to-number.d.ts +1 -1
- package/dist/duration/to-number.js +11 -11
- package/dist/format/formatter.cjs +31 -31
- package/dist/format/formatter.d.ts +4 -4
- package/dist/format/formatter.js +32 -37
- package/dist/format/formatter.test.d.ts +1 -0
- package/dist/format/stringfy.test.d.ts +1 -0
- package/dist/format/stringify.cjs +34 -40
- package/dist/format/stringify.d.ts +1 -1
- package/dist/format/stringify.js +35 -42
- package/dist/format/template.cjs +25 -32
- package/dist/format/template.d.ts +3 -3
- package/dist/format/template.js +24 -33
- package/dist/format/template.test.d.ts +1 -0
- package/dist/index.cjs +0 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -4
- package/dist/object/get.cjs +5 -5
- package/dist/object/get.d.ts +1 -1
- package/dist/object/get.js +6 -7
- package/dist/object/get.test.d.ts +1 -0
- package/dist/object/is-object.cjs +5 -2
- package/dist/object/is-object.d.ts +1 -1
- package/dist/object/is-object.js +6 -4
- package/dist/object/is-object.test.d.ts +1 -0
- package/dist/object/omit.cjs +14 -16
- package/dist/object/omit.d.ts +1 -1
- package/dist/object/omit.js +15 -18
- package/dist/object/omit.test.d.ts +1 -0
- package/dist/object/pick.cjs +10 -9
- package/dist/object/pick.d.ts +1 -1
- package/dist/object/pick.js +9 -9
- package/dist/object/pick.test.d.ts +1 -0
- package/dist/object/set.cjs +13 -12
- package/dist/object/set.d.ts +1 -1
- package/dist/object/set.js +14 -14
- package/dist/object/set.test.d.ts +1 -0
- package/dist/path/file-url-to-path.cjs +10 -6
- package/dist/path/file-url-to-path.js +11 -8
- package/dist/path/file-url-to-path.test.d.ts +1 -0
- package/dist/path/normalize.cjs +41 -27
- package/dist/path/normalize.d.ts +8 -2
- package/dist/path/normalize.js +41 -28
- package/dist/path/normalize.test.d.ts +1 -0
- package/dist/set/difference.cjs +5 -6
- package/dist/set/difference.d.ts +1 -1
- package/dist/set/difference.js +6 -8
- package/dist/set/intersection.cjs +6 -9
- package/dist/set/intersection.d.ts +1 -1
- package/dist/set/intersection.js +7 -11
- package/dist/set/is-superset.cjs +5 -8
- package/dist/set/is-superset.d.ts +1 -1
- package/dist/set/is-superset.js +6 -10
- package/dist/set/set.test.d.ts +1 -0
- package/dist/set/symmetric-difference.cjs +6 -10
- package/dist/set/symmetric-difference.d.ts +1 -1
- package/dist/set/symmetric-difference.js +7 -12
- package/dist/set/union.cjs +5 -6
- package/dist/set/union.d.ts +1 -1
- package/dist/set/union.js +6 -8
- package/dist/string/capitalize.cjs +5 -2
- package/dist/string/capitalize.d.ts +1 -1
- package/dist/string/capitalize.js +6 -4
- package/dist/string/capitalize.test.d.ts +1 -0
- package/dist/string/normalize.cjs +7 -2
- package/dist/string/normalize.js +8 -4
- package/dist/string/normalize.test.d.ts +1 -0
- package/dist/string/pluralize/index.cjs +5 -4
- package/dist/string/pluralize/index.js +4 -5
- package/dist/string/pluralize/pluralize.cjs +162 -208
- package/dist/string/pluralize/pluralize.d.ts +4 -8
- package/dist/string/pluralize/pluralize.js +158 -205
- package/dist/string/pluralize/pluralize.test.d.ts +1 -0
- package/dist/string/pluralize/rules/index.cjs +8 -9
- package/dist/string/pluralize/rules/index.js +1 -6
- package/dist/string/pluralize/rules/irregular.cjs +55 -59
- package/dist/string/pluralize/rules/irregular.js +56 -61
- package/dist/string/pluralize/rules/pluralization.cjs +28 -36
- package/dist/string/pluralize/rules/pluralization.js +29 -38
- package/dist/string/pluralize/rules/singularization.cjs +27 -44
- package/dist/string/pluralize/rules/singularization.js +28 -46
- package/dist/string/pluralize/rules/uncountable.cjs +104 -110
- package/dist/string/pluralize/rules/uncountable.js +105 -112
- package/dist/string/pluralize/types.cjs +0 -1
- package/dist/string/pluralize/types.js +0 -1
- package/dist/string/slugify/index.cjs +2129 -2246
- package/dist/string/slugify/index.js +2130 -2248
- package/dist/string/slugify/slugify.test.d.ts +1 -0
- package/dist/string/strip-html-tags.cjs +4 -3
- package/dist/string/strip-html-tags.js +5 -5
- package/dist/string/strip-html-tags.test.d.ts +1 -0
- package/dist/string/to-int.cjs +14 -6
- package/dist/string/to-int.js +15 -8
- package/dist/string/to-int.test.d.ts +1 -0
- package/dist/string/to-sentence-case.cjs +6 -6
- package/dist/string/to-sentence-case.d.ts +1 -1
- package/dist/string/to-sentence-case.js +7 -8
- package/dist/string/to-sentence-case.test.d.ts +1 -0
- package/dist/string/trim.cjs +8 -7
- package/dist/string/trim.js +9 -9
- package/dist/string/trim.test.d.ts +1 -0
- package/dist/string/truncate.cjs +16 -15
- package/dist/string/truncate.js +17 -17
- package/dist/string/truncate.test.d.ts +1 -0
- package/dist/value/is-empty.cjs +30 -12
- package/dist/value/is-empty.d.ts +1 -1
- package/dist/value/is-empty.js +31 -14
- package/dist/value/value.test.d.ts +1 -0
- package/package.json +183 -67
- package/dist/array/index.cjs +0 -4
- package/dist/array/index.d.ts +0 -1
- package/dist/array/index.js +0 -4
- package/dist/date/index.cjs +0 -8
- package/dist/date/index.d.ts +0 -1
- package/dist/date/index.js +0 -8
- package/dist/date/iso-date-time.cjs +0 -256
- package/dist/date/iso-date-time.js +0 -256
- package/dist/duration/index.cjs +0 -8
- package/dist/duration/index.d.ts +0 -3
- package/dist/duration/index.js +0 -8
- package/dist/format/index.cjs +0 -13
- package/dist/format/index.d.ts +0 -3
- package/dist/format/index.js +0 -13
- package/dist/object/index.cjs +0 -12
- package/dist/object/index.d.ts +0 -5
- package/dist/object/index.js +0 -12
- package/dist/path/index.cjs +0 -6
- package/dist/path/index.d.ts +0 -2
- package/dist/path/index.js +0 -6
- package/dist/set/index.cjs +0 -12
- package/dist/set/index.d.ts +0 -5
- package/dist/set/index.js +0 -12
- package/dist/string/index.cjs +0 -14
- package/dist/string/index.d.ts +0 -6
- package/dist/string/index.js +0 -14
- package/dist/value/index.cjs +0 -4
- package/dist/value/index.d.ts +0 -1
- package/dist/value/index.js +0 -4
- package/eslint.config.js +0 -19
- package/src/array/chunk.ts +0 -6
- package/src/array/index.ts +0 -1
- package/src/date/index.ts +0 -1
- package/src/date/iso-date-time.ts +0 -356
- package/src/duration/add-durations.ts +0 -16
- package/src/duration/index.ts +0 -3
- package/src/duration/is-duration.ts +0 -5
- package/src/duration/to-number.ts +0 -18
- package/src/format/formatter.ts +0 -37
- package/src/format/index.ts +0 -3
- package/src/format/stringify.ts +0 -87
- package/src/format/template.ts +0 -48
- package/src/index.ts +0 -1
- package/src/object/get.ts +0 -9
- package/src/object/index.ts +0 -5
- package/src/object/is-object.ts +0 -2
- package/src/object/omit.ts +0 -21
- package/src/object/pick.ts +0 -10
- package/src/object/set.ts +0 -15
- package/src/path/file-url-to-path.ts +0 -12
- package/src/path/index.ts +0 -2
- package/src/path/normalize.ts +0 -72
- package/src/set/difference.ts +0 -9
- package/src/set/index.ts +0 -5
- package/src/set/intersection.ts +0 -12
- package/src/set/is-superset.ts +0 -12
- package/src/set/symmetric-difference.ts +0 -12
- package/src/set/union.ts +0 -8
- package/src/string/capitalize.ts +0 -2
- package/src/string/index.ts +0 -6
- package/src/string/normalize.ts +0 -7
- package/src/string/pluralize/index.ts +0 -7
- package/src/string/pluralize/pluralize.ts +0 -296
- package/src/string/pluralize/rules/index.ts +0 -4
- package/src/string/pluralize/rules/irregular.ts +0 -59
- package/src/string/pluralize/rules/pluralization.ts +0 -40
- package/src/string/pluralize/rules/singularization.ts +0 -46
- package/src/string/pluralize/rules/uncountable.ts +0 -107
- package/src/string/pluralize/types.ts +0 -4
- package/src/string/slugify/index.ts +0 -3
- package/src/string/strip-html-tags.ts +0 -4
- package/src/string/to-int.ts +0 -20
- package/src/string/to-sentence-case.ts +0 -6
- package/src/string/trim.ts +0 -11
- package/src/string/truncate.ts +0 -44
- package/src/value/index.ts +0 -1
- package/src/value/is-empty.ts +0 -31
- package/tsconfig.json +0 -18
- package/tsconfig.lib.json +0 -37
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
2
|
+
//#region src/string/strip-html-tags.ts
|
|
3
|
+
var htmlTagRegExp = /(<([^>]+)>)/g;
|
|
4
4
|
function stripHtmlTags(text) {
|
|
5
|
-
|
|
5
|
+
return text.replace(htmlTagRegExp, "");
|
|
6
6
|
}
|
|
7
|
+
//#endregion
|
|
7
8
|
exports.stripHtmlTags = stripHtmlTags;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/string/strip-html-tags.ts
|
|
2
|
+
var htmlTagRegExp = /(<([^>]+)>)/g;
|
|
2
3
|
function stripHtmlTags(text) {
|
|
3
|
-
|
|
4
|
+
return text.replace(htmlTagRegExp, "");
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { stripHtmlTags };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/string/to-int.cjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/string/to-int.ts
|
|
3
|
+
/**
|
|
4
|
+
* Converts a string (or a number) into a number.
|
|
5
|
+
* If the input can not be successfully converted, it will return the fallback.
|
|
6
|
+
* It will not return NaN.
|
|
7
|
+
* @param value - The value to convert
|
|
8
|
+
* @param fallback - The value to fallback to. Defaults to 0
|
|
9
|
+
* @returns number
|
|
10
|
+
*/
|
|
3
11
|
function stringToInt(value, fallback = 0) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return returnValue;
|
|
12
|
+
let returnValue = value;
|
|
13
|
+
if (typeof returnValue === "string") returnValue = Number.parseInt(returnValue);
|
|
14
|
+
if (Number.isNaN(returnValue)) returnValue = fallback;
|
|
15
|
+
return returnValue;
|
|
9
16
|
}
|
|
17
|
+
//#endregion
|
|
10
18
|
exports.stringToInt = stringToInt;
|
package/dist/string/to-int.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
//#region src/string/to-int.ts
|
|
2
|
+
/**
|
|
3
|
+
* Converts a string (or a number) into a number.
|
|
4
|
+
* If the input can not be successfully converted, it will return the fallback.
|
|
5
|
+
* It will not return NaN.
|
|
6
|
+
* @param value - The value to convert
|
|
7
|
+
* @param fallback - The value to fallback to. Defaults to 0
|
|
8
|
+
* @returns number
|
|
9
|
+
*/
|
|
1
10
|
function stringToInt(value, fallback = 0) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return returnValue;
|
|
11
|
+
let returnValue = value;
|
|
12
|
+
if (typeof returnValue === "string") returnValue = Number.parseInt(returnValue);
|
|
13
|
+
if (Number.isNaN(returnValue)) returnValue = fallback;
|
|
14
|
+
return returnValue;
|
|
7
15
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { stringToInt };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
//#region src/string/to-sentence-case.ts
|
|
3
|
+
var specialCharRegExp = /[\s\-_.+]+/g;
|
|
4
|
+
function toSentenceCase(s) {
|
|
5
|
+
return (s[0].toUpperCase() + s.slice(1).toLowerCase()).replace(specialCharRegExp, " ");
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
8
|
exports.toSentenceCase = toSentenceCase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function toSentenceCase<T extends string>(s: T): string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
1
|
+
//#region src/string/to-sentence-case.ts
|
|
2
|
+
var specialCharRegExp = /[\s\-_.+]+/g;
|
|
3
|
+
function toSentenceCase(s) {
|
|
4
|
+
return (s[0].toUpperCase() + s.slice(1).toLowerCase()).replace(specialCharRegExp, " ");
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { toSentenceCase };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/string/trim.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/string/trim.ts
|
|
3
3
|
function trim(text, chars = " ") {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let start = 0;
|
|
5
|
+
let end = text.length;
|
|
6
|
+
if (!Array.isArray(chars)) chars = [chars];
|
|
7
|
+
while (start < end && chars.includes(text[start])) start += 1;
|
|
8
|
+
while (end > start && chars.includes(text[end - 1])) end -= 1;
|
|
9
|
+
return start > 0 || end < text.length ? text.substring(start, end) : text;
|
|
10
10
|
}
|
|
11
|
+
//#endregion
|
|
11
12
|
exports.trim = trim;
|
package/dist/string/trim.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
//#region src/string/trim.ts
|
|
1
2
|
function trim(text, chars = " ") {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
let start = 0;
|
|
4
|
+
let end = text.length;
|
|
5
|
+
if (!Array.isArray(chars)) chars = [chars];
|
|
6
|
+
while (start < end && chars.includes(text[start])) start += 1;
|
|
7
|
+
while (end > start && chars.includes(text[end - 1])) end -= 1;
|
|
8
|
+
return start > 0 || end < text.length ? text.substring(start, end) : text;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { trim };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/string/truncate.cjs
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
//#region src/string/truncate.ts
|
|
3
|
+
var defaultOptions = {
|
|
4
|
+
ending: "...",
|
|
5
|
+
maxlength: 100,
|
|
6
|
+
noWordBreak: false
|
|
7
7
|
};
|
|
8
8
|
function truncate(text, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const conf = {
|
|
10
|
+
...defaultOptions,
|
|
11
|
+
...options
|
|
12
|
+
};
|
|
13
|
+
text = text.trim();
|
|
14
|
+
if (conf.noWordBreak) {
|
|
15
|
+
const lastSpaceIndex = text.indexOf(" ", conf.maxlength);
|
|
16
|
+
if (lastSpaceIndex >= conf.maxlength) return text.substring(0, lastSpaceIndex) + conf.ending;
|
|
17
|
+
} else if (text.length > conf.maxlength + conf.ending.length) return text.substring(0, conf.maxlength) + conf.ending;
|
|
18
|
+
return text;
|
|
19
19
|
}
|
|
20
|
+
//#endregion
|
|
20
21
|
exports.truncate = truncate;
|
package/dist/string/truncate.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/string/truncate.ts
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
ending: "...",
|
|
4
|
+
maxlength: 100,
|
|
5
|
+
noWordBreak: false
|
|
5
6
|
};
|
|
6
7
|
function truncate(text, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const conf = {
|
|
9
|
+
...defaultOptions,
|
|
10
|
+
...options
|
|
11
|
+
};
|
|
12
|
+
text = text.trim();
|
|
13
|
+
if (conf.noWordBreak) {
|
|
14
|
+
const lastSpaceIndex = text.indexOf(" ", conf.maxlength);
|
|
15
|
+
if (lastSpaceIndex >= conf.maxlength) return text.substring(0, lastSpaceIndex) + conf.ending;
|
|
16
|
+
} else if (text.length > conf.maxlength + conf.ending.length) return text.substring(0, conf.maxlength) + conf.ending;
|
|
17
|
+
return text;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { truncate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/value/is-empty.cjs
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
//#region src/value/is-empty.ts
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the value is `empty`
|
|
5
|
+
*
|
|
6
|
+
* returns `true`, if the value
|
|
7
|
+
*
|
|
8
|
+
* - `undefined`
|
|
9
|
+
* - `null`
|
|
10
|
+
* - `string` and there is no character in the string or all white space
|
|
11
|
+
* - `array` and there is no item in the array
|
|
12
|
+
* - `map` and there is no item in the map
|
|
13
|
+
* - `set` and there is no item in the set
|
|
14
|
+
* - `object` and there is no property in the object
|
|
15
|
+
*
|
|
16
|
+
* otherwise, false
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
function isEmpty(value) {
|
|
20
|
+
if (value === void 0) return true;
|
|
21
|
+
if (value === null) return true;
|
|
22
|
+
if (typeof value === "string") return value.trim() === "";
|
|
23
|
+
if (typeof value === "object") {
|
|
24
|
+
if (Array.isArray(value) && value.length === 0) return true;
|
|
25
|
+
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
|
26
|
+
if (value instanceof Date) return false;
|
|
27
|
+
return Object.keys(value).length === 0;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
14
32
|
exports.isEmpty = isEmpty;
|
package/dist/value/is-empty.d.ts
CHANGED
package/dist/value/is-empty.js
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
//#region src/value/is-empty.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the value is `empty`
|
|
4
|
+
*
|
|
5
|
+
* returns `true`, if the value
|
|
6
|
+
*
|
|
7
|
+
* - `undefined`
|
|
8
|
+
* - `null`
|
|
9
|
+
* - `string` and there is no character in the string or all white space
|
|
10
|
+
* - `array` and there is no item in the array
|
|
11
|
+
* - `map` and there is no item in the map
|
|
12
|
+
* - `set` and there is no item in the set
|
|
13
|
+
* - `object` and there is no property in the object
|
|
14
|
+
*
|
|
15
|
+
* otherwise, false
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
function isEmpty(value) {
|
|
19
|
+
if (value === void 0) return true;
|
|
20
|
+
if (value === null) return true;
|
|
21
|
+
if (typeof value === "string") return value.trim() === "";
|
|
22
|
+
if (typeof value === "object") {
|
|
23
|
+
if (Array.isArray(value) && value.length === 0) return true;
|
|
24
|
+
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
|
25
|
+
if (value instanceof Date) return false;
|
|
26
|
+
return Object.keys(value).length === 0;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { isEmpty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,54 +1,168 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bccampus/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "BCcampus' utility box",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
|
+
"packageManager": "yarn@4.16.0",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"_postinstall": "husky",
|
|
10
|
+
"prepack": "pinst --disable && yarn build",
|
|
11
|
+
"postpack": "pinst --enable",
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"lint": "eslint ./src",
|
|
14
|
+
"lint:fix": "eslint --fix ./src",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"coverage": "vitest run --reporter=minimal --coverage",
|
|
17
|
+
"build": "yarn typecheck && yarn lint && yarn coverage && vite build",
|
|
18
|
+
"publish": "yarn npm publish --access public --tolerate-republish"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@antfu/eslint-config": "^9.0.0",
|
|
22
|
+
"@types/node": "^24.13.0",
|
|
23
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
24
|
+
"baseline-browser-mapping": "^2.10.33",
|
|
25
|
+
"eslint": "^10.4.1",
|
|
26
|
+
"eslint-plugin-format": "^2.0.1",
|
|
27
|
+
"globals": "^17.6.0",
|
|
28
|
+
"husky": "^9.1.7",
|
|
29
|
+
"lint-staged": "^17.0.7",
|
|
30
|
+
"pinst": "^3.0.0",
|
|
31
|
+
"tinyglobby": "^0.2.17",
|
|
32
|
+
"typescript": "~6.0.3",
|
|
33
|
+
"unplugin-dts": "^1.0.2",
|
|
34
|
+
"vite": "^8.0.16",
|
|
35
|
+
"vitest": "^4.1.8"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@sindresorhus/slugify": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"lint-staged": {
|
|
41
|
+
"!(*test).ts": [
|
|
42
|
+
"vitest related --run",
|
|
43
|
+
"eslint --fix"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"main": "./dist/index.cjs",
|
|
47
|
+
"module": "./dist/index.js",
|
|
48
|
+
"files": [
|
|
49
|
+
"dist"
|
|
50
|
+
],
|
|
7
51
|
"exports": {
|
|
8
52
|
".": {
|
|
9
53
|
"types": "./dist/index.d.ts",
|
|
10
54
|
"import": "./dist/index.js",
|
|
11
55
|
"require": "./dist/index.cjs"
|
|
12
56
|
},
|
|
13
|
-
"./array": {
|
|
14
|
-
"types": "./dist/array/
|
|
15
|
-
"import": "./dist/array/
|
|
16
|
-
"require": "./dist/array/
|
|
17
|
-
},
|
|
18
|
-
"./date": {
|
|
19
|
-
"types": "./dist/date/index.d.ts",
|
|
20
|
-
"import": "./dist/date/index.js",
|
|
21
|
-
"require": "./dist/date/index.cjs"
|
|
22
|
-
},
|
|
23
|
-
"./duration": {
|
|
24
|
-
"types": "./dist/duration/
|
|
25
|
-
"import": "./dist/duration/
|
|
26
|
-
"require": "./dist/duration/
|
|
27
|
-
},
|
|
28
|
-
"./
|
|
29
|
-
"types": "./dist/
|
|
30
|
-
"import": "./dist/
|
|
31
|
-
"require": "./dist/
|
|
32
|
-
},
|
|
33
|
-
"./
|
|
34
|
-
"types": "./dist/
|
|
35
|
-
"import": "./dist/
|
|
36
|
-
"require": "./dist/
|
|
37
|
-
},
|
|
38
|
-
"./
|
|
39
|
-
"types": "./dist/
|
|
40
|
-
"import": "./dist/
|
|
41
|
-
"require": "./dist/
|
|
42
|
-
},
|
|
43
|
-
"./
|
|
44
|
-
"types": "./dist/
|
|
45
|
-
"import": "./dist/
|
|
46
|
-
"require": "./dist/
|
|
47
|
-
},
|
|
48
|
-
"./
|
|
49
|
-
"types": "./dist/
|
|
50
|
-
"import": "./dist/
|
|
51
|
-
"require": "./dist/
|
|
57
|
+
"./array/chunk": {
|
|
58
|
+
"types": "./dist/array/chunk.d.ts",
|
|
59
|
+
"import": "./dist/array/chunk.js",
|
|
60
|
+
"require": "./dist/array/chunk.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./date/iso-date-time": {
|
|
63
|
+
"types": "./dist/date/iso-date-time/index.d.ts",
|
|
64
|
+
"import": "./dist/date/iso-date-time/index.js",
|
|
65
|
+
"require": "./dist/date/iso-date-time/index.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./duration/add-durations": {
|
|
68
|
+
"types": "./dist/duration/add-durations.d.ts",
|
|
69
|
+
"import": "./dist/duration/add-durations.js",
|
|
70
|
+
"require": "./dist/duration/add-durations.cjs"
|
|
71
|
+
},
|
|
72
|
+
"./duration/is-duration": {
|
|
73
|
+
"types": "./dist/duration/is-duration.d.ts",
|
|
74
|
+
"import": "./dist/duration/is-duration.js",
|
|
75
|
+
"require": "./dist/duration/is-duration.cjs"
|
|
76
|
+
},
|
|
77
|
+
"./duration/to-number": {
|
|
78
|
+
"types": "./dist/duration/to-number.d.ts",
|
|
79
|
+
"import": "./dist/duration/to-number.js",
|
|
80
|
+
"require": "./dist/duration/to-number.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./format/formatter": {
|
|
83
|
+
"types": "./dist/format/formatter.d.ts",
|
|
84
|
+
"import": "./dist/format/formatter.js",
|
|
85
|
+
"require": "./dist/format/formatter.cjs"
|
|
86
|
+
},
|
|
87
|
+
"./format/stringify": {
|
|
88
|
+
"types": "./dist/format/stringify.d.ts",
|
|
89
|
+
"import": "./dist/format/stringify.js",
|
|
90
|
+
"require": "./dist/format/stringify.cjs"
|
|
91
|
+
},
|
|
92
|
+
"./format/template": {
|
|
93
|
+
"types": "./dist/format/template.d.ts",
|
|
94
|
+
"import": "./dist/format/template.js",
|
|
95
|
+
"require": "./dist/format/template.cjs"
|
|
96
|
+
},
|
|
97
|
+
"./object/get": {
|
|
98
|
+
"types": "./dist/object/get.d.ts",
|
|
99
|
+
"import": "./dist/object/get.js",
|
|
100
|
+
"require": "./dist/object/get.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./object/is-object": {
|
|
103
|
+
"types": "./dist/object/is-object.d.ts",
|
|
104
|
+
"import": "./dist/object/is-object.js",
|
|
105
|
+
"require": "./dist/object/is-object.cjs"
|
|
106
|
+
},
|
|
107
|
+
"./object/omit": {
|
|
108
|
+
"types": "./dist/object/omit.d.ts",
|
|
109
|
+
"import": "./dist/object/omit.js",
|
|
110
|
+
"require": "./dist/object/omit.cjs"
|
|
111
|
+
},
|
|
112
|
+
"./object/pick": {
|
|
113
|
+
"types": "./dist/object/pick.d.ts",
|
|
114
|
+
"import": "./dist/object/pick.js",
|
|
115
|
+
"require": "./dist/object/pick.cjs"
|
|
116
|
+
},
|
|
117
|
+
"./object/set": {
|
|
118
|
+
"types": "./dist/object/set.d.ts",
|
|
119
|
+
"import": "./dist/object/set.js",
|
|
120
|
+
"require": "./dist/object/set.cjs"
|
|
121
|
+
},
|
|
122
|
+
"./path/file-url-to-path": {
|
|
123
|
+
"types": "./dist/path/file-url-to-path.d.ts",
|
|
124
|
+
"import": "./dist/path/file-url-to-path.js",
|
|
125
|
+
"require": "./dist/path/file-url-to-path.cjs"
|
|
126
|
+
},
|
|
127
|
+
"./path/normalize": {
|
|
128
|
+
"types": "./dist/path/normalize.d.ts",
|
|
129
|
+
"import": "./dist/path/normalize.js",
|
|
130
|
+
"require": "./dist/path/normalize.cjs"
|
|
131
|
+
},
|
|
132
|
+
"./set/difference": {
|
|
133
|
+
"types": "./dist/set/difference.d.ts",
|
|
134
|
+
"import": "./dist/set/difference.js",
|
|
135
|
+
"require": "./dist/set/difference.cjs"
|
|
136
|
+
},
|
|
137
|
+
"./set/intersection": {
|
|
138
|
+
"types": "./dist/set/intersection.d.ts",
|
|
139
|
+
"import": "./dist/set/intersection.js",
|
|
140
|
+
"require": "./dist/set/intersection.cjs"
|
|
141
|
+
},
|
|
142
|
+
"./set/is-superset": {
|
|
143
|
+
"types": "./dist/set/is-superset.d.ts",
|
|
144
|
+
"import": "./dist/set/is-superset.js",
|
|
145
|
+
"require": "./dist/set/is-superset.cjs"
|
|
146
|
+
},
|
|
147
|
+
"./set/symmetric-difference": {
|
|
148
|
+
"types": "./dist/set/symmetric-difference.d.ts",
|
|
149
|
+
"import": "./dist/set/symmetric-difference.js",
|
|
150
|
+
"require": "./dist/set/symmetric-difference.cjs"
|
|
151
|
+
},
|
|
152
|
+
"./set/union": {
|
|
153
|
+
"types": "./dist/set/union.d.ts",
|
|
154
|
+
"import": "./dist/set/union.js",
|
|
155
|
+
"require": "./dist/set/union.cjs"
|
|
156
|
+
},
|
|
157
|
+
"./string/capitalize": {
|
|
158
|
+
"types": "./dist/string/capitalize.d.ts",
|
|
159
|
+
"import": "./dist/string/capitalize.js",
|
|
160
|
+
"require": "./dist/string/capitalize.cjs"
|
|
161
|
+
},
|
|
162
|
+
"./string/normalize": {
|
|
163
|
+
"types": "./dist/string/normalize.d.ts",
|
|
164
|
+
"import": "./dist/string/normalize.js",
|
|
165
|
+
"require": "./dist/string/normalize.cjs"
|
|
52
166
|
},
|
|
53
167
|
"./string/pluralize": {
|
|
54
168
|
"types": "./dist/string/pluralize/index.d.ts",
|
|
@@ -60,33 +174,35 @@
|
|
|
60
174
|
"import": "./dist/string/slugify/index.js",
|
|
61
175
|
"require": "./dist/string/slugify/index.cjs"
|
|
62
176
|
},
|
|
63
|
-
"./
|
|
64
|
-
"types": "./dist/
|
|
65
|
-
"import": "./dist/
|
|
66
|
-
"require": "./dist/
|
|
177
|
+
"./string/strip-html-tags": {
|
|
178
|
+
"types": "./dist/string/strip-html-tags.d.ts",
|
|
179
|
+
"import": "./dist/string/strip-html-tags.js",
|
|
180
|
+
"require": "./dist/string/strip-html-tags.cjs"
|
|
181
|
+
},
|
|
182
|
+
"./string/to-int": {
|
|
183
|
+
"types": "./dist/string/to-int.d.ts",
|
|
184
|
+
"import": "./dist/string/to-int.js",
|
|
185
|
+
"require": "./dist/string/to-int.cjs"
|
|
186
|
+
},
|
|
187
|
+
"./string/to-sentence-case": {
|
|
188
|
+
"types": "./dist/string/to-sentence-case.d.ts",
|
|
189
|
+
"import": "./dist/string/to-sentence-case.js",
|
|
190
|
+
"require": "./dist/string/to-sentence-case.cjs"
|
|
191
|
+
},
|
|
192
|
+
"./string/trim": {
|
|
193
|
+
"types": "./dist/string/trim.d.ts",
|
|
194
|
+
"import": "./dist/string/trim.js",
|
|
195
|
+
"require": "./dist/string/trim.cjs"
|
|
196
|
+
},
|
|
197
|
+
"./string/truncate": {
|
|
198
|
+
"types": "./dist/string/truncate.d.ts",
|
|
199
|
+
"import": "./dist/string/truncate.js",
|
|
200
|
+
"require": "./dist/string/truncate.cjs"
|
|
201
|
+
},
|
|
202
|
+
"./value/is-empty": {
|
|
203
|
+
"types": "./dist/value/is-empty.d.ts",
|
|
204
|
+
"import": "./dist/value/is-empty.js",
|
|
205
|
+
"require": "./dist/value/is-empty.cjs"
|
|
67
206
|
}
|
|
68
|
-
},
|
|
69
|
-
"packageManager": "yarn@4.15.0",
|
|
70
|
-
"scripts": {
|
|
71
|
-
"check": "tsc -b && eslint ./src",
|
|
72
|
-
"build": "tsc -b && vite build",
|
|
73
|
-
"lint": "eslint .",
|
|
74
|
-
"prepublish": "yarn build",
|
|
75
|
-
"publish": "yarn npm publish --access public --tolerate-republish"
|
|
76
|
-
},
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"@eslint/js": "^9.39.4",
|
|
79
|
-
"@types/node": "^24.12.3",
|
|
80
|
-
"baseline-browser-mapping": "^2.10.27",
|
|
81
|
-
"eslint": "^9.39.4",
|
|
82
|
-
"globals": "^17.6.0",
|
|
83
|
-
"tinyglobby": "^0.2.16",
|
|
84
|
-
"typescript": "~5.9.3",
|
|
85
|
-
"typescript-eslint": "^8.59.2",
|
|
86
|
-
"vite": "^7.3.3",
|
|
87
|
-
"vite-plugin-dts": "^4.5.4"
|
|
88
|
-
},
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"@sindresorhus/slugify": "^3.0.0"
|
|
91
207
|
}
|
|
92
208
|
}
|
package/dist/array/index.cjs
DELETED
package/dist/array/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './chunk';
|
package/dist/array/index.js
DELETED