@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
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Rule } from "../types";
|
|
2
|
-
|
|
3
|
-
export const SINGULARIZATION_RULES: Rule[] = [
|
|
4
|
-
[/s$/i, ""],
|
|
5
|
-
[/(ss)$/i, "$1"],
|
|
6
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|\W|^)li)ves$/i, "$1fe"],
|
|
7
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
8
|
-
[/ies$/i, "y"],
|
|
9
|
-
[/(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$/i, "$1ie"],
|
|
10
|
-
[
|
|
11
|
-
/\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$/i,
|
|
12
|
-
"$1ie",
|
|
13
|
-
],
|
|
14
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
15
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
16
|
-
[/(seraph|cherub)im$/i, "$1"],
|
|
17
|
-
[
|
|
18
|
-
/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
|
|
19
|
-
"$1",
|
|
20
|
-
],
|
|
21
|
-
[
|
|
22
|
-
/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
|
|
23
|
-
"$1sis",
|
|
24
|
-
],
|
|
25
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
26
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
|
27
|
-
[
|
|
28
|
-
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
29
|
-
"$1us",
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
33
|
-
"$1um",
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
37
|
-
"$1on",
|
|
38
|
-
],
|
|
39
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
40
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
41
|
-
[/(matr|append)ices$/i, "$1ix"],
|
|
42
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
43
|
-
[/(child)ren$/i, "$1"],
|
|
44
|
-
[/(eau)x?$/i, "$1"],
|
|
45
|
-
[/men$/i, "man"],
|
|
46
|
-
];
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { RuleKey } from '../types';
|
|
2
|
-
|
|
3
|
-
export const UNCOUNTABLE_WORDS: RuleKey[] = [
|
|
4
|
-
// Singular words with no plurals.
|
|
5
|
-
'adulthood',
|
|
6
|
-
'advice',
|
|
7
|
-
'agenda',
|
|
8
|
-
'aid',
|
|
9
|
-
'aircraft',
|
|
10
|
-
'alcohol',
|
|
11
|
-
'ammo',
|
|
12
|
-
'analytics',
|
|
13
|
-
'anime',
|
|
14
|
-
'athletics',
|
|
15
|
-
'audio',
|
|
16
|
-
'bison',
|
|
17
|
-
'blood',
|
|
18
|
-
'bream',
|
|
19
|
-
'buffalo',
|
|
20
|
-
'butter',
|
|
21
|
-
'carp',
|
|
22
|
-
'cash',
|
|
23
|
-
'chassis',
|
|
24
|
-
'chess',
|
|
25
|
-
'clothing',
|
|
26
|
-
'cod',
|
|
27
|
-
'commerce',
|
|
28
|
-
'cooperation',
|
|
29
|
-
'corps',
|
|
30
|
-
'debris',
|
|
31
|
-
'diabetes',
|
|
32
|
-
'digestion',
|
|
33
|
-
'elk',
|
|
34
|
-
'energy',
|
|
35
|
-
'equipment',
|
|
36
|
-
'excretion',
|
|
37
|
-
'expertise',
|
|
38
|
-
'firmware',
|
|
39
|
-
'flounder',
|
|
40
|
-
'fun',
|
|
41
|
-
'gallows',
|
|
42
|
-
'garbage',
|
|
43
|
-
'graffiti',
|
|
44
|
-
'hardware',
|
|
45
|
-
'headquarters',
|
|
46
|
-
'health',
|
|
47
|
-
'herpes',
|
|
48
|
-
'highjinks',
|
|
49
|
-
'homework',
|
|
50
|
-
'housework',
|
|
51
|
-
'information',
|
|
52
|
-
'jeans',
|
|
53
|
-
'justice',
|
|
54
|
-
'kudos',
|
|
55
|
-
'labour',
|
|
56
|
-
'literature',
|
|
57
|
-
'machinery',
|
|
58
|
-
'mackerel',
|
|
59
|
-
'mail',
|
|
60
|
-
'media',
|
|
61
|
-
'mews',
|
|
62
|
-
'moose',
|
|
63
|
-
'music',
|
|
64
|
-
'mud',
|
|
65
|
-
'manga',
|
|
66
|
-
'news',
|
|
67
|
-
'only',
|
|
68
|
-
'personnel',
|
|
69
|
-
'pike',
|
|
70
|
-
'plankton',
|
|
71
|
-
'pliers',
|
|
72
|
-
'police',
|
|
73
|
-
'pollution',
|
|
74
|
-
'premises',
|
|
75
|
-
'rain',
|
|
76
|
-
'research',
|
|
77
|
-
'rice',
|
|
78
|
-
'salmon',
|
|
79
|
-
'scissors',
|
|
80
|
-
'series',
|
|
81
|
-
'sewage',
|
|
82
|
-
'shambles',
|
|
83
|
-
'shrimp',
|
|
84
|
-
'software',
|
|
85
|
-
'staff',
|
|
86
|
-
'swine',
|
|
87
|
-
'tennis',
|
|
88
|
-
'traffic',
|
|
89
|
-
'transportation',
|
|
90
|
-
'trout',
|
|
91
|
-
'tuna',
|
|
92
|
-
'wealth',
|
|
93
|
-
'welfare',
|
|
94
|
-
'whiting',
|
|
95
|
-
'wildebeest',
|
|
96
|
-
'wildlife',
|
|
97
|
-
'you',
|
|
98
|
-
/pok[eé]mon$/i,
|
|
99
|
-
// Regexes.
|
|
100
|
-
/[^aeiou]ese$/i, // "chinese", "japanese"
|
|
101
|
-
/deer$/i, // "deer", "reindeer"
|
|
102
|
-
/fish$/i, // "fish", "blowfish", "angelfish"
|
|
103
|
-
/measles$/i,
|
|
104
|
-
/o[iu]s$/i, // "carnivorous"
|
|
105
|
-
/pox$/i, // "chickpox", "smallpox"
|
|
106
|
-
/sheep$/i,
|
|
107
|
-
];
|
package/src/string/to-int.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string (or a number) into a number.
|
|
3
|
-
* If the input can not be successfully converted, it will return the fallback.
|
|
4
|
-
* It will not return NaN.
|
|
5
|
-
* @param value - The value to convert
|
|
6
|
-
* @param fallback - The value to fallback to. Defaults to 0
|
|
7
|
-
* @returns number
|
|
8
|
-
*/
|
|
9
|
-
export function stringToInt(
|
|
10
|
-
value: string | number,
|
|
11
|
-
fallback: number = 0,
|
|
12
|
-
): number {
|
|
13
|
-
let returnValue = value;
|
|
14
|
-
if (typeof returnValue === "string")
|
|
15
|
-
returnValue = Number.parseInt(returnValue);
|
|
16
|
-
|
|
17
|
-
if (Number.isNaN(returnValue)) returnValue = fallback;
|
|
18
|
-
|
|
19
|
-
return returnValue;
|
|
20
|
-
}
|
package/src/string/trim.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function trim(text: string, chars: string | string[] = " ") {
|
|
2
|
-
let start = 0;
|
|
3
|
-
let end = text.length;
|
|
4
|
-
|
|
5
|
-
if (!Array.isArray(chars)) chars = [chars];
|
|
6
|
-
|
|
7
|
-
while (start < end && chars.includes(text[start])) start += 1;
|
|
8
|
-
while (end > start && chars.includes(text[end - 1])) end -= 1;
|
|
9
|
-
|
|
10
|
-
return start > 0 || end < text.length ? text.substring(start, end) : text;
|
|
11
|
-
}
|
package/src/string/truncate.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface TruncateOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The maximum number of character allowed in the text before truncating it
|
|
4
|
-
*
|
|
5
|
-
* @default 100
|
|
6
|
-
*/
|
|
7
|
-
maxlength?: number;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The string to use at the end of the truncated text
|
|
11
|
-
*
|
|
12
|
-
* @default "..."
|
|
13
|
-
*/
|
|
14
|
-
ending?: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* If true, truncates the text at the next space char,
|
|
18
|
-
* so the returned string can exceed the specified `maxLength`
|
|
19
|
-
*
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
noWordBreak?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const defaultOptions: Required<TruncateOptions> = {
|
|
26
|
-
ending: "...",
|
|
27
|
-
maxlength: 100,
|
|
28
|
-
noWordBreak: false,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export function truncate(text: string, options?: TruncateOptions) {
|
|
32
|
-
const conf = { ...defaultOptions, ...options };
|
|
33
|
-
text = text.trim();
|
|
34
|
-
if (conf.noWordBreak) {
|
|
35
|
-
const lastSpaceIndex = text.indexOf(" ", conf.maxlength);
|
|
36
|
-
|
|
37
|
-
if (lastSpaceIndex >= conf.maxlength)
|
|
38
|
-
return text.substring(0, lastSpaceIndex) + conf.ending;
|
|
39
|
-
} else if (text.length > conf.maxlength + conf.ending.length) {
|
|
40
|
-
return text.substring(0, conf.maxlength) + conf.ending;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return text;
|
|
44
|
-
}
|
package/src/value/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./is-empty";
|
package/src/value/is-empty.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the value is `empty`
|
|
3
|
-
*
|
|
4
|
-
* returns `true`, if the value
|
|
5
|
-
*
|
|
6
|
-
* - `undefined`
|
|
7
|
-
* - `null`
|
|
8
|
-
* - `string` and there is no character in the string or all white space
|
|
9
|
-
* - `array` and there is no item in the array
|
|
10
|
-
* - `map` and there is no item in the map
|
|
11
|
-
* - `set` and there is no item in the set
|
|
12
|
-
* - `object` and there is no property in the object
|
|
13
|
-
*
|
|
14
|
-
* otherwise, false
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export const isEmpty = (value: unknown) => {
|
|
18
|
-
if (value === undefined) return true;
|
|
19
|
-
if (value === null) return true;
|
|
20
|
-
|
|
21
|
-
if (typeof value === "string") return value.trim() === "";
|
|
22
|
-
if (typeof value === "object") {
|
|
23
|
-
if (Array.isArray(value) && value.length === 0) return true;
|
|
24
|
-
|
|
25
|
-
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
|
26
|
-
|
|
27
|
-
return Object.keys(value).length === 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return false;
|
|
31
|
-
};
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "./dist",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"lib": [
|
|
7
|
-
"DOM",
|
|
8
|
-
"ESNext"
|
|
9
|
-
],
|
|
10
|
-
"strict": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"jsx": "preserve",
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"moduleResolution": "bundler",
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"noUnusedLocals": true,
|
|
17
|
-
"strictNullChecks": true,
|
|
18
|
-
"allowJs": true,
|
|
19
|
-
"forceConsistentCasingInFileNames": true,
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"types": [
|
|
22
|
-
"node",
|
|
23
|
-
],
|
|
24
|
-
"paths": {
|
|
25
|
-
"@/*": [
|
|
26
|
-
"./src/*"
|
|
27
|
-
],
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"include": [
|
|
31
|
-
"src/**/*",
|
|
32
|
-
],
|
|
33
|
-
"exclude": [
|
|
34
|
-
"dist",
|
|
35
|
-
"node_modules"
|
|
36
|
-
]
|
|
37
|
-
}
|
package/tsconfig.node.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "ES2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"verbatimModuleSyntax": true,
|
|
13
|
-
"moduleDetection": "force",
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
|
|
16
|
-
/* Linting */
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"erasableSyntaxOnly": true,
|
|
21
|
-
"noFallthroughCasesInSwitch": true,
|
|
22
|
-
"noUncheckedSideEffectImports": true
|
|
23
|
-
},
|
|
24
|
-
"include": ["vite.config.ts"]
|
|
25
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { globSync } from "tinyglobby";
|
|
4
|
-
import { defineConfig } from "vite";
|
|
5
|
-
import dts from "vite-plugin-dts";
|
|
6
|
-
import packageConfig from "./package.json";
|
|
7
|
-
import { writeFileSync } from "node:fs";
|
|
8
|
-
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const outDir = "./dist";
|
|
11
|
-
|
|
12
|
-
const createEntries = () => {
|
|
13
|
-
const entries = new Map<string, string>();
|
|
14
|
-
const exports = new Map<
|
|
15
|
-
string,
|
|
16
|
-
{
|
|
17
|
-
types: string;
|
|
18
|
-
import: string;
|
|
19
|
-
require: string;
|
|
20
|
-
}
|
|
21
|
-
>();
|
|
22
|
-
|
|
23
|
-
const files = globSync("src/**/*.ts", {
|
|
24
|
-
cwd: __dirname,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
for (const file of files) {
|
|
28
|
-
const filePath = file.split(".")[0].replace(/^src[/\\]/, "");
|
|
29
|
-
|
|
30
|
-
if (!filePath) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const filePathParts = filePath.split("/");
|
|
35
|
-
if (filePathParts.at(-1) === "index" && filePathParts.length <= 3) {
|
|
36
|
-
const exportPath = filePathParts.length === 1 ? "." : `./${filePathParts.slice(0, -1).join("/")}`;
|
|
37
|
-
|
|
38
|
-
exports.set(exportPath, {
|
|
39
|
-
types: `${outDir}/${filePath}.d.ts`,
|
|
40
|
-
import: `${outDir}/${filePath}.js`,
|
|
41
|
-
require: `${outDir}/${filePath}.cjs`,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
entries.set(filePath, fileURLToPath(new URL(file, import.meta.url)));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const _packageConfig = {
|
|
49
|
-
...packageConfig,
|
|
50
|
-
exports: Object.fromEntries([...exports].sort((a, b) => a[0].localeCompare(b[0]))),
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
writeFileSync("./package.json", JSON.stringify(_packageConfig, null, 2), {
|
|
54
|
-
encoding: "utf-8",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return Object.fromEntries(entries);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default defineConfig({
|
|
61
|
-
plugins: [dts({ tsconfigPath: "./tsconfig.lib.json" })],
|
|
62
|
-
resolve: {
|
|
63
|
-
alias: {
|
|
64
|
-
"@": path.resolve(__dirname, "./src"),
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
build: {
|
|
68
|
-
minify: false,
|
|
69
|
-
copyPublicDir: false,
|
|
70
|
-
lib: {
|
|
71
|
-
entry: createEntries(),
|
|
72
|
-
name: "utils",
|
|
73
|
-
formats: ["es", "cjs"],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
});
|