utilium 1.3.3 → 1.4.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.d.ts +1 -4
- package/dist/objects.d.ts +5 -2
- package/dist/objects.js +0 -8
- package/package.json +1 -1
- package/src/fs.ts +1 -10
- package/src/objects.ts +5 -8
package/dist/fs.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type JSONValue } from './objects.js';
|
1
2
|
export declare abstract class FileMap<V> implements Map<string, V> {
|
2
3
|
protected readonly path: string;
|
3
4
|
get [Symbol.toStringTag](): string;
|
@@ -15,10 +16,6 @@ export declare abstract class FileMap<V> implements Map<string, V> {
|
|
15
16
|
get entries(): typeof this._map.entries;
|
16
17
|
get forEach(): typeof this._map.forEach;
|
17
18
|
}
|
18
|
-
export type JSONObject<Key extends string | number | symbol = string> = {
|
19
|
-
[K in Key]: JSONValue;
|
20
|
-
};
|
21
|
-
export type JSONValue<Key extends string | number | symbol = string> = string | number | boolean | JSONObject<Key> | Array<JSONValue>;
|
22
19
|
export interface JSONFileMapOptions {
|
23
20
|
/**
|
24
21
|
* Should an invalid JSON file be overwritten
|
package/dist/objects.d.ts
CHANGED
@@ -33,5 +33,8 @@ export interface ConstMap<T extends Partial<Record<keyof any, any>>, K extends k
|
|
33
33
|
export declare function map<const T extends Partial<Record<any, any>>>(items: T): Map<keyof T, T[keyof T]>;
|
34
34
|
export declare function getByString(object: Record<string, any>, path: string, separator?: RegExp): Record<string, any>;
|
35
35
|
export declare function setByString(object: Record<string, any>, path: string, value: unknown, separator?: RegExp): Record<string, any>;
|
36
|
-
|
37
|
-
export
|
36
|
+
export type JSONPrimitive = null | string | number | boolean;
|
37
|
+
export type JSONObject = {
|
38
|
+
[K in string]: JSONValue;
|
39
|
+
};
|
40
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONValue[];
|
package/dist/objects.js
CHANGED
@@ -59,11 +59,3 @@ export function setByString(object, path, value, separator = /[.[\]'"]/) {
|
|
59
59
|
.filter(p => p)
|
60
60
|
.reduce((o, p, i) => (o[p] = path.split(separator).filter(p => p).length === ++i ? value : o[p] || {}), object);
|
61
61
|
}
|
62
|
-
/** Binds a class member to the instance */
|
63
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
64
|
-
export function bound(value, { name, addInitializer }) {
|
65
|
-
addInitializer(function () {
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
67
|
-
this[name] = this[name].bind(this);
|
68
|
-
});
|
69
|
-
}
|
package/package.json
CHANGED
package/src/fs.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { isJSON } from './objects.js';
|
1
|
+
import { isJSON, type JSONValue } from './objects.js';
|
2
2
|
import * as fs from 'fs';
|
3
3
|
|
4
4
|
export abstract class FileMap<V> implements Map<string, V> {
|
@@ -49,15 +49,6 @@ export abstract class FileMap<V> implements Map<string, V> {
|
|
49
49
|
}
|
50
50
|
}
|
51
51
|
|
52
|
-
export type JSONObject<Key extends string | number | symbol = string> = { [K in Key]: JSONValue };
|
53
|
-
|
54
|
-
export type JSONValue<Key extends string | number | symbol = string> =
|
55
|
-
| string
|
56
|
-
| number
|
57
|
-
| boolean
|
58
|
-
| JSONObject<Key>
|
59
|
-
| Array<JSONValue>;
|
60
|
-
|
61
52
|
export interface JSONFileMapOptions {
|
62
53
|
/**
|
63
54
|
* Should an invalid JSON file be overwritten
|
package/src/objects.ts
CHANGED
@@ -113,11 +113,8 @@ export function setByString(object: Record<string, any>, path: string, value: un
|
|
113
113
|
.reduce((o, p, i) => (o[p] = path.split(separator).filter(p => p).length === ++i ? value : o[p] || {}), object);
|
114
114
|
}
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
export
|
119
|
-
|
120
|
-
|
121
|
-
this[name] = this[name].bind(this);
|
122
|
-
});
|
123
|
-
}
|
116
|
+
export type JSONPrimitive = null | string | number | boolean;
|
117
|
+
|
118
|
+
export type JSONObject = { [K in string]: JSONValue };
|
119
|
+
|
120
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONValue[];
|