@hypernym/utils 2.0.1 → 2.1.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/fs/index.mjs +13 -0
- package/dist/types/fs/index.d.ts +31 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +13 -9
- package/dist/node/index.mjs +0 -7
- package/dist/types/node/index.d.ts +0 -6
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { access, constants, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
|
|
4
|
+
async function exists(path) {
|
|
5
|
+
return await access(path, constants.F_OK).then(() => true).catch(() => false);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async function writeFile(path, data, options) {
|
|
9
|
+
await mkdir(dirname(path), { recursive: true });
|
|
10
|
+
return await writeFile$1(path, data, options);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { exists, writeFile };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { writeFile as writeFile$1 } from 'node:fs/promises';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the file or directory exists.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // New import
|
|
10
|
+
* import { exists } from '@hypernym/utils/fs'
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Deprecated import
|
|
15
|
+
* import { exists } from '@hypernym/utils/node'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function exists(path: string): Promise<boolean>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Writes data to a file recursively.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { writeFile } from '@hypernym/utils/fs'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function writeFile(path: string, data: Parameters<typeof writeFile$1>[1], options?: Parameters<typeof writeFile$1>[2]): Promise<void>;
|
|
30
|
+
|
|
31
|
+
export { exists, writeFile };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -157,7 +157,7 @@ type PartialOptions = {
|
|
|
157
157
|
*/
|
|
158
158
|
type PartialDeep<T, Options extends PartialOptions = {
|
|
159
159
|
arrays: true;
|
|
160
|
-
}> = T extends BuiltIn ? T | undefined : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<
|
|
160
|
+
}> = T extends BuiltIn ? T | undefined : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<Partial<K>, PartialDeep<V, Options>> : T extends Set<infer V> ? Set<PartialDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<PartialDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<Partial<V>> : T extends Promise<infer V> ? Promise<PartialDeep<V, Options>> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<PartialDeep<V, Options>> : Array<PartialDeep<V, Options>> : PartialObjectDeep<T, Options> : T | undefined : PartialObjectDeep<T, Options> : unknown;
|
|
161
161
|
type PartialObjectDeep<T extends object, Options extends PartialOptions = {
|
|
162
162
|
arrays: true;
|
|
163
163
|
}> = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
"types": "./dist/types/index.d.ts",
|
|
14
14
|
"import": "./dist/index.mjs"
|
|
15
15
|
},
|
|
16
|
+
"./fs": {
|
|
17
|
+
"types": "./dist/types/fs/index.d.ts",
|
|
18
|
+
"import": "./dist/fs/index.mjs"
|
|
19
|
+
},
|
|
16
20
|
"./node": {
|
|
17
|
-
"types": "./dist/types/
|
|
18
|
-
"import": "./dist/
|
|
21
|
+
"types": "./dist/types/fs/index.d.ts",
|
|
22
|
+
"import": "./dist/fs/index.mjs"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"scripts": {
|
|
37
41
|
"dev": "vite playgrounds/client",
|
|
38
42
|
"dev:node": "vite-node -w playgrounds/node/main.ts",
|
|
39
|
-
"build": "
|
|
43
|
+
"build": "hyperbundler",
|
|
40
44
|
"test:types": "vitest -c .config/vitest.config.ts typecheck",
|
|
41
45
|
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js .",
|
|
42
46
|
"lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js --fix .",
|
|
@@ -44,14 +48,14 @@
|
|
|
44
48
|
"prepublishOnly": "npm run build"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
51
|
+
"@hypernym/bundler": "^0.1.2",
|
|
47
52
|
"@hypernym/eslint-config": "^2.0.1",
|
|
48
53
|
"@hypernym/prettier-config": "^2.0.1",
|
|
49
|
-
"@hypernym/tsconfig": "^1.0
|
|
50
|
-
"@types/node": "^20.8.
|
|
51
|
-
"eslint": "^8.
|
|
54
|
+
"@hypernym/tsconfig": "^1.1.0",
|
|
55
|
+
"@types/node": "^20.8.4",
|
|
56
|
+
"eslint": "^8.51.0",
|
|
52
57
|
"prettier": "^3.0.3",
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^5.1.6",
|
|
58
|
+
"typescript": "^5.2.2",
|
|
55
59
|
"vitest": "^0.34.6"
|
|
56
60
|
}
|
|
57
61
|
}
|
package/dist/node/index.mjs
DELETED