boma 1.0.0 → 1.0.1
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/LICENSE +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/package.json +3 -2
- package/readme.md +2 -0
package/LICENSE
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -20,4 +20,4 @@ export declare const isErrorWithMessage: (error: unknown) => error is ErrorWithM
|
|
|
20
20
|
export declare const isSyntaxError: (error: unknown) => error is SyntaxError;
|
|
21
21
|
export declare const saveJSON: (filePath: string, objToSave: Serializable, format?: boolean) => void;
|
|
22
22
|
export declare const readJSON: (props: ReadJSONProps) => any;
|
|
23
|
-
export declare const addToJSON: (filePath: string, objToAdd: SerializableObject | SerializableArray) => void;
|
|
23
|
+
export declare const addToJSON: (filePath: string, objToAdd: SerializableObject | SerializableArray, format?: boolean) => void;
|
package/dist/index.js
CHANGED
|
@@ -62,19 +62,19 @@ export const readJSON = (props) => {
|
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
export const addToJSON = (filePath, objToAdd) => {
|
|
65
|
+
export const addToJSON = (filePath, objToAdd, format) => {
|
|
66
66
|
const oldJSON = readJSON({ filePath, createIfNotFound: true });
|
|
67
67
|
if (oldJSON === null || typeof oldJSON !== 'object') {
|
|
68
68
|
return saveJSON(filePath, objToAdd);
|
|
69
69
|
}
|
|
70
70
|
if (Array.isArray(oldJSON) && Array.isArray(objToAdd)) {
|
|
71
|
-
saveJSON(filePath, [...oldJSON, ...objToAdd]);
|
|
71
|
+
saveJSON(filePath, [...oldJSON, ...objToAdd], format);
|
|
72
72
|
}
|
|
73
73
|
else if (!Array.isArray(oldJSON) && !Array.isArray(objToAdd)) {
|
|
74
|
-
saveJSON(filePath, { ...oldJSON, ...objToAdd });
|
|
74
|
+
saveJSON(filePath, { ...oldJSON, ...objToAdd }, format);
|
|
75
75
|
}
|
|
76
76
|
else if (Array.isArray(objToAdd) && Object.keys(oldJSON).length === 0) {
|
|
77
|
-
saveJSON(filePath, [...objToAdd]);
|
|
77
|
+
saveJSON(filePath, [...objToAdd], format);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
80
|
throw new Error('Cannot merge array with object');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boma",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Primitive JSON helper",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"author": "Nick",
|
|
24
|
+
"author": "Nick G.",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/Psychosynthesis/Boma/issues"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/Psychosynthesis/Boma#readme",
|
|
30
|
+
"keywords": [ "json", "helper" ],
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/node": "^22.13.10",
|
|
32
33
|
"typescript": "^5.8.x"
|
package/readme.md
CHANGED