@wxn0brp/db-storage-dir 0.1.4 → 0.1.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/format.d.ts CHANGED
@@ -1,12 +1,2 @@
1
- /**
2
- * Parses given string into a JSON object. If the string does not start with
3
- * a {, it is wrapped in one. This allows for a shorthand when
4
- * storing/reading data from a file.
5
- */
6
1
  export declare function parseData(data: string): any;
7
- /**
8
- * Converts given object to a string. If the string is a valid json5, it is
9
- * returned as is. If it is a valid json5 wrapped in {}, the curly brackets
10
- * are removed. Otherwise the string is wrapped in {}.
11
- */
12
- export declare function stringifyData(data: any): any;
2
+ export declare function stringifyData(data: any): string;
package/dist/format.js CHANGED
@@ -1,23 +1,9 @@
1
1
  import json5 from "json5";
2
- /**
3
- * Parses given string into a JSON object. If the string does not start with
4
- * a {, it is wrapped in one. This allows for a shorthand when
5
- * storing/reading data from a file.
6
- */
7
2
  export function parseData(data) {
8
- if (!data.startsWith("{"))
9
- data = "{" + data + "}";
3
+ if (data[0] !== "{")
4
+ return json5.parse(`{${data}}`);
10
5
  return json5.parse(data);
11
6
  }
12
- /**
13
- * Converts given object to a string. If the string is a valid json5, it is
14
- * returned as is. If it is a valid json5 wrapped in {}, the curly brackets
15
- * are removed. Otherwise the string is wrapped in {}.
16
- */
17
7
  export function stringifyData(data) {
18
- data = json5.stringify(data);
19
- if (data.startsWith("{")) {
20
- data = data.slice(1, -1);
21
- }
22
- return data;
8
+ return json5.stringify(data).slice(1, -1);
23
9
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.1.4";
1
+ export const version = "0.1.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-dir",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
@@ -16,11 +16,11 @@
16
16
  "json5": "^2.2.3"
17
17
  },
18
18
  "peerDependencies": {
19
- "@wxn0brp/db-core": ">=0.2.4"
19
+ "@wxn0brp/db-core": ">=0.4.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/bun": "*",
23
- "@wxn0brp/db-core": "^0.2.4",
23
+ "@wxn0brp/db-core": "^0.4.0",
24
24
  "tsc-alias": "*",
25
25
  "typescript": "*"
26
26
  },