@hypernym/utils 3.4.4 → 3.4.6

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.js ADDED
@@ -0,0 +1,437 @@
1
+ //#region src/base/index.ts
2
+ /**
3
+ * An empty arrow function that performs no operation.
4
+ *
5
+ * @example
6
+ *
7
+ * ```ts
8
+ * import { noop } from '@hypernym/utils'
9
+ *
10
+ * noop()
11
+ * ```
12
+ */
13
+ const noop = () => {};
14
+ /**
15
+ * Returns a string representing the object.
16
+ *
17
+ * @example
18
+ *
19
+ * ```ts
20
+ * import { toString } from '@hypernym/utils'
21
+ *
22
+ * toString({}) // 'Object'
23
+ * ```
24
+ */
25
+ const toString = (v) => Object.prototype.toString.call(v).slice(8, -1);
26
+
27
+ //#endregion
28
+ //#region src/is/index.ts
29
+ /**
30
+ * Checks if the code is running in the browser.
31
+ *
32
+ * @example
33
+ *
34
+ * ```ts
35
+ * import { isBrowser } from '@hypernym/utils'
36
+ *
37
+ * isBrowser // true
38
+ * ```
39
+ */
40
+ const isBrowser = typeof window !== "undefined";
41
+ /**
42
+ * Returns a boolean if the given value is a `null`.
43
+ *
44
+ * @example
45
+ *
46
+ * ```ts
47
+ * import { isNull } from '@hypernym/utils'
48
+ *
49
+ * isNull(null) // true
50
+ * ```
51
+ */
52
+ const isNull = (v) => v === null;
53
+ /**
54
+ * Returns a boolean if the given value is a `undefined`.
55
+ *
56
+ * @example
57
+ *
58
+ * ```ts
59
+ * import { isUndefined } from '@hypernym/utils'
60
+ *
61
+ * isUndefined(undefined) // true
62
+ * ```
63
+ */
64
+ const isUndefined = (v) => typeof v === "undefined";
65
+ /**
66
+ * Returns a boolean if the given value is a `string`.
67
+ *
68
+ * @example
69
+ *
70
+ * ```ts
71
+ * import { isString } from '@hypernym/utils'
72
+ *
73
+ * isString('@hypernym/utils') // true
74
+ * ```
75
+ */
76
+ const isString = (v) => typeof v === "string";
77
+ /**
78
+ * Returns a boolean if the given value is an empty `string`.
79
+ *
80
+ * @example
81
+ *
82
+ * ```ts
83
+ * import { isStringEmpty } from '@hypernym/utils'
84
+ *
85
+ * isStringEmpty('') // true
86
+ * ```
87
+ */
88
+ const isStringEmpty = (v) => isString(v) && v.trim().length === 0;
89
+ /**
90
+ * Returns a boolean if the given value is a `boolean`.
91
+ *
92
+ * @example
93
+ *
94
+ * ```ts
95
+ * import { isBoolean } from '@hypernym/utils'
96
+ *
97
+ * isBoolean(true) // true
98
+ * ```
99
+ */
100
+ const isBoolean = (v) => typeof v === "boolean";
101
+ /**
102
+ * Returns a boolean if the given value is a `true`.
103
+ *
104
+ * @example
105
+ *
106
+ * ```ts
107
+ * import { isTrue } from '@hypernym/utils'
108
+ *
109
+ * isTrue(true) // true
110
+ * ```
111
+ */
112
+ const isTrue = (v) => v === true;
113
+ /**
114
+ * Returns a boolean if the given value is a `false`.
115
+ *
116
+ * @example
117
+ *
118
+ * ```ts
119
+ * import { isFalse } from '@hypernym/utils'
120
+ *
121
+ * isFalse(false) // true
122
+ * ```
123
+ */
124
+ const isFalse = (v) => v === false;
125
+ /**
126
+ * Returns a boolean if the given value is a `number`.
127
+ *
128
+ * @example
129
+ *
130
+ * ```ts
131
+ * import { isNumber } from '@hypernym/utils'
132
+ *
133
+ * isNumber(33) // true
134
+ * ```
135
+ */
136
+ const isNumber = (v) => typeof v === "number" && !isNaN(v);
137
+ /**
138
+ * Returns a boolean if the given value is a `array`.
139
+ *
140
+ * @example
141
+ *
142
+ * ```ts
143
+ * import { isArray } from '@hypernym/utils'
144
+ *
145
+ * isArray([]) // true
146
+ * ```
147
+ */
148
+ const isArray = (v) => Array.isArray(v);
149
+ /**
150
+ * Returns a boolean if the given value is an empty `array`.
151
+ *
152
+ * @example
153
+ *
154
+ * ```ts
155
+ * import { isArrayEmpty } from '@hypernym/utils'
156
+ *
157
+ * isArrayEmpty([]) // true
158
+ * ```
159
+ */
160
+ const isArrayEmpty = (v) => isArray(v) && v.length === 0;
161
+ /**
162
+ * Returns a boolean if the given value is a `object`.
163
+ *
164
+ * @example
165
+ *
166
+ * ```ts
167
+ * import { isObject } from '@hypernym/utils'
168
+ *
169
+ * isObject({}) // true
170
+ * ```
171
+ */
172
+ const isObject = (v) => toString(v) === "Object";
173
+ /**
174
+ * Returns a boolean if the given value is an empty `object`.
175
+ *
176
+ * @example
177
+ *
178
+ * ```ts
179
+ * import { isObjectEmpty } from '@hypernym/utils'
180
+ *
181
+ * isObjectEmpty({}) // true
182
+ * ```
183
+ */
184
+ const isObjectEmpty = (v) => isObject(v) && Object.keys(v).length === 0;
185
+ /**
186
+ * Returns a boolean if the given value is a `Function`.
187
+ *
188
+ * @example
189
+ *
190
+ * ```ts
191
+ * import { isFunction } from '@hypernym/utils'
192
+ *
193
+ * isFunction(() => {}) // true
194
+ * ```
195
+ */
196
+ const isFunction = (v) => v instanceof Function;
197
+ /**
198
+ * Returns a boolean if the given value is a `NaN`.
199
+ *
200
+ * @example
201
+ *
202
+ * ```ts
203
+ * import { isNaNValue } from '@hypernym/utils'
204
+ *
205
+ * isNaNValue(NaN) // true
206
+ * ```
207
+ */
208
+ const isNaNValue = (v) => typeof v === "number" && isNaN(v);
209
+ /**
210
+ * Returns a boolean if the given value is a `RegExp`.
211
+ *
212
+ * @example
213
+ *
214
+ * ```ts
215
+ * import { isRegExp } from '@hypernym/utils'
216
+ *
217
+ * isRegExp(/^hypernym/) // true
218
+ * ```
219
+ */
220
+ const isRegExp = (v) => v instanceof RegExp;
221
+ /**
222
+ * Returns a boolean if the given value is a `Map`.
223
+ *
224
+ * @example
225
+ *
226
+ * ```ts
227
+ * import { isMap } from '@hypernym/utils'
228
+ *
229
+ * isMap(new Map()) // true
230
+ * ```
231
+ */
232
+ const isMap = (v) => v instanceof Map;
233
+ /**
234
+ * Returns a boolean if the given value is a `WeakMap`.
235
+ *
236
+ * @example
237
+ *
238
+ * ```ts
239
+ * import { isWeakMap } from '@hypernym/utils'
240
+ *
241
+ * isWeakMap(new WeakMap()) // true
242
+ * ```
243
+ */
244
+ const isWeakMap = (v) => v instanceof WeakMap;
245
+ /**
246
+ * Returns a boolean if the given value is a `Set`.
247
+ *
248
+ * @example
249
+ *
250
+ * ```ts
251
+ * import { isSet } from '@hypernym/utils'
252
+ *
253
+ * isSet(new Set()) // true
254
+ * ```
255
+ */
256
+ const isSet = (v) => v instanceof Set;
257
+ /**
258
+ * Returns a boolean if the given value is a `WeakSet`.
259
+ *
260
+ * @example
261
+ *
262
+ * ```ts
263
+ * import { isWeakSet } from '@hypernym/utils'
264
+ *
265
+ * isWeakSet(new WeakSet()) // true
266
+ * ```
267
+ */
268
+ const isWeakSet = (v) => v instanceof WeakSet;
269
+ /**
270
+ * Returns a boolean if the given value is a `symbol`.
271
+ *
272
+ * @example
273
+ *
274
+ * ```ts
275
+ * import { isSymbol } from '@hypernym/utils'
276
+ *
277
+ * isSymbol(Symboly('hypernym')) // true
278
+ * ```
279
+ */
280
+ const isSymbol = (v) => toString(v) === "Symbol";
281
+ /**
282
+ * Returns a boolean if the given value is a `Date`.
283
+ *
284
+ * @example
285
+ *
286
+ * ```ts
287
+ * import { isDate } from '@hypernym/utils'
288
+ *
289
+ * isDate(new Date()) // true
290
+ * ```
291
+ */
292
+ const isDate = (v) => v instanceof Date && !isNaN(v.valueOf());
293
+ /**
294
+ * Returns a boolean if the given value is a `bigint`.
295
+ *
296
+ * @example
297
+ *
298
+ * ```ts
299
+ * import { isBigInt } from '@hypernym/utils'
300
+ *
301
+ * isBigInt(1n) // true
302
+ * ```
303
+ */
304
+ const isBigInt = (v) => typeof v === "bigint";
305
+ /**
306
+ * Returns a boolean if the given value is a `Infinity`.
307
+ *
308
+ * @example
309
+ *
310
+ * ```ts
311
+ * import { isInfinity } from '@hypernym/utils'
312
+ *
313
+ * isInfinity(Infinity) // true
314
+ * ```
315
+ */
316
+ const isInfinity = (v) => v === Infinity || v === -Infinity;
317
+ /**
318
+ * Returns a boolean if the given value is a `URL`.
319
+ *
320
+ * @example
321
+ *
322
+ * ```ts
323
+ * import { isURL } from '@hypernym/utils'
324
+ *
325
+ * isURL(new URL('https://localhost:3000')) // true
326
+ * ```
327
+ */
328
+ const isURL = (v) => v instanceof URL;
329
+ /**
330
+ * Returns a boolean if the given value is a `Error`.
331
+ *
332
+ * @example
333
+ *
334
+ * ```ts
335
+ * import { isError } from '@hypernym/utils'
336
+ *
337
+ * isError(new Error()) // true
338
+ * ```
339
+ */
340
+ const isError = (v) => v instanceof Error;
341
+ /**
342
+ * Returns a boolean if the given value is a `Primitive`.
343
+ *
344
+ * @example
345
+ *
346
+ * ```ts
347
+ * import { isPrimitive } from '@hypernym/utils'
348
+ *
349
+ * isPrimitive(true) // true
350
+ * ```
351
+ */
352
+ const isPrimitive = (v) => isString(v) || isNumber(v) || isBigInt(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
353
+ /**
354
+ * Returns a boolean if the given value is a `Element`.
355
+ *
356
+ * @example
357
+ *
358
+ * ```ts
359
+ * import { isElement } from '@hypernym/utils'
360
+ *
361
+ * isElement(el) // true
362
+ * ```
363
+ */
364
+ const isElement = (v) => v instanceof Element;
365
+ /**
366
+ * Returns a boolean if the given value is a `HTMLElement`.
367
+ *
368
+ * @example
369
+ *
370
+ * ```ts
371
+ * import { isHtmlElement } from '@hypernym/utils'
372
+ *
373
+ * isHtmlElement(htmlEl) // true
374
+ * ```
375
+ */
376
+ const isHtmlElement = (v) => v instanceof HTMLElement;
377
+ /**
378
+ * Returns a boolean if the given value is a `SVGElement`.
379
+ *
380
+ * @example
381
+ *
382
+ * ```ts
383
+ * import { isSvgElement } from '@hypernym/utils'
384
+ *
385
+ * isSvgElement(svgEl) // true
386
+ * ```
387
+ */
388
+ const isSvgElement = (v) => v instanceof SVGElement;
389
+ /**
390
+ * Returns a boolean if the given value is a `NodeList`.
391
+ *
392
+ * @example
393
+ *
394
+ * ```ts
395
+ * import { isNodeList } from '@hypernym/utils'
396
+ *
397
+ * isNodeList(document.querySelectorAll('div')) // true
398
+ * ```
399
+ */
400
+ const isNodeList = (v) => v instanceof NodeList;
401
+ /**
402
+ * Returns a boolean if the given value is an empty `NodeList`.
403
+ *
404
+ * @example
405
+ *
406
+ * ```ts
407
+ * import { isNodeListEmpty } from '@hypernym/utils'
408
+ *
409
+ * isNodeListEmpty(document.querySelectorAll('divs')) // true
410
+ * ```
411
+ */
412
+ const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
413
+ /**
414
+ * Returns a boolean if the given value is a `HTMLCollection`.
415
+ *
416
+ * @example
417
+ *
418
+ * ```ts
419
+ * import { isHtmlCollection } from '@hypernym/utils'
420
+ *
421
+ * isHtmlCollection(document.getElementsByClassName('el')) // true
422
+ * ```
423
+ */
424
+ const isHtmlCollection = (v) => v instanceof HTMLCollection;
425
+ /**
426
+ * Returns a boolean if the given value is an empty `HTMLCollection`.
427
+ *
428
+ * ```ts
429
+ * import { isHtmlCollectionEmpty } from '@hypernym/utils'
430
+ *
431
+ * isHtmlCollectionEmpty(document.getElementsByClassName('els')) // true
432
+ * ```
433
+ */
434
+ const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
435
+
436
+ //#endregion
437
+ export { isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
@@ -0,0 +1 @@
1
+ const e=()=>{},t=e=>Object.prototype.toString.call(e).slice(8,-1),n=typeof window<`u`,r=e=>e===null,i=e=>e===void 0,a=e=>typeof e==`string`,o=e=>a(e)&&e.trim().length===0,s=e=>typeof e==`boolean`,c=e=>e===!0,l=e=>e===!1,u=e=>typeof e==`number`&&!isNaN(e),d=e=>Array.isArray(e),f=e=>d(e)&&e.length===0,p=e=>t(e)===`Object`,m=e=>p(e)&&Object.keys(e).length===0,h=e=>e instanceof Function,g=e=>typeof e==`number`&&isNaN(e),_=e=>e instanceof RegExp,v=e=>e instanceof Map,y=e=>e instanceof WeakMap,b=e=>e instanceof Set,x=e=>e instanceof WeakSet,S=e=>t(e)===`Symbol`,C=e=>e instanceof Date&&!isNaN(e.valueOf()),w=e=>typeof e==`bigint`,T=e=>e===1/0||e===-1/0,E=e=>e instanceof URL,D=e=>e instanceof Error,O=e=>a(e)||u(e)||w(e)||s(e)||S(e)||r(e)||i(e),k=e=>e instanceof Element,A=e=>e instanceof HTMLElement,j=e=>e instanceof SVGElement,M=e=>e instanceof NodeList,N=e=>M(e)&&e.length===0,P=e=>e instanceof HTMLCollection,F=e=>P(e)&&e.length===0;export{d as isArray,f as isArrayEmpty,w as isBigInt,s as isBoolean,n as isBrowser,C as isDate,k as isElement,D as isError,l as isFalse,h as isFunction,P as isHtmlCollection,F as isHtmlCollectionEmpty,A as isHtmlElement,T as isInfinity,v as isMap,g as isNaNValue,M as isNodeList,N as isNodeListEmpty,r as isNull,u as isNumber,p as isObject,m as isObjectEmpty,O as isPrimitive,_ as isRegExp,b as isSet,a as isString,o as isStringEmpty,j as isSvgElement,S as isSymbol,c as isTrue,E as isURL,i as isUndefined,y as isWeakMap,x as isWeakSet,e as noop,t as toString};
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.Hyperutils={}))})(this,function(e){"use strict";const t=()=>{},n=i=>Object.prototype.toString.call(i).slice(8,-1),d=typeof window<"u",l=i=>i===null,a=i=>typeof i>"u",s=i=>typeof i=="string",N=i=>s(i)&&i.trim().length===0,o=i=>typeof i=="boolean",S=i=>i===!0,b=i=>i===!1,f=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),r=i=>m(i)&&i.length===0,c=i=>n(i)==="Object",L=i=>c(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,h=i=>typeof i=="number"&&isNaN(i),j=i=>i instanceof RegExp,M=i=>i instanceof Map,O=i=>i instanceof WeakMap,k=i=>i instanceof Set,A=i=>i instanceof WeakSet,y=i=>n(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),u=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,T=i=>i instanceof URL,W=i=>i instanceof Error,v=i=>s(i)||f(i)||u(i)||o(i)||y(i)||l(i)||a(i),C=i=>i instanceof Element,F=i=>i instanceof HTMLElement,U=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,w=i=>E(i)&&i.length===0,g=i=>i instanceof HTMLCollection,I=i=>g(i)&&i.length===0;e.isArray=m,e.isArrayEmpty=r,e.isBigInt=u,e.isBoolean=o,e.isBrowser=d,e.isDate=B,e.isElement=C,e.isError=W,e.isFalse=b,e.isFunction=H,e.isHtmlCollection=g,e.isHtmlCollectionEmpty=I,e.isHtmlElement=F,e.isInfinity=R,e.isMap=M,e.isNaNValue=h,e.isNodeList=E,e.isNodeListEmpty=w,e.isNull=l,e.isNumber=f,e.isObject=c,e.isObjectEmpty=L,e.isPrimitive=v,e.isRegExp=j,e.isSet=k,e.isString=s,e.isStringEmpty=N,e.isSvgElement=U,e.isSymbol=y,e.isTrue=S,e.isURL=T,e.isUndefined=a,e.isWeakMap=O,e.isWeakSet=A,e.noop=t,e.toString=n});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Hyperutils={}))})(this,function(e){let t=()=>{},n=e=>Object.prototype.toString.call(e).slice(8,-1),r=typeof window<`u`,i=e=>e===null,a=e=>e===void 0,o=e=>typeof e==`string`,s=e=>o(e)&&e.trim().length===0,c=e=>typeof e==`boolean`,l=e=>e===!0,u=e=>e===!1,d=e=>typeof e==`number`&&!isNaN(e),f=e=>Array.isArray(e),p=e=>f(e)&&e.length===0,m=e=>n(e)===`Object`,h=e=>m(e)&&Object.keys(e).length===0,g=e=>e instanceof Function,_=e=>typeof e==`number`&&isNaN(e),v=e=>e instanceof RegExp,y=e=>e instanceof Map,b=e=>e instanceof WeakMap,x=e=>e instanceof Set,S=e=>e instanceof WeakSet,C=e=>n(e)===`Symbol`,w=e=>e instanceof Date&&!isNaN(e.valueOf()),T=e=>typeof e==`bigint`,E=e=>e===1/0||e===-1/0,D=e=>e instanceof URL,O=e=>e instanceof Error,k=e=>o(e)||d(e)||T(e)||c(e)||C(e)||i(e)||a(e),A=e=>e instanceof Element,j=e=>e instanceof HTMLElement,M=e=>e instanceof SVGElement,N=e=>e instanceof NodeList,P=e=>N(e)&&e.length===0,F=e=>e instanceof HTMLCollection;e.isArray=f,e.isArrayEmpty=p,e.isBigInt=T,e.isBoolean=c,e.isBrowser=r,e.isDate=w,e.isElement=A,e.isError=O,e.isFalse=u,e.isFunction=g,e.isHtmlCollection=F,e.isHtmlCollectionEmpty=e=>F(e)&&e.length===0,e.isHtmlElement=j,e.isInfinity=E,e.isMap=y,e.isNaNValue=_,e.isNodeList=N,e.isNodeListEmpty=P,e.isNull=i,e.isNumber=d,e.isObject=m,e.isObjectEmpty=h,e.isPrimitive=k,e.isRegExp=v,e.isSet=x,e.isString=o,e.isStringEmpty=s,e.isSvgElement=M,e.isSymbol=C,e.isTrue=l,e.isURL=D,e.isUndefined=a,e.isWeakMap=b,e.isWeakSet=S,e.noop=t,e.toString=n});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypernym/utils",
3
- "version": "3.4.4",
3
+ "version": "3.4.6",
4
4
  "author": "Hypernym Studio",
5
5
  "description": "A collection of reusable utilities.",
6
6
  "license": "MIT",
@@ -13,12 +13,12 @@
13
13
  "type": "module",
14
14
  "exports": {
15
15
  ".": {
16
- "types": "./dist/index.d.mts",
17
- "import": "./dist/index.mjs"
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
18
  },
19
19
  "./fs": {
20
- "types": "./dist/fs/index.d.mts",
21
- "import": "./dist/fs/index.mjs"
20
+ "types": "./dist/fs/index.d.ts",
21
+ "import": "./dist/fs/index.js"
22
22
  }
23
23
  },
24
24
  "files": [
@@ -37,16 +37,6 @@
37
37
  "js",
38
38
  "ts"
39
39
  ],
40
- "scripts": {
41
- "dev:browser": "vite playgrounds/browser",
42
- "dev:server": "bun --watch playgrounds/server/main.ts",
43
- "build": "hyperbundler",
44
- "test": "vitest -c test/vitest.config.ts",
45
- "lint": "eslint .",
46
- "lint:fix": "eslint --fix .",
47
- "format": "prettier --write .",
48
- "prepublishOnly": "npm run build"
49
- },
50
40
  "peerDependencies": {
51
41
  "@types/node": ">=20.0.0",
52
42
  "typescript": ">=5.0.0"
@@ -60,14 +50,23 @@
60
50
  }
61
51
  },
62
52
  "devDependencies": {
63
- "@hypernym/bundler": "^0.14.3",
64
- "@hypernym/eslint-config": "^3.6.1",
65
- "@hypernym/prettier-config": "^3.2.4",
66
- "@hypernym/tsconfig": "^2.6.1",
67
- "@types/node": "^22.15.17",
68
- "eslint": "^9.26.0",
69
- "prettier": "^3.5.3",
70
- "typescript": "^5.8.3",
71
- "vitest": "^3.1.3"
53
+ "@hypernym/bundler": "^0.30.4",
54
+ "@hypernym/eslint-config": "^3.6.4",
55
+ "@hypernym/prettier-config": "^3.2.7",
56
+ "@hypernym/tsconfig": "^2.6.2",
57
+ "@types/node": "^24.7.2",
58
+ "eslint": "^9.37.0",
59
+ "prettier": "^3.6.2",
60
+ "typescript": "^5.9.3",
61
+ "vitest": "^3.2.4"
62
+ },
63
+ "scripts": {
64
+ "dev:browser": "vite playgrounds/browser",
65
+ "dev:server": "bun --watch playgrounds/server/main.ts",
66
+ "build": "hyperbundler",
67
+ "test": "vitest -c test/vitest.config.ts",
68
+ "lint": "eslint .",
69
+ "lint:fix": "eslint --fix .",
70
+ "format": "prettier --write ."
72
71
  }
73
- }
72
+ }
package/dist/fs/index.mjs DELETED
@@ -1,59 +0,0 @@
1
- import { access, constants, readFile, readdir as readdir$1, mkdir as mkdir$1, writeFile as writeFile$1, cp, rm } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { isURL, isString } from '../index.mjs';
5
-
6
- async function exists(path) {
7
- return await access(path, constants.F_OK).then(() => true).catch(() => false);
8
- }
9
-
10
- async function read(path, options = {}) {
11
- const { encoding = "utf-8" } = options;
12
- return await readFile(path, { encoding, ...options });
13
- }
14
-
15
- async function readdir(path, options = {}) {
16
- const { encoding = "utf-8", recursive = true } = options;
17
- return await readdir$1(path, {
18
- encoding,
19
- recursive,
20
- ...options
21
- });
22
- }
23
-
24
- async function write(path, data, options) {
25
- await mkdir$1(dirname(isURL(path) ? fileURLToPath(path) : path), {
26
- recursive: true
27
- });
28
- await writeFile$1(path, data, options);
29
- }
30
- const writeFile = write;
31
-
32
- async function copy(source, destination, options = {}) {
33
- const { recursive = true, filter } = options;
34
- const sources = isString(source) || isURL(source) ? [source] : source;
35
- for (const src of sources) {
36
- await cp(src, destination, {
37
- recursive,
38
- filter
39
- });
40
- }
41
- }
42
-
43
- async function mkdir(path, options = {}) {
44
- const { recursive = true, mode } = options;
45
- const paths = isString(path) || isURL(path) ? [path] : path;
46
- for (const p of paths) {
47
- await mkdir$1(p, { recursive, mode });
48
- }
49
- }
50
-
51
- async function remove(path, options = {}) {
52
- const { recursive = true, force = true } = options;
53
- const paths = isString(path) || isURL(path) ? [path] : path;
54
- for (const p of paths) {
55
- await rm(p, { recursive, force, ...options });
56
- }
57
- }
58
-
59
- export { copy, exists, mkdir, read, readdir, remove, write, writeFile };
@@ -1 +0,0 @@
1
- const y=()=>{},i=e=>Object.prototype.toString.call(e).slice(8,-1),g=typeof window<"u",s=e=>e===null,n=e=>typeof e>"u",t=e=>typeof e=="string",E=e=>t(e)&&e.trim().length===0,o=e=>typeof e=="boolean",u=e=>e===!0,N=e=>e===!1,a=e=>typeof e=="number"&&!isNaN(e),l=e=>Array.isArray(e),b=e=>l(e)&&e.length===0,r=e=>i(e)==="Object",S=e=>r(e)&&Object.keys(e).length===0,L=e=>e instanceof Function,d=e=>typeof e=="number"&&isNaN(e),M=e=>e instanceof RegExp,O=e=>e instanceof Map,h=e=>e instanceof WeakMap,j=e=>e instanceof Set,k=e=>e instanceof WeakSet,c=e=>i(e)==="Symbol",H=e=>e instanceof Date&&!isNaN(e.valueOf()),f=e=>typeof e=="bigint",A=e=>e===1/0||e===-1/0,R=e=>e instanceof URL,W=e=>e instanceof Error,v=e=>t(e)||a(e)||f(e)||o(e)||c(e)||s(e)||n(e),w=e=>e instanceof Element,x=e=>e instanceof HTMLElement,B=e=>e instanceof SVGElement,p=e=>e instanceof NodeList,C=e=>p(e)&&e.length===0,m=e=>e instanceof HTMLCollection,F=e=>m(e)&&e.length===0;export{l as isArray,b as isArrayEmpty,f as isBigInt,o as isBoolean,g as isBrowser,H as isDate,w as isElement,W as isError,N as isFalse,L as isFunction,m as isHtmlCollection,F as isHtmlCollectionEmpty,x as isHtmlElement,A as isInfinity,O as isMap,d as isNaNValue,p as isNodeList,C as isNodeListEmpty,s as isNull,a as isNumber,r as isObject,S as isObjectEmpty,v as isPrimitive,M as isRegExp,j as isSet,t as isString,E as isStringEmpty,B as isSvgElement,c as isSymbol,u as isTrue,R as isURL,n as isUndefined,h as isWeakMap,k as isWeakSet,y as noop,i as toString};
package/dist/index.mjs DELETED
@@ -1,40 +0,0 @@
1
- const noop = () => {
2
- };
3
- const toString = (v) => Object.prototype.toString.call(v).slice(8, -1);
4
-
5
- const isBrowser = typeof window !== "undefined";
6
- const isNull = (v) => v === null;
7
- const isUndefined = (v) => typeof v === "undefined";
8
- const isString = (v) => typeof v === "string";
9
- const isStringEmpty = (v) => isString(v) && v.trim().length === 0;
10
- const isBoolean = (v) => typeof v === "boolean";
11
- const isTrue = (v) => v === true;
12
- const isFalse = (v) => v === false;
13
- const isNumber = (v) => typeof v === "number" && !isNaN(v);
14
- const isArray = (v) => Array.isArray(v);
15
- const isArrayEmpty = (v) => isArray(v) && v.length === 0;
16
- const isObject = (v) => toString(v) === "Object";
17
- const isObjectEmpty = (v) => isObject(v) && Object.keys(v).length === 0;
18
- const isFunction = (v) => v instanceof Function;
19
- const isNaNValue = (v) => typeof v === "number" && isNaN(v);
20
- const isRegExp = (v) => v instanceof RegExp;
21
- const isMap = (v) => v instanceof Map;
22
- const isWeakMap = (v) => v instanceof WeakMap;
23
- const isSet = (v) => v instanceof Set;
24
- const isWeakSet = (v) => v instanceof WeakSet;
25
- const isSymbol = (v) => toString(v) === "Symbol";
26
- const isDate = (v) => v instanceof Date && !isNaN(v.valueOf());
27
- const isBigInt = (v) => typeof v === "bigint";
28
- const isInfinity = (v) => v === Infinity || v === -Infinity;
29
- const isURL = (v) => v instanceof URL;
30
- const isError = (v) => v instanceof Error;
31
- const isPrimitive = (v) => isString(v) || isNumber(v) || isBigInt(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
32
- const isElement = (v) => v instanceof Element;
33
- const isHtmlElement = (v) => v instanceof HTMLElement;
34
- const isSvgElement = (v) => v instanceof SVGElement;
35
- const isNodeList = (v) => v instanceof NodeList;
36
- const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
37
- const isHtmlCollection = (v) => v instanceof HTMLCollection;
38
- const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
39
-
40
- export { isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };