@ms-cloudpack/json-utilities 0.0.7 → 0.0.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"readJson.d.ts","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAU9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAWnE"}
1
+ {"version":3,"file":"readJson.d.ts","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAU9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAUnE"}
package/lib/readJson.js CHANGED
@@ -21,7 +21,6 @@ export async function readJson(path) {
21
21
  export function readJsonSync(path) {
22
22
  let result = undefined;
23
23
  try {
24
- // eslint-disable-next-line no-restricted-syntax
25
24
  result = JSON.parse(fs.readFileSync(path, 'utf8'));
26
25
  }
27
26
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"readJson.js","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,sGAAsG;AACtG,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAQ,IAAY;IAChD,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KACvE;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAQ,IAAY;IAC9C,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,gDAAgD;QAChD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KAC7D;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\n// NOTE: Importing the whole module (not named exports) is required to make Jest mocks work elsewhere.\nimport fsPromises from 'fs/promises';\n\n/**\n * Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.\n */\nexport async function readJson<TData>(path: string): Promise<TData | undefined> {\n let result: TData | undefined = undefined;\n\n try {\n result = JSON.parse(await fsPromises.readFile(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n\n/**\n * Synchronously reads JSON from a path and returns the object, or undefined if it does not exist\n * or is unparsable.\n */\nexport function readJsonSync<TData>(path: string): TData | undefined {\n let result: TData | undefined = undefined;\n\n try {\n // eslint-disable-next-line no-restricted-syntax\n result = JSON.parse(fs.readFileSync(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"readJson.js","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,sGAAsG;AACtG,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAQ,IAAY;IAChD,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KACvE;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAQ,IAAY;IAC9C,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KAC7D;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\n// NOTE: Importing the whole module (not named exports) is required to make Jest mocks work elsewhere.\nimport fsPromises from 'fs/promises';\n\n/**\n * Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.\n */\nexport async function readJson<TData>(path: string): Promise<TData | undefined> {\n let result: TData | undefined = undefined;\n\n try {\n result = JSON.parse(await fsPromises.readFile(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n\n/**\n * Synchronously reads JSON from a path and returns the object, or undefined if it does not exist\n * or is unparsable.\n */\nexport function readJsonSync<TData>(path: string): TData | undefined {\n let result: TData | undefined = undefined;\n\n try {\n result = JSON.parse(fs.readFileSync(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.36.1"
8
+ "packageVersion": "7.36.4"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"writeJson.d.ts","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1E;AAED;;GAEG;AAEH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAM/D"}
1
+ {"version":3,"file":"writeJson.d.ts","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1E;AAED;;GAEG;AAEH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAK/D"}
package/lib/writeJson.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import fs from 'fs';
2
2
  import fsPromises from 'fs/promises';
3
3
  import path from 'path';
4
- import { ensureDir, ensureDirSync } from 'fs-extra';
4
+ import fsExtra from 'fs-extra';
5
5
  /**
6
6
  * Writes json to a path. Ensures the path exists.
7
7
  */
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  export async function writeJson(filePath, data) {
10
10
  const folderPath = path.dirname(filePath);
11
- await ensureDir(folderPath);
11
+ await fsExtra.ensureDir(folderPath);
12
12
  await fsPromises.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
13
13
  }
14
14
  /**
@@ -17,8 +17,7 @@ export async function writeJson(filePath, data) {
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
18
  export function writeJsonSync(filePath, data) {
19
19
  const folderPath = path.dirname(filePath);
20
- ensureDirSync(folderPath);
21
- // eslint-disable-next-line no-restricted-syntax
20
+ fsExtra.ensureDirSync(folderPath);
22
21
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
23
22
  }
24
23
  //# sourceMappingURL=writeJson.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeJson.js","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD;;GAEG;AACH,8DAA8D;AAC9D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAS;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;IAC5B,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,IAAS;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1B,gDAAgD;IAChD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { ensureDir, ensureDirSync } from 'fs-extra';\n\n/**\n * Writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function writeJson(filePath: string, data: any): Promise<void> {\n const folderPath = path.dirname(filePath);\n\n await ensureDir(folderPath);\n await fsPromises.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n\n/**\n * Synchronously writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function writeJsonSync(filePath: string, data: any): void {\n const folderPath = path.dirname(filePath);\n\n ensureDirSync(folderPath);\n // eslint-disable-next-line no-restricted-syntax\n fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n"]}
1
+ {"version":3,"file":"writeJson.js","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B;;GAEG;AACH,8DAA8D;AAC9D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAS;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,MAAM,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,IAAS;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAClC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport fsExtra from 'fs-extra';\n\n/**\n * Writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function writeJson(filePath: string, data: any): Promise<void> {\n const folderPath = path.dirname(filePath);\n\n await fsExtra.ensureDir(folderPath);\n await fsPromises.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n\n/**\n * Synchronously writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function writeJsonSync(filePath: string, data: any): void {\n const folderPath = path.dirname(filePath);\n\n fsExtra.ensureDirSync(folderPath);\n fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/json-utilities",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Helpers for reading/writing json files.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,6 +8,7 @@
8
8
  "sideEffects": false,
9
9
  "exports": {
10
10
  ".": {
11
+ "source": "./src/index.ts",
11
12
  "types": "./lib/index.d.ts",
12
13
  "import": "./lib/index.js"
13
14
  }