complete-common 2.21.0 → 2.22.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/dist/index.cjs +6 -0
- package/dist/index.mjs +6 -1
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/functions/array.d.ts.map +1 -0
- package/dist/{functions → src/functions}/assert.d.cts +8 -0
- package/dist/{functions → src/functions}/assert.d.mts +8 -0
- package/dist/{functions → src/functions}/assert.d.ts +8 -0
- package/dist/src/functions/assert.d.ts.map +1 -0
- package/dist/src/functions/enums.d.ts.map +1 -0
- package/dist/src/functions/map.d.ts.map +1 -0
- package/dist/src/functions/math.d.ts.map +1 -0
- package/dist/src/functions/object.d.ts.map +1 -0
- package/dist/src/functions/random.d.ts.map +1 -0
- package/dist/src/functions/set.d.ts.map +1 -0
- package/dist/src/functions/sort.d.ts.map +1 -0
- package/dist/src/functions/string.d.ts.map +1 -0
- package/dist/src/functions/time.d.ts.map +1 -0
- package/dist/src/functions/tuple.d.ts.map +1 -0
- package/dist/src/functions/types.d.ts.map +1 -0
- package/dist/src/functions/utils.d.ts.map +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/interfaces/SemanticVersion.d.ts.map +1 -0
- package/dist/src/types/AddSubtract.d.ts.map +1 -0
- package/dist/src/types/CompositionTypeSatisfiesEnum.d.ts.map +1 -0
- package/dist/src/types/ERange.d.ts.map +1 -0
- package/dist/src/types/IRange.d.ts.map +1 -0
- package/dist/src/types/Immutable.d.ts.map +1 -0
- package/dist/src/types/NaturalNumbersLessThan.d.ts.map +1 -0
- package/dist/src/types/NaturalNumbersLessThanOrEqualTo.d.ts.map +1 -0
- package/dist/src/types/ObjectValues.d.ts.map +1 -0
- package/dist/src/types/ReadonlyMap.d.ts.map +1 -0
- package/dist/src/types/ReadonlyRecord.d.ts.map +1 -0
- package/dist/src/types/ReadonlySet.d.ts.map +1 -0
- package/dist/src/types/TranspiledEnum.d.ts.map +1 -0
- package/dist/src/types/Tuple.d.ts.map +1 -0
- package/dist/src/types/WidenLiteral.d.ts.map +1 -0
- package/dist/src/types/Writeable.d.ts.map +1 -0
- package/package.json +7 -8
- package/src/functions/assert.ts +25 -0
- package/src/functions/tuple.ts +1 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/functions/array.d.ts.map +0 -1
- package/dist/functions/assert.d.ts.map +0 -1
- package/dist/functions/enums.d.ts.map +0 -1
- package/dist/functions/map.d.ts.map +0 -1
- package/dist/functions/math.d.ts.map +0 -1
- package/dist/functions/object.d.ts.map +0 -1
- package/dist/functions/random.d.ts.map +0 -1
- package/dist/functions/set.d.ts.map +0 -1
- package/dist/functions/sort.d.ts.map +0 -1
- package/dist/functions/string.d.ts.map +0 -1
- package/dist/functions/string.test.d.cts +0 -2
- package/dist/functions/string.test.d.mts +0 -2
- package/dist/functions/string.test.d.ts +0 -2
- package/dist/functions/string.test.d.ts.map +0 -1
- package/dist/functions/time.d.ts.map +0 -1
- package/dist/functions/tuple.d.ts.map +0 -1
- package/dist/functions/types.d.ts.map +0 -1
- package/dist/functions/utils.d.ts.map +0 -1
- package/dist/functions/utils.test.d.cts +0 -2
- package/dist/functions/utils.test.d.mts +0 -2
- package/dist/functions/utils.test.d.ts +0 -2
- package/dist/functions/utils.test.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interfaces/SemanticVersion.d.ts.map +0 -1
- package/dist/types/AddSubtract.d.ts.map +0 -1
- package/dist/types/CompositionTypeSatisfiesEnum.d.ts.map +0 -1
- package/dist/types/ERange.d.ts.map +0 -1
- package/dist/types/IRange.d.ts.map +0 -1
- package/dist/types/Immutable.d.ts.map +0 -1
- package/dist/types/NaturalNumbersLessThan.d.ts.map +0 -1
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.ts.map +0 -1
- package/dist/types/ObjectValues.d.ts.map +0 -1
- package/dist/types/ReadonlyMap.d.ts.map +0 -1
- package/dist/types/ReadonlyRecord.d.ts.map +0 -1
- package/dist/types/ReadonlySet.d.ts.map +0 -1
- package/dist/types/TranspiledEnum.d.ts.map +0 -1
- package/dist/types/Tuple.d.ts.map +0 -1
- package/dist/types/WidenLiteral.d.ts.map +0 -1
- package/dist/types/Writeable.d.ts.map +0 -1
- package/src/functions/string.test.ts +0 -205
- package/src/functions/utils.test.ts +0 -904
- /package/dist/{constants.d.cts → src/constants.d.cts} +0 -0
- /package/dist/{constants.d.mts → src/constants.d.mts} +0 -0
- /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/{functions → src/functions}/array.d.cts +0 -0
- /package/dist/{functions → src/functions}/array.d.mts +0 -0
- /package/dist/{functions → src/functions}/array.d.ts +0 -0
- /package/dist/{functions → src/functions}/enums.d.cts +0 -0
- /package/dist/{functions → src/functions}/enums.d.mts +0 -0
- /package/dist/{functions → src/functions}/enums.d.ts +0 -0
- /package/dist/{functions → src/functions}/map.d.cts +0 -0
- /package/dist/{functions → src/functions}/map.d.mts +0 -0
- /package/dist/{functions → src/functions}/map.d.ts +0 -0
- /package/dist/{functions → src/functions}/math.d.cts +0 -0
- /package/dist/{functions → src/functions}/math.d.mts +0 -0
- /package/dist/{functions → src/functions}/math.d.ts +0 -0
- /package/dist/{functions → src/functions}/object.d.cts +0 -0
- /package/dist/{functions → src/functions}/object.d.mts +0 -0
- /package/dist/{functions → src/functions}/object.d.ts +0 -0
- /package/dist/{functions → src/functions}/random.d.cts +0 -0
- /package/dist/{functions → src/functions}/random.d.mts +0 -0
- /package/dist/{functions → src/functions}/random.d.ts +0 -0
- /package/dist/{functions → src/functions}/set.d.cts +0 -0
- /package/dist/{functions → src/functions}/set.d.mts +0 -0
- /package/dist/{functions → src/functions}/set.d.ts +0 -0
- /package/dist/{functions → src/functions}/sort.d.cts +0 -0
- /package/dist/{functions → src/functions}/sort.d.mts +0 -0
- /package/dist/{functions → src/functions}/sort.d.ts +0 -0
- /package/dist/{functions → src/functions}/string.d.cts +0 -0
- /package/dist/{functions → src/functions}/string.d.mts +0 -0
- /package/dist/{functions → src/functions}/string.d.ts +0 -0
- /package/dist/{functions → src/functions}/time.d.cts +0 -0
- /package/dist/{functions → src/functions}/time.d.mts +0 -0
- /package/dist/{functions → src/functions}/time.d.ts +0 -0
- /package/dist/{functions → src/functions}/tuple.d.cts +0 -0
- /package/dist/{functions → src/functions}/tuple.d.mts +0 -0
- /package/dist/{functions → src/functions}/tuple.d.ts +0 -0
- /package/dist/{functions → src/functions}/types.d.cts +0 -0
- /package/dist/{functions → src/functions}/types.d.mts +0 -0
- /package/dist/{functions → src/functions}/types.d.ts +0 -0
- /package/dist/{functions → src/functions}/utils.d.cts +0 -0
- /package/dist/{functions → src/functions}/utils.d.mts +0 -0
- /package/dist/{functions → src/functions}/utils.d.ts +0 -0
- /package/dist/{index.d.cts → src/index.d.cts} +0 -0
- /package/dist/{index.d.mts → src/index.d.mts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{interfaces → src/interfaces}/SemanticVersion.d.cts +0 -0
- /package/dist/{interfaces → src/interfaces}/SemanticVersion.d.mts +0 -0
- /package/dist/{interfaces → src/interfaces}/SemanticVersion.d.ts +0 -0
- /package/dist/{types → src/types}/AddSubtract.d.cts +0 -0
- /package/dist/{types → src/types}/AddSubtract.d.mts +0 -0
- /package/dist/{types → src/types}/AddSubtract.d.ts +0 -0
- /package/dist/{types → src/types}/CompositionTypeSatisfiesEnum.d.cts +0 -0
- /package/dist/{types → src/types}/CompositionTypeSatisfiesEnum.d.mts +0 -0
- /package/dist/{types → src/types}/CompositionTypeSatisfiesEnum.d.ts +0 -0
- /package/dist/{types → src/types}/ERange.d.cts +0 -0
- /package/dist/{types → src/types}/ERange.d.mts +0 -0
- /package/dist/{types → src/types}/ERange.d.ts +0 -0
- /package/dist/{types → src/types}/IRange.d.cts +0 -0
- /package/dist/{types → src/types}/IRange.d.mts +0 -0
- /package/dist/{types → src/types}/IRange.d.ts +0 -0
- /package/dist/{types → src/types}/Immutable.d.cts +0 -0
- /package/dist/{types → src/types}/Immutable.d.mts +0 -0
- /package/dist/{types → src/types}/Immutable.d.ts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThan.d.cts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThan.d.mts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThan.d.ts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThanOrEqualTo.d.cts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThanOrEqualTo.d.mts +0 -0
- /package/dist/{types → src/types}/NaturalNumbersLessThanOrEqualTo.d.ts +0 -0
- /package/dist/{types → src/types}/ObjectValues.d.cts +0 -0
- /package/dist/{types → src/types}/ObjectValues.d.mts +0 -0
- /package/dist/{types → src/types}/ObjectValues.d.ts +0 -0
- /package/dist/{types → src/types}/ReadonlyMap.d.cts +0 -0
- /package/dist/{types → src/types}/ReadonlyMap.d.mts +0 -0
- /package/dist/{types → src/types}/ReadonlyMap.d.ts +0 -0
- /package/dist/{types → src/types}/ReadonlyRecord.d.cts +0 -0
- /package/dist/{types → src/types}/ReadonlyRecord.d.mts +0 -0
- /package/dist/{types → src/types}/ReadonlyRecord.d.ts +0 -0
- /package/dist/{types → src/types}/ReadonlySet.d.cts +0 -0
- /package/dist/{types → src/types}/ReadonlySet.d.mts +0 -0
- /package/dist/{types → src/types}/ReadonlySet.d.ts +0 -0
- /package/dist/{types → src/types}/TranspiledEnum.d.cts +0 -0
- /package/dist/{types → src/types}/TranspiledEnum.d.mts +0 -0
- /package/dist/{types → src/types}/TranspiledEnum.d.ts +0 -0
- /package/dist/{types → src/types}/Tuple.d.cts +0 -0
- /package/dist/{types → src/types}/Tuple.d.mts +0 -0
- /package/dist/{types → src/types}/Tuple.d.ts +0 -0
- /package/dist/{types → src/types}/WidenLiteral.d.cts +0 -0
- /package/dist/{types → src/types}/WidenLiteral.d.mts +0 -0
- /package/dist/{types → src/types}/WidenLiteral.d.ts +0 -0
- /package/dist/{types → src/types}/Writeable.d.cts +0 -0
- /package/dist/{types → src/types}/Writeable.d.mts +0 -0
- /package/dist/{types → src/types}/Writeable.d.ts +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complete/require-ascii */
|
|
2
|
-
|
|
3
|
-
import { equal } from "node:assert";
|
|
4
|
-
import { describe, test } from "node:test";
|
|
5
|
-
import {
|
|
6
|
-
hasDiacritic,
|
|
7
|
-
hasEmoji,
|
|
8
|
-
isASCII,
|
|
9
|
-
isKebabCase,
|
|
10
|
-
titleCaseToKebabCase,
|
|
11
|
-
trimPrefix,
|
|
12
|
-
trimSuffix,
|
|
13
|
-
} from "./string.js";
|
|
14
|
-
|
|
15
|
-
describe("hasEmoji", () => {
|
|
16
|
-
test("should return true for string with normal emoji", () => {
|
|
17
|
-
equal(hasEmoji("Hello 😃 World"), true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("should return true for string with keycap emoji", () => {
|
|
21
|
-
equal(hasEmoji("This is a keycap emoji: #️⃣"), true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("should return false for string without emoji", () => {
|
|
25
|
-
equal(hasEmoji("Hello World"), false);
|
|
26
|
-
equal(
|
|
27
|
-
hasEmoji(`
|
|
28
|
-
# Some Markdown Title
|
|
29
|
-
|
|
30
|
-
This page is for people who like [cake](https://en.wikipedia.org/wiki/Cake).
|
|
31
|
-
|
|
32
|
-
- Run \`command cake\` to get cake.
|
|
33
|
-
- Run \`command pie\` to get pie.
|
|
34
|
-
`),
|
|
35
|
-
false,
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("should handle empty string", () => {
|
|
40
|
-
equal(hasEmoji(""), false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("should handle strings with only emoji", () => {
|
|
44
|
-
equal(hasEmoji("😊"), true);
|
|
45
|
-
equal(hasEmoji("🚀"), true);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe("hasDiacritic", () => {
|
|
50
|
-
test("should return true for diacritic character", () => {
|
|
51
|
-
equal(hasDiacritic("á"), true);
|
|
52
|
-
equal(hasDiacritic("è"), true);
|
|
53
|
-
equal(hasDiacritic("ô"), true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("should return false for non-diacritic character", () => {
|
|
57
|
-
equal(hasDiacritic("A"), false);
|
|
58
|
-
equal(hasDiacritic("1"), false);
|
|
59
|
-
equal(hasDiacritic("!"), false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("should handle empty string", () => {
|
|
63
|
-
equal(hasDiacritic(""), false);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe("isASCII", () => {
|
|
68
|
-
test("should return true for ASCII strings", () => {
|
|
69
|
-
equal(isASCII("Hello World"), true);
|
|
70
|
-
equal(isASCII("1234567890"), true);
|
|
71
|
-
equal(isASCII("!@#$%^&*()_+"), true);
|
|
72
|
-
equal(isASCII(" \n\t\r"), true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("should return false for non-ASCII strings", () => {
|
|
76
|
-
equal(isASCII("Hello World 😃"), false);
|
|
77
|
-
equal(isASCII("á"), false);
|
|
78
|
-
equal(isASCII("è"), false);
|
|
79
|
-
equal(isASCII("ô"), false);
|
|
80
|
-
equal(isASCII("😊"), false);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("should handle empty string", () => {
|
|
84
|
-
equal(isASCII(""), true);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("isKebabCase", () => {
|
|
89
|
-
test("should return true for valid kebab-case strings", () => {
|
|
90
|
-
equal(isKebabCase("hello-world"), true);
|
|
91
|
-
equal(isKebabCase("lowercase"), true);
|
|
92
|
-
equal(isKebabCase("item-123-abc"), true);
|
|
93
|
-
equal(isKebabCase("section-1a"), true);
|
|
94
|
-
equal(isKebabCase("segment-1-2-3"), true);
|
|
95
|
-
equal(isKebabCase("1-2-3"), true);
|
|
96
|
-
equal(isKebabCase("12345"), true);
|
|
97
|
-
equal(isKebabCase("fix-k8s"), true);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("should return false for strings with uppercase letters", () => {
|
|
101
|
-
equal(isKebabCase("HelloWorld"), false);
|
|
102
|
-
equal(isKebabCase("helloWorld"), false);
|
|
103
|
-
equal(isKebabCase("Hello-World"), false);
|
|
104
|
-
equal(isKebabCase("kebab-Case"), false);
|
|
105
|
-
equal(isKebabCase("HELLO-WORLD"), false);
|
|
106
|
-
equal(isKebabCase("UPPERCASE"), false);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("should return false for strings with spaces", () => {
|
|
110
|
-
equal(isKebabCase("hello world"), false);
|
|
111
|
-
equal(isKebabCase(" hello-world"), false);
|
|
112
|
-
equal(isKebabCase("hello-world "), false);
|
|
113
|
-
equal(isKebabCase("hello - world"), false);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("should return false for strings with underscores", () => {
|
|
117
|
-
equal(isKebabCase("hello_world"), false);
|
|
118
|
-
equal(isKebabCase("snake_case_example"), false);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test("should return false for strings with consecutive hyphens", () => {
|
|
122
|
-
equal(isKebabCase("hello--world"), false);
|
|
123
|
-
equal(isKebabCase("a--b--c"), false);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("should return false for strings starting or ending with a hyphen", () => {
|
|
127
|
-
equal(isKebabCase("-hello-world"), false);
|
|
128
|
-
equal(isKebabCase("hello-world-"), false);
|
|
129
|
-
equal(isKebabCase("-start"), false);
|
|
130
|
-
equal(isKebabCase("end-"), false);
|
|
131
|
-
equal(isKebabCase("-"), false);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test("should return false for strings with special characters other than hyphens", () => {
|
|
135
|
-
equal(isKebabCase("hello-world!"), false);
|
|
136
|
-
equal(isKebabCase("test@example"), false);
|
|
137
|
-
equal(isKebabCase("kebab$case"), false);
|
|
138
|
-
equal(isKebabCase("has-#-symbol"), false);
|
|
139
|
-
equal(isKebabCase("dot.case"), false);
|
|
140
|
-
equal(isKebabCase("slash/case"), false);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("should return false for mixed separators", () => {
|
|
144
|
-
equal(isKebabCase("hello_world-foo"), false);
|
|
145
|
-
equal(isKebabCase("hello-world_bar"), false);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test("should return false for an empty string", () => {
|
|
149
|
-
equal(isKebabCase(""), false);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe("titleCaseToKebabCase", () => {
|
|
154
|
-
test("should convert a single TitleCase word to lowercase", () => {
|
|
155
|
-
equal(titleCaseToKebabCase("Foo"), "foo");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("should convert two TitleCase words to kebab-case", () => {
|
|
159
|
-
equal(titleCaseToKebabCase("FooBar"), "foo-bar");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test("should convert multiple TitleCase words to kebab-case", () => {
|
|
163
|
-
equal(titleCaseToKebabCase("FooBarBaz"), "foo-bar-baz");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("should handle an empty string", () => {
|
|
167
|
-
equal(titleCaseToKebabCase(""), "");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("should handle a string that is already lowercase", () => {
|
|
171
|
-
equal(titleCaseToKebabCase("foo"), "foo");
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test("should handle a string with digits", () => {
|
|
175
|
-
equal(titleCaseToKebabCase("Foo2Bar"), "foo2-bar");
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
test("should handle spaces", () => {
|
|
179
|
-
equal(titleCaseToKebabCase("Foo Bar"), "foo-bar");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test("should handle multiple spaces", () => {
|
|
183
|
-
equal(titleCaseToKebabCase("Foo Bar"), "foo-bar");
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe("trimPrefix", () => {
|
|
188
|
-
test(() => {
|
|
189
|
-
equal(trimPrefix("foo", ""), "foo");
|
|
190
|
-
equal(trimPrefix("foo", "f"), "oo");
|
|
191
|
-
equal(trimPrefix("foo", "fo"), "o");
|
|
192
|
-
equal(trimPrefix("foo", "foo"), "");
|
|
193
|
-
equal(trimPrefix("foo", "foo1"), "foo");
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe("trimSuffix", () => {
|
|
198
|
-
test(() => {
|
|
199
|
-
equal(trimSuffix("foo", ""), "foo");
|
|
200
|
-
equal(trimSuffix("foo", "o"), "fo");
|
|
201
|
-
equal(trimSuffix("foo", "oo"), "f");
|
|
202
|
-
equal(trimSuffix("foo", "foo"), "");
|
|
203
|
-
equal(trimSuffix("foo", "1foo"), "foo");
|
|
204
|
-
});
|
|
205
|
-
});
|