jj 2.3.0 → 2.5.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 +18 -57
- package/lib/JJD.d.ts +36 -25
- package/lib/JJD.js +56 -28
- package/lib/JJD.js.map +1 -1
- package/lib/JJDF.d.ts +19 -5
- package/lib/JJDF.js +32 -2
- package/lib/JJDF.js.map +1 -1
- package/lib/JJE.d.ts +96 -110
- package/lib/JJE.js +143 -154
- package/lib/JJE.js.map +1 -1
- package/lib/JJET.d.ts +79 -0
- package/lib/JJET.js +114 -0
- package/lib/JJET.js.map +1 -0
- package/lib/JJEx.d.ts +63 -0
- package/lib/JJEx.js +83 -0
- package/lib/JJEx.js.map +1 -0
- package/lib/JJHE.d.ts +26 -37
- package/lib/JJHE.js +34 -62
- package/lib/JJHE.js.map +1 -1
- package/lib/JJN-wrap.js +46 -0
- package/lib/JJN-wrap.js.map +1 -0
- package/lib/JJN.d.ts +21 -106
- package/lib/JJN.js +44 -164
- package/lib/JJN.js.map +1 -1
- package/lib/JJNx.d.ts +126 -0
- package/lib/JJNx.js +157 -0
- package/lib/JJNx.js.map +1 -0
- package/lib/JJSE.d.ts +32 -10
- package/lib/JJSE.js +36 -9
- package/lib/JJSE.js.map +1 -1
- package/lib/JJSR.d.ts +8 -4
- package/lib/JJSR.js +10 -5
- package/lib/JJSR.js.map +1 -1
- package/lib/JJT.d.ts +26 -13
- package/lib/JJT.js +38 -30
- package/lib/JJT.js.map +1 -1
- package/lib/bundle.js +779 -734
- package/lib/bundle.js.map +3 -3
- package/lib/bundle.min.js +1 -2
- package/lib/components.js +5 -4
- package/lib/components.js.map +1 -1
- package/lib/helpers.d.ts +3 -2
- package/lib/helpers.js +11 -9
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +20 -2
- package/lib/index.js +21 -2
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +30 -0
- package/lib/internal.js +35 -0
- package/lib/internal.js.map +1 -0
- package/lib/types.d.ts +18 -30
- package/lib/util.d.ts +0 -28
- package/lib/util.js +0 -32
- package/lib/util.js.map +1 -1
- package/llms.txt +214 -0
- package/package.json +11 -3
- package/lib/case.test.js +0 -79
- package/lib/case.test.js.map +0 -1
- package/lib/mixin-types.d.ts +0 -143
- package/lib/mixin-types.js +0 -2
- package/lib/mixin-types.js.map +0 -1
- package/lib/mixins.d.ts +0 -94
- package/lib/mixins.js +0 -359
- package/lib/mixins.js.map +0 -1
- package/lib/util.test.d.ts +0 -1
- package/lib/util.test.js +0 -46
- package/lib/util.test.js.map +0 -1
- /package/lib/{case.test.d.ts → JJN-wrap.d.ts} +0 -0
package/lib/mixins.js
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import { hasProp, isA, isObj, isStr } from 'jty';
|
|
2
|
-
import { JJHE } from './JJHE.js';
|
|
3
|
-
import { JJE } from './JJE.js';
|
|
4
|
-
import { JJDF } from './JJDF.js';
|
|
5
|
-
import { JJSR } from './JJSR.js';
|
|
6
|
-
import { JJT } from './JJT.js';
|
|
7
|
-
import { JJN } from './JJN.js';
|
|
8
|
-
import { JJD } from './JJD.js';
|
|
9
|
-
import { JJSE } from './JJSE.js';
|
|
10
|
-
export const { wrapAll, unwrapAll } = JJN;
|
|
11
|
-
/**
|
|
12
|
-
* Wraps a native DOM node or string into the most specific JJ wrapper available.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
16
|
-
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const bodyWrapper = JJN.wrap(document.body) // Returns JJHE
|
|
21
|
-
* const textWrapper = JJN.wrap('Hello') // Returns JJT wrapping a new Text node
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param raw - The object to wrap. If it's already Wrapped, it'll be returned without any change. We don't double-wrap or clone it.
|
|
25
|
-
* @returns The most granular Wrapped subclass instance. If the input is already wrapped, it'll be returned as is without cloning.
|
|
26
|
-
* @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
|
|
27
|
-
*/
|
|
28
|
-
export function wrap(raw) {
|
|
29
|
-
if (isStr(raw)) {
|
|
30
|
-
return JJT.from(document.createTextNode(raw));
|
|
31
|
-
}
|
|
32
|
-
if (!isObj(raw)) {
|
|
33
|
-
throw new TypeError(`Expected an object to wrap. Got ${raw} (${typeof raw})`);
|
|
34
|
-
}
|
|
35
|
-
if (isA(raw, JJN)) {
|
|
36
|
-
return raw;
|
|
37
|
-
}
|
|
38
|
-
if (isA(raw, HTMLElement)) {
|
|
39
|
-
return JJHE.from(raw);
|
|
40
|
-
}
|
|
41
|
-
if (isA(raw, SVGElement)) {
|
|
42
|
-
return JJSE.from(raw);
|
|
43
|
-
}
|
|
44
|
-
if (isA(raw, Element)) {
|
|
45
|
-
return JJE.from(raw);
|
|
46
|
-
}
|
|
47
|
-
if (isA(raw, ShadowRoot)) {
|
|
48
|
-
return JJSR.from(raw);
|
|
49
|
-
}
|
|
50
|
-
if (isA(raw, DocumentFragment)) {
|
|
51
|
-
return JJDF.from(raw);
|
|
52
|
-
}
|
|
53
|
-
if (isA(raw, Document)) {
|
|
54
|
-
return JJD.from(raw);
|
|
55
|
-
}
|
|
56
|
-
if (isA(raw, Text)) {
|
|
57
|
-
return JJT.from(raw);
|
|
58
|
-
}
|
|
59
|
-
if (isA(raw, Node)) {
|
|
60
|
-
return JJN.from(raw);
|
|
61
|
-
}
|
|
62
|
-
throw new TypeError(`Expected a Node to wrap. Got ${raw} (${typeof raw})`);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Extracts the underlying native DOM node from a wrapper.
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
* If the input is already a native Node, it is returned as is.
|
|
69
|
-
* If the input is a string, a new Text node is created and returned.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* const rawElement = JJN.unwrap(myJJHE) // Returns HTMLElement
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @param obj - The object to unwrap.
|
|
77
|
-
* @returns The underlying DOM node.
|
|
78
|
-
* @throws {TypeError} If the input cannot be unwrapped.
|
|
79
|
-
*/
|
|
80
|
-
export function unwrap(obj) {
|
|
81
|
-
if (isStr(obj)) {
|
|
82
|
-
return document.createTextNode(obj);
|
|
83
|
-
}
|
|
84
|
-
if (!isObj(obj)) {
|
|
85
|
-
throw new TypeError(`Expected an object. Got ${obj} (${typeof obj})`);
|
|
86
|
-
}
|
|
87
|
-
if (isA(obj, Node)) {
|
|
88
|
-
return obj;
|
|
89
|
-
}
|
|
90
|
-
if (isA(obj, JJN)) {
|
|
91
|
-
return obj.ref;
|
|
92
|
-
}
|
|
93
|
-
throw new TypeError(`Could not unwrap ${obj} (${typeof obj})`);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Finds an element by ID in the document.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const el = byId('my-id')
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* @param id - The ID to search for.
|
|
104
|
-
* @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
|
|
105
|
-
* @returns The wrapped element, or null if not found and throwIfNotFound is false.
|
|
106
|
-
* @throws {TypeError} If the element is not found and throwIfNotFound is true.
|
|
107
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById | Document.getElementById}
|
|
108
|
-
*/
|
|
109
|
-
export function byId(id, throwIfNotFound = true) {
|
|
110
|
-
const el = document.getElementById(id);
|
|
111
|
-
if (el) {
|
|
112
|
-
return wrap(el);
|
|
113
|
-
}
|
|
114
|
-
if (throwIfNotFound) {
|
|
115
|
-
throw new TypeError(`Found no element with id ${id} in the document.`);
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Finds elements by class name in the document.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* const items = byClass('list-item')
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* @param className - The class name to search for.
|
|
128
|
-
* @returns An array of wrapped elements.
|
|
129
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName | Document.getElementsByClassName}
|
|
130
|
-
*/
|
|
131
|
-
export function byClass(className) {
|
|
132
|
-
return wrapAll(document.getElementsByClassName(className));
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Finds the first element matching a selector in the document.
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* const btn = query('.submit-btn')
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* @param selector - The CSS selector.
|
|
143
|
-
* @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
|
|
144
|
-
* @returns The wrapped element, or null.
|
|
145
|
-
* @throws {TypeError} If not found and throwIfNotFound is true.
|
|
146
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector | Document.querySelector}
|
|
147
|
-
*/
|
|
148
|
-
export function query(selector, throwIfNotFound = true) {
|
|
149
|
-
const queryResult = document.querySelector(selector);
|
|
150
|
-
if (queryResult) {
|
|
151
|
-
return wrap(queryResult);
|
|
152
|
-
}
|
|
153
|
-
if (throwIfNotFound) {
|
|
154
|
-
throw new TypeError(`Element with selector ${selector} not found`);
|
|
155
|
-
}
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Finds all elements matching a selector in the document.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* const inputs = queryAll('input[type="text"]')
|
|
164
|
-
* ```
|
|
165
|
-
*
|
|
166
|
-
* @param selector - The CSS selector.
|
|
167
|
-
* @returns An array of wrapped elements.
|
|
168
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll | Document.querySelectorAll}
|
|
169
|
-
*/
|
|
170
|
-
export function queryAll(selector) {
|
|
171
|
-
return wrapAll(document.querySelectorAll(selector));
|
|
172
|
-
}
|
|
173
|
-
const DDF = {
|
|
174
|
-
/**
|
|
175
|
-
* Finds an element by ID within this Document or DocumentFragment.
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```ts
|
|
179
|
-
* const el = doc.byId('header')
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @param this - The JJD or JJDF instance.
|
|
183
|
-
* @param id - The ID to search for.
|
|
184
|
-
* @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
|
|
185
|
-
* @returns The wrapped element, or null if not found and throwIfNotFound is false.
|
|
186
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById | Document.getElementById}
|
|
187
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/getElementById | DocumentFragment.getElementById}
|
|
188
|
-
*/
|
|
189
|
-
byId(id, throwIfNotFound = true) {
|
|
190
|
-
const el = this.ref.getElementById(id);
|
|
191
|
-
if (el) {
|
|
192
|
-
return wrap(el);
|
|
193
|
-
}
|
|
194
|
-
if (throwIfNotFound) {
|
|
195
|
-
throw new TypeError(`Element with id ${id} not found`);
|
|
196
|
-
}
|
|
197
|
-
return null;
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
const EDDF = {
|
|
201
|
-
/**
|
|
202
|
-
* Finds the first element matching a selector within this element's context.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```ts
|
|
206
|
-
* const span = div.query('span')
|
|
207
|
-
* ```
|
|
208
|
-
*
|
|
209
|
-
* @param this - The JJE, JJD or JJDF instance.
|
|
210
|
-
* @param selector - The CSS selector.
|
|
211
|
-
* @param throwIfNotFound - Whether to throw an error if not found. Defaults to true.
|
|
212
|
-
* @returns The wrapped element, or null.
|
|
213
|
-
* @throws {TypeError} If context is invalid or element not found (when requested).
|
|
214
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
|
|
215
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector | Document.querySelector}
|
|
216
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/querySelector | DocumentFragment.querySelector}
|
|
217
|
-
*/
|
|
218
|
-
query(selector, throwIfNotFound = true) {
|
|
219
|
-
const queryResult = this.ref.querySelector(selector);
|
|
220
|
-
if (queryResult) {
|
|
221
|
-
return wrap(queryResult);
|
|
222
|
-
}
|
|
223
|
-
if (throwIfNotFound) {
|
|
224
|
-
throw new TypeError(`Element with selector ${selector} not found`);
|
|
225
|
-
}
|
|
226
|
-
return null;
|
|
227
|
-
},
|
|
228
|
-
/**
|
|
229
|
-
* Finds all elements matching a selector within this element's context.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* const items = list.queryAll('li')
|
|
234
|
-
* ```
|
|
235
|
-
*
|
|
236
|
-
* @param this - The JJE, JJD or JJDF instance.
|
|
237
|
-
* @param selector - The CSS selector.
|
|
238
|
-
* @returns An array of wrapped elements.
|
|
239
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll | Element.querySelectorAll}
|
|
240
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll | Document.querySelectorAll}
|
|
241
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/querySelectorAll | DocumentFragment.querySelectorAll}
|
|
242
|
-
*/
|
|
243
|
-
queryAll(selector) {
|
|
244
|
-
return wrapAll(this.ref.querySelectorAll(selector));
|
|
245
|
-
},
|
|
246
|
-
/**
|
|
247
|
-
* Appends children to this node using native append.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* myDiv.append(h('span', null, 'hello'))
|
|
252
|
-
* ```
|
|
253
|
-
*
|
|
254
|
-
* @param this - The JJE, JJD or JJDF instance.
|
|
255
|
-
* @param children - The children to append.
|
|
256
|
-
* @returns This instance for chaining.
|
|
257
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
|
|
258
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/append | Document.append}
|
|
259
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/append | DocumentFragment.append}
|
|
260
|
-
*/
|
|
261
|
-
append(...children) {
|
|
262
|
-
const nodes = unwrapAll(children);
|
|
263
|
-
this.ref.append(...nodes);
|
|
264
|
-
return this;
|
|
265
|
-
},
|
|
266
|
-
/**
|
|
267
|
-
* Prepends children to this node using native prepend.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```ts
|
|
271
|
-
* div.prepend(h('span', null, 'first'))
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* @param this - The JJE, JJD or JJDF instance.
|
|
275
|
-
* @param children - The children to prepend.
|
|
276
|
-
* @returns This instance for chaining.
|
|
277
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
|
|
278
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/prepend | Document.prepend}
|
|
279
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/prepend | DocumentFragment.prepend}
|
|
280
|
-
*/
|
|
281
|
-
prepend(...children) {
|
|
282
|
-
const nodes = unwrapAll(children);
|
|
283
|
-
this.ref.prepend(...nodes);
|
|
284
|
-
return this;
|
|
285
|
-
},
|
|
286
|
-
/**
|
|
287
|
-
* Replaces the existing children of a node with a specified new set of children.
|
|
288
|
-
*
|
|
289
|
-
* @remarks
|
|
290
|
-
* If no children are provided, it empties the node.
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* ```ts
|
|
294
|
-
* div.replaceChildren(h('p', null, 'New Content'))
|
|
295
|
-
* ```
|
|
296
|
-
*
|
|
297
|
-
* @param this - The JJE, JJD or JJDF instance.
|
|
298
|
-
* @param children - The children to replace with.
|
|
299
|
-
* @returns This instance for chaining.
|
|
300
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
|
|
301
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/replaceChildren | Document.replaceChildren}
|
|
302
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/replaceChildren | DocumentFragment.replaceChildren}
|
|
303
|
-
*/
|
|
304
|
-
replaceChildren(...children) {
|
|
305
|
-
const nodes = unwrapAll(children);
|
|
306
|
-
this.ref.replaceChildren(...nodes);
|
|
307
|
-
return this;
|
|
308
|
-
},
|
|
309
|
-
/**
|
|
310
|
-
* Removes all children from this node.
|
|
311
|
-
*
|
|
312
|
-
* @example
|
|
313
|
-
* ```ts
|
|
314
|
-
* div.empty()
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* @returns This instance for chaining.
|
|
318
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
|
|
319
|
-
*/
|
|
320
|
-
empty() {
|
|
321
|
-
this.replaceChildren();
|
|
322
|
-
return this;
|
|
323
|
-
},
|
|
324
|
-
};
|
|
325
|
-
const HESE = {
|
|
326
|
-
getData(name) {
|
|
327
|
-
return this.ref.dataset[name];
|
|
328
|
-
},
|
|
329
|
-
hasData(name) {
|
|
330
|
-
return hasProp(this.ref.dataset, name);
|
|
331
|
-
},
|
|
332
|
-
setData(name, value) {
|
|
333
|
-
this.ref.dataset[name] = value;
|
|
334
|
-
return this;
|
|
335
|
-
},
|
|
336
|
-
setDataObj(obj) {
|
|
337
|
-
for (const [name, value] of Object.entries(obj)) {
|
|
338
|
-
this.setData(name, value);
|
|
339
|
-
}
|
|
340
|
-
return this;
|
|
341
|
-
},
|
|
342
|
-
rmData(name) {
|
|
343
|
-
delete this.ref.dataset[name];
|
|
344
|
-
return this;
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
function assignPrototype(Class, ...mixins) {
|
|
348
|
-
for (const mixin of mixins) {
|
|
349
|
-
Object.assign(Class.prototype, mixin);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
JJN.wrap = wrap;
|
|
353
|
-
JJN.unwrap = unwrap;
|
|
354
|
-
assignPrototype(JJE, EDDF);
|
|
355
|
-
assignPrototype(JJD, DDF, EDDF);
|
|
356
|
-
assignPrototype(JJDF, DDF, EDDF);
|
|
357
|
-
assignPrototype(JJHE, HESE);
|
|
358
|
-
assignPrototype(JJSE, HESE);
|
|
359
|
-
//# sourceMappingURL=mixins.js.map
|
package/lib/mixins.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../src/mixins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,GAAG,CAAA;AAEzC;;;;;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,EAAE,IAAI,CAAC,CAAA;AAC3B,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
package/lib/util.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/util.test.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import { fileExt } from './util.js';
|
|
4
|
-
describe('fileExt()', () => {
|
|
5
|
-
it('throws for input that is not a string or URL', () => {
|
|
6
|
-
assert.throws(() => fileExt(123), TypeError, 'Should throw for a number');
|
|
7
|
-
assert.throws(() => fileExt(true), TypeError, 'Should throw for a boolean');
|
|
8
|
-
assert.throws(() => fileExt(null), TypeError, 'Should throw for null');
|
|
9
|
-
assert.throws(() => fileExt(undefined), TypeError, 'Should throw for undefined');
|
|
10
|
-
assert.throws(() => fileExt(new URL('file.txt')), TypeError, 'Should throw for an object');
|
|
11
|
-
});
|
|
12
|
-
it('returns the extension of a file path', () => {
|
|
13
|
-
assert.strictEqual(fileExt('file.txt'), 'txt');
|
|
14
|
-
assert.strictEqual(fileExt('./file.txt'), 'txt');
|
|
15
|
-
assert.strictEqual(fileExt('./path/to/file.txt'), 'txt');
|
|
16
|
-
assert.strictEqual(fileExt('/path/to/file.txt'), 'txt');
|
|
17
|
-
});
|
|
18
|
-
it('always returns lowercase', () => {
|
|
19
|
-
assert.strictEqual(fileExt('FILE.TXT'), 'txt');
|
|
20
|
-
assert.strictEqual(fileExt('./FILE.TxT'), 'txt');
|
|
21
|
-
assert.strictEqual(fileExt('./path/to/FILE.Txt'), 'txt');
|
|
22
|
-
assert.strictEqual(fileExt('/path/to/FILE.tXT'), 'txt');
|
|
23
|
-
});
|
|
24
|
-
it('returns an empty string for non-file paths', () => {
|
|
25
|
-
assert.strictEqual(fileExt('/path/to/directory'), '');
|
|
26
|
-
assert.strictEqual(fileExt('https://www.alexewerlof.com/path/to/directory'), '');
|
|
27
|
-
});
|
|
28
|
-
it('returns empty strings if there is no extension', () => {
|
|
29
|
-
assert.strictEqual(fileExt(''), '');
|
|
30
|
-
assert.strictEqual(fileExt('.'), '');
|
|
31
|
-
assert.strictEqual(fileExt('..'), '');
|
|
32
|
-
assert.strictEqual(fileExt('file'), '');
|
|
33
|
-
assert.strictEqual(fileExt('./dir'), '');
|
|
34
|
-
assert.strictEqual(fileExt('/path/to/file.'), '');
|
|
35
|
-
});
|
|
36
|
-
it('handles edge cases for dotfiles and paths', () => {
|
|
37
|
-
// Note: This implementation differs from Node.js path.extname for dotfiles (which returns '')
|
|
38
|
-
assert.strictEqual(fileExt('.env'), 'env');
|
|
39
|
-
assert.strictEqual(fileExt('.gitignore'), 'gitignore');
|
|
40
|
-
// Directories with dots should not be confused for extensions
|
|
41
|
-
assert.strictEqual(fileExt('folder.v1/file'), '');
|
|
42
|
-
// Current behavior includes query parameters
|
|
43
|
-
assert.strictEqual(fileExt('script.js?v=1'), 'js?v=1');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=util.test.js.map
|
package/lib/util.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.test.js","sourceRoot":"","sources":["../src/util.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAU,CAAC,EAAE,SAAS,EAAE,2BAA2B,CAAC,CAAA;QAChF,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAW,CAAC,EAAE,SAAS,EAAE,4BAA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