@stryke/fs 0.33.62 → 0.33.64

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +1 -1
  3. package/dist/buffer.d.cts.map +1 -1
  4. package/dist/buffer.d.mts.map +1 -1
  5. package/dist/buffer.mjs.map +1 -1
  6. package/dist/chmod-x.d.mts.map +1 -1
  7. package/dist/index.d.cts +3 -3
  8. package/dist/index.d.mts +3 -3
  9. package/dist/json/src/storm-json.cjs +11 -22
  10. package/dist/json/src/storm-json.mjs +11 -22
  11. package/dist/json/src/storm-json.mjs.map +1 -1
  12. package/dist/json/src/utils/stringify.cjs +1 -35
  13. package/dist/json/src/utils/stringify.mjs +1 -35
  14. package/dist/json/src/utils/stringify.mjs.map +1 -1
  15. package/dist/json.cjs +22 -9
  16. package/dist/json.d.cts +4 -11
  17. package/dist/json.d.cts.map +1 -1
  18. package/dist/json.d.mts +4 -11
  19. package/dist/json.d.mts.map +1 -1
  20. package/dist/json.mjs +22 -9
  21. package/dist/json.mjs.map +1 -1
  22. package/dist/toml.cjs +6 -17
  23. package/dist/toml.d.cts +9 -50
  24. package/dist/toml.d.cts.map +1 -1
  25. package/dist/toml.d.mts +9 -50
  26. package/dist/toml.d.mts.map +1 -1
  27. package/dist/toml.mjs +5 -16
  28. package/dist/toml.mjs.map +1 -1
  29. package/dist/type-checks/src/is-buffer.cjs +4 -2
  30. package/dist/type-checks/src/is-buffer.mjs +2 -0
  31. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  32. package/dist/type-checks/src/is-plain-object.cjs +2 -2
  33. package/dist/type-checks/src/is-plain-object.mjs +2 -2
  34. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  35. package/dist/type-checks/src/type-detect.cjs +2 -2
  36. package/dist/type-checks/src/type-detect.mjs +2 -2
  37. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  38. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  # Changelog for Stryke - Fs
4
4
 
5
+ ## [0.33.64](https://github.com/storm-software/stryke/releases/tag/fs%400.33.64) (03/23/2026)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **monorepo:** Update all repository projects to resolve linting failures ([e9fb597b](https://github.com/storm-software/stryke/commit/e9fb597b))
10
+
11
+ ### Updated Dependencies
12
+
13
+ - Updated **string-format** to **v0.17.7**
14
+ - Updated **type-checks** to **v0.6.0**
15
+ - Updated **convert** to **v0.6.57**
16
+ - Updated **helpers** to **v0.10.7**
17
+ - Updated **types** to **v0.11.2**
18
+ - Updated **json** to **v0.14.11**
19
+ - Updated **path** to **v0.27.3**
20
+
21
+ ## [0.33.63](https://github.com/storm-software/stryke/releases/tag/fs%400.33.63) (03/16/2026)
22
+
23
+ ### Miscellaneous
24
+
25
+ - **monorepo:** Added `README.md` workspace files ([515dc333](https://github.com/storm-software/stryke/commit/515dc333))
26
+
27
+ ### Updated Dependencies
28
+
29
+ - Updated **string-format** to **v0.17.6**
30
+ - Updated **type-checks** to **v0.5.41**
31
+ - Updated **convert** to **v0.6.56**
32
+ - Updated **helpers** to **v0.10.6**
33
+ - Updated **types** to **v0.11.1**
34
+ - Updated **json** to **v0.14.10**
35
+ - Updated **path** to **v0.27.2**
36
+
5
37
  ## [0.33.62](https://github.com/storm-software/stryke/releases/tag/fs%400.33.62) (03/16/2026)
6
38
 
7
39
  ### Updated Dependencies
package/README.md CHANGED
@@ -28,7 +28,7 @@ This package is part of Storm Software's **🌩️ Stryke** monorepo. Stryke pac
28
28
 
29
29
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
30
30
 
31
- [![Version](https://img.shields.io/badge/version-0.33.56-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://github.com/storm-software/stryke)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
+ [![Version](https://img.shields.io/badge/version-0.33.62-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://github.com/storm-software/stryke)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
32
32
 
33
33
  > [!IMPORTANT] Important
34
34
  > This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.d.cts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":";;AA8BA;AAsBA;AAmBA;AAiBA;;iBA1DsB,cAAA,oBAAkC,QAAQ;;;;;;;iBAsBhD,kBAAA,oBAAsC;;;;;;;iBAmBhC,eAAA,yBAAwC,cAAW;;;;;;;iBAiBzD,mBAAA,yBAA4C"}
1
+ {"version":3,"file":"buffer.d.cts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":";;AA8BA;AAmBA;AAmBA;AAiBA;;iBAvDsB,cAAA,oBAAkC,QAAQ;;;;;;;iBAmBhD,kBAAA,oBAAsC;;;;;;;iBAmBhC,eAAA,yBAAwC,cAAW;;;;;;;iBAiBzD,mBAAA,yBAA4C"}
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.d.mts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":";;AA8BA;AAsBA;AAmBA;AAiBA;;iBA1DsB,cAAA,oBAAkC,QAAQ;;;;;;;iBAsBhD,kBAAA,oBAAsC;;;;;;;iBAmBhC,eAAA,yBAAwC,cAAW;;;;;;;iBAiBzD,mBAAA,yBAA4C"}
1
+ {"version":3,"file":"buffer.d.mts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":";;AA8BA;AAmBA;AAmBA;AAiBA;;iBAvDsB,cAAA,oBAAkC,QAAQ;;;;;;;iBAmBhD,kBAAA,oBAAsC;;;;;;;iBAmBhC,eAAA,yBAAwC,cAAW;;;;;;;iBAiBzD,mBAAA,yBAA4C"}
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.mjs","names":[],"sources":["../src/buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { findFilePath } from \"@stryke/path\";\nimport { Buffer } from \"node:buffer\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { createDirectory, createDirectorySync } from \"./helpers\";\n\n/**\n * Reads a file from the given path and returns its content as an ArrayBuffer. The file is expected to be located relative to the current directory of this module.\n *\n * @param filePath - The path to the file to read.\n * @returns The content of the file as an ArrayBuffer.\n */\nexport async function readFileBuffer(filePath: string): Promise<ArrayBuffer> {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n if (!existsSync(filePath)) {\n throw new Error(`File does not exist at path: ${filePath}`);\n }\n\n const b = await readFile(filePath);\n\n return b.buffer.slice(\n b.byteOffset,\n b.byteOffset + b.byteLength\n ) as ArrayBuffer;\n}\n\n/**\n * Reads a file from the given path and returns its content as an ArrayBuffer. The file is expected to be located relative to the current directory of this module.\n *\n * @param filePath - The path to the file to read.\n * @returns The content of the file as an ArrayBuffer.\n */\nexport function readFileBufferSync(filePath: string): ArrayBuffer {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n if (!existsSync(filePath)) {\n throw new Error(`File does not exist at path: ${filePath}`);\n }\n\n const b = readFileSync(filePath);\n\n return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n}\n\n/**\n * Writes an ArrayBuffer to a file at the specified path.\n *\n * @param filePath - The path to the file where the data should be written.\n * @param data - The ArrayBuffer containing the data to write.\n */\nexport async function writeFileBuffer(filePath: string, data: ArrayBuffer) {\n if (!filePath) {\n throw new Error(\"No file path provided to write data\");\n }\n if (!existsSync(findFilePath(filePath))) {\n await createDirectory(findFilePath(filePath));\n }\n\n await writeFile(filePath, Buffer.from(data));\n}\n\n/**\n * Writes an ArrayBuffer to a file at the specified path.\n *\n * @param filePath - The path to the file where the data should be written.\n * @param data - The ArrayBuffer containing the data to write.\n */\nexport function writeFileBufferSync(filePath: string, data: ArrayBuffer) {\n if (!filePath) {\n throw new Error(\"No file path provided to write data\");\n }\n if (!existsSync(findFilePath(filePath))) {\n createDirectorySync(findFilePath(filePath));\n }\n\n writeFileSync(filePath, Buffer.from(data));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,eAAsB,eAAe,UAAwC;AAC3E,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAEvD,KAAI,CAAC,WAAW,SAAS,CACvB,OAAM,IAAI,MAAM,gCAAgC,WAAW;CAG7D,MAAM,IAAI,MAAM,SAAS,SAAS;AAElC,QAAO,EAAE,OAAO,MACd,EAAE,YACF,EAAE,aAAa,EAAE,WAClB;;;;;;;;AASH,SAAgB,mBAAmB,UAA+B;AAChE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAEvD,KAAI,CAAC,WAAW,SAAS,CACvB,OAAM,IAAI,MAAM,gCAAgC,WAAW;CAG7D,MAAM,IAAI,aAAa,SAAS;AAEhC,QAAO,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW;;;;;;;;AASlE,eAAsB,gBAAgB,UAAkB,MAAmB;AACzE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,sCAAsC;AAExD,KAAI,CAAC,WAAW,aAAa,SAAS,CAAC,CACrC,OAAM,gBAAgB,aAAa,SAAS,CAAC;AAG/C,OAAM,UAAU,UAAU,OAAO,KAAK,KAAK,CAAC;;;;;;;;AAS9C,SAAgB,oBAAoB,UAAkB,MAAmB;AACvE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,sCAAsC;AAExD,KAAI,CAAC,WAAW,aAAa,SAAS,CAAC,CACrC,qBAAoB,aAAa,SAAS,CAAC;AAG7C,eAAc,UAAU,OAAO,KAAK,KAAK,CAAC"}
1
+ {"version":3,"file":"buffer.mjs","names":[],"sources":["../src/buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { findFilePath } from \"@stryke/path\";\nimport { Buffer } from \"node:buffer\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { createDirectory, createDirectorySync } from \"./helpers\";\n\n/**\n * Reads a file from the given path and returns its content as an ArrayBuffer. The file is expected to be located relative to the current directory of this module.\n *\n * @param filePath - The path to the file to read.\n * @returns The content of the file as an ArrayBuffer.\n */\nexport async function readFileBuffer(filePath: string): Promise<ArrayBuffer> {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n if (!existsSync(filePath)) {\n throw new Error(`File does not exist at path: ${filePath}`);\n }\n\n const b = await readFile(filePath);\n\n return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n}\n\n/**\n * Reads a file from the given path and returns its content as an ArrayBuffer. The file is expected to be located relative to the current directory of this module.\n *\n * @param filePath - The path to the file to read.\n * @returns The content of the file as an ArrayBuffer.\n */\nexport function readFileBufferSync(filePath: string): ArrayBuffer {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n if (!existsSync(filePath)) {\n throw new Error(`File does not exist at path: ${filePath}`);\n }\n\n const b = readFileSync(filePath);\n\n return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n}\n\n/**\n * Writes an ArrayBuffer to a file at the specified path.\n *\n * @param filePath - The path to the file where the data should be written.\n * @param data - The ArrayBuffer containing the data to write.\n */\nexport async function writeFileBuffer(filePath: string, data: ArrayBuffer) {\n if (!filePath) {\n throw new Error(\"No file path provided to write data\");\n }\n if (!existsSync(findFilePath(filePath))) {\n await createDirectory(findFilePath(filePath));\n }\n\n await writeFile(filePath, Buffer.from(data));\n}\n\n/**\n * Writes an ArrayBuffer to a file at the specified path.\n *\n * @param filePath - The path to the file where the data should be written.\n * @param data - The ArrayBuffer containing the data to write.\n */\nexport function writeFileBufferSync(filePath: string, data: ArrayBuffer) {\n if (!filePath) {\n throw new Error(\"No file path provided to write data\");\n }\n if (!existsSync(findFilePath(filePath))) {\n createDirectorySync(findFilePath(filePath));\n }\n\n writeFileSync(filePath, Buffer.from(data));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,eAAsB,eAAe,UAAwC;AAC3E,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAEvD,KAAI,CAAC,WAAW,SAAS,CACvB,OAAM,IAAI,MAAM,gCAAgC,WAAW;CAG7D,MAAM,IAAI,MAAM,SAAS,SAAS;AAElC,QAAO,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW;;;;;;;;AASlE,SAAgB,mBAAmB,UAA+B;AAChE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAEvD,KAAI,CAAC,WAAW,SAAS,CACvB,OAAM,IAAI,MAAM,gCAAgC,WAAW;CAG7D,MAAM,IAAI,aAAa,SAAS;AAEhC,QAAO,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW;;;;;;;;AASlE,eAAsB,gBAAgB,UAAkB,MAAmB;AACzE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,sCAAsC;AAExD,KAAI,CAAC,WAAW,aAAa,SAAS,CAAC,CACrC,OAAM,gBAAgB,aAAa,SAAS,CAAC;AAG/C,OAAM,UAAU,UAAU,OAAO,KAAK,KAAK,CAAC;;;;;;;;AAS9C,SAAgB,oBAAoB,UAAkB,MAAmB;AACvE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,sCAAsC;AAExD,KAAI,CAAC,WAAW,aAAa,SAAS,CAAC,CACrC,qBAAoB,aAAa,SAAS,CAAC;AAG7C,eAAc,UAAU,OAAO,KAAK,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"chmod-x.d.mts","names":[],"sources":["../src/chmod-x.ts"],"sourcesContent":[],"mappings":";;AA0BA;AAuBA;AAwBA;AAeA;AAesB,iBA7EN,UAAA,CA6EsC,IAAA,EAAO,MAAA,CAAA,EAAA,IAAA;AAe7D;;;;;iBArEsB,MAAA,gBAAmB;;;;;;;iBAwBnB,UAAA,oBAA8B;;;;;;;iBAepC,cAAA;;;;;;;iBAeM,YAAA,oBAAgC;;;;;;;iBAetC,gBAAA"}
1
+ {"version":3,"file":"chmod-x.d.mts","names":[],"sources":["../src/chmod-x.ts"],"sourcesContent":[],"mappings":";;AA0BA;AAuBA;AAwBA;AAeA;AAesB,iBA7EN,UAAA,CA6EsC,IAAO,EAAA,MAAA,CAAA,EAAA,IAAA;AAe7D;;;;;iBArEsB,MAAA,gBAAmB;;;;;;;iBAwBnB,UAAA,oBAA8B;;;;;;;iBAepC,cAAA;;;;;;;iBAeM,YAAA,oBAAgC;;;;;;;iBAetC,gBAAA"}
package/dist/index.d.cts CHANGED
@@ -10,7 +10,7 @@ import { PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, getProjectRoot, getWorksp
10
10
  import { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync } from "./helpers.cjs";
11
11
  import { install, packageExists } from "./install.cjs";
12
12
  import { isDirectory, isDirectorySymlink, isFile, isFileSymlink } from "./is-file.cjs";
13
- import { JsonReadOptions, JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.cjs";
13
+ import { JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.cjs";
14
14
  import { InferListReturnType, ListOptions, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync } from "./list-files.cjs";
15
15
  import { DEFAULT_EXTENSIONS, ResolutionCombinationOptions, ResolveOptions, getNodeModulesPaths, getResolutionCombinations, getResolutionPaths, importModule, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync } from "./resolve.cjs";
16
16
  import { GetPackageListingReturn, PackageExistsOptions, PackageMatchesOptions, doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson } from "./package-fns.cjs";
@@ -18,8 +18,8 @@ import { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync } fr
18
18
  import { NodeOptionsToken, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, tokenizeArgs } from "./registry.cjs";
19
19
  import { removeFile, removeFileSync } from "./remove-file.cjs";
20
20
  import { RELEASE_TYPES, ReleaseType, coerceVersion, deriveNewSemverVersion, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, parseVersion, satisfiesVersion } from "./semver-fns.cjs";
21
- import { TomlReadOptions, TomlWriteOptions, XOptions, readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.cjs";
21
+ import { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.cjs";
22
22
  import { loadTsConfig } from "./tsconfig.cjs";
23
23
  import { WriteFileOptions, writeFile, writeFileSync } from "./write-file.cjs";
24
24
  import { YamlReadOptions, readYamlFile, readYamlFileSync } from "./yaml.cjs";
25
- export { CompressDirectoryOptions, DEFAULT_EXTENSIONS, Encoding, GetPackageListingReturn, GetParentPathOptions, InferListReturnType, JsonReadOptions, JsonWriteOptions, ListOptions, NodeOptionsToken, PROJECT_ROOT_CONTENT, PackageExistsOptions, PackageMatchesOptions, RELEASE_TYPES, ReleaseType, ResolutionCombinationOptions, ResolveOptions, TomlReadOptions, TomlWriteOptions, WORKSPACE_ROOT_CONTENT, WriteFileOptions, XOptions, YamlReadOptions, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
25
+ export { CompressDirectoryOptions, DEFAULT_EXTENSIONS, Encoding, GetPackageListingReturn, GetParentPathOptions, InferListReturnType, JsonWriteOptions, ListOptions, NodeOptionsToken, PROJECT_ROOT_CONTENT, PackageExistsOptions, PackageMatchesOptions, RELEASE_TYPES, ReleaseType, ResolutionCombinationOptions, ResolveOptions, WORKSPACE_ROOT_CONTENT, WriteFileOptions, YamlReadOptions, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
package/dist/index.d.mts CHANGED
@@ -10,7 +10,7 @@ import { PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, getProjectRoot, getWorksp
10
10
  import { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync } from "./helpers.mjs";
11
11
  import { install, packageExists } from "./install.mjs";
12
12
  import { isDirectory, isDirectorySymlink, isFile, isFileSymlink } from "./is-file.mjs";
13
- import { JsonReadOptions, JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.mjs";
13
+ import { JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.mjs";
14
14
  import { InferListReturnType, ListOptions, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync } from "./list-files.mjs";
15
15
  import { DEFAULT_EXTENSIONS, ResolutionCombinationOptions, ResolveOptions, getNodeModulesPaths, getResolutionCombinations, getResolutionPaths, importModule, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync } from "./resolve.mjs";
16
16
  import { GetPackageListingReturn, PackageExistsOptions, PackageMatchesOptions, doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson } from "./package-fns.mjs";
@@ -18,8 +18,8 @@ import { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync } fr
18
18
  import { NodeOptionsToken, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, tokenizeArgs } from "./registry.mjs";
19
19
  import { removeFile, removeFileSync } from "./remove-file.mjs";
20
20
  import { RELEASE_TYPES, ReleaseType, coerceVersion, deriveNewSemverVersion, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, parseVersion, satisfiesVersion } from "./semver-fns.mjs";
21
- import { TomlReadOptions, TomlWriteOptions, XOptions, readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.mjs";
21
+ import { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.mjs";
22
22
  import { loadTsConfig } from "./tsconfig.mjs";
23
23
  import { WriteFileOptions, writeFile, writeFileSync } from "./write-file.mjs";
24
24
  import { YamlReadOptions, readYamlFile, readYamlFileSync } from "./yaml.mjs";
25
- export { CompressDirectoryOptions, DEFAULT_EXTENSIONS, Encoding, GetPackageListingReturn, GetParentPathOptions, InferListReturnType, JsonReadOptions, JsonWriteOptions, ListOptions, NodeOptionsToken, PROJECT_ROOT_CONTENT, PackageExistsOptions, PackageMatchesOptions, RELEASE_TYPES, ReleaseType, ResolutionCombinationOptions, ResolveOptions, TomlReadOptions, TomlWriteOptions, WORKSPACE_ROOT_CONTENT, WriteFileOptions, XOptions, YamlReadOptions, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
25
+ export { CompressDirectoryOptions, DEFAULT_EXTENSIONS, Encoding, GetPackageListingReturn, GetParentPathOptions, InferListReturnType, JsonWriteOptions, ListOptions, NodeOptionsToken, PROJECT_ROOT_CONTENT, PackageExistsOptions, PackageMatchesOptions, RELEASE_TYPES, ReleaseType, ResolutionCombinationOptions, ResolveOptions, WORKSPACE_ROOT_CONTENT, WriteFileOptions, YamlReadOptions, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
@@ -40,8 +40,17 @@ var StormJSON = class StormJSON extends superjson.default {
40
40
  * @param value - The string value to parse
41
41
  * @returns The parsed data
42
42
  */
43
- static parse(value) {
44
- return require_parse.parse(value);
43
+ static parse(value, options = {}) {
44
+ try {
45
+ if (options.expectComments === false) return require_parse.parse(value);
46
+ } catch {}
47
+ const errors = [];
48
+ const result = (0, jsonc_parser.parse)(value, errors, {
49
+ allowTrailingComma: true,
50
+ ...options
51
+ });
52
+ if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(value, errors[0]));
53
+ return result;
45
54
  }
46
55
  /**
47
56
  * Serializes the given data to a JSON string.
@@ -58,26 +67,6 @@ var StormJSON = class StormJSON extends superjson.default {
58
67
  return require_stringify.stringify(result, options?.spaces ?? 2);
59
68
  }
60
69
  /**
61
- * Parses the given JSON string and returns the object the JSON content represents.
62
- * By default javascript-style comments and trailing commas are allowed.
63
- *
64
- * @param strData - JSON content as string
65
- * @param options - JSON parse options
66
- * @returns Object the JSON content represents
67
- */
68
- static parseJson(strData, options) {
69
- try {
70
- if (options?.expectComments === false) return StormJSON.instance.parse(strData);
71
- } catch {}
72
- const errors = [];
73
- const result = (0, jsonc_parser.parse)(strData, errors, {
74
- allowTrailingComma: true,
75
- ...options
76
- });
77
- if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(strData, errors[0]));
78
- return result;
79
- }
80
- /**
81
70
  * Register a custom schema with superjson
82
71
  *
83
72
  * @param name - The name of the schema
@@ -38,8 +38,17 @@ var StormJSON = class StormJSON extends SuperJSON {
38
38
  * @param value - The string value to parse
39
39
  * @returns The parsed data
40
40
  */
41
- static parse(value) {
42
- return parse$1(value);
41
+ static parse(value, options = {}) {
42
+ try {
43
+ if (options.expectComments === false) return parse$1(value);
44
+ } catch {}
45
+ const errors = [];
46
+ const result = parse(value, errors, {
47
+ allowTrailingComma: true,
48
+ ...options
49
+ });
50
+ if (errors.length > 0 && errors[0]) throw new Error(formatParseError(value, errors[0]));
51
+ return result;
43
52
  }
44
53
  /**
45
54
  * Serializes the given data to a JSON string.
@@ -56,26 +65,6 @@ var StormJSON = class StormJSON extends SuperJSON {
56
65
  return stringify(result, options?.spaces ?? 2);
57
66
  }
58
67
  /**
59
- * Parses the given JSON string and returns the object the JSON content represents.
60
- * By default javascript-style comments and trailing commas are allowed.
61
- *
62
- * @param strData - JSON content as string
63
- * @param options - JSON parse options
64
- * @returns Object the JSON content represents
65
- */
66
- static parseJson(strData, options) {
67
- try {
68
- if (options?.expectComments === false) return StormJSON.instance.parse(strData);
69
- } catch {}
70
- const errors = [];
71
- const result = parse(strData, errors, {
72
- allowTrailingComma: true,
73
- ...options
74
- });
75
- if (errors.length > 0 && errors[0]) throw new Error(formatParseError(strData, errors[0]));
76
- return result;
77
- }
78
- /**
79
68
  * Register a custom schema with superjson
80
69
  *
81
70
  * @param name - The name of the schema
@@ -1 +1 @@
1
- {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../../../../json/src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport { Buffer } from \"node:buffer\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(value: string): TData {\n return parseValue(value);\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result, options?.spaces ?? 2);\n }\n\n /**\n * Parses the given JSON string and returns the object the JSON content represents.\n * By default javascript-style comments and trailing commas are allowed.\n *\n * @param strData - JSON content as string\n * @param options - JSON parse options\n * @returns Object the JSON content represents\n */\n public static parseJson<TData = unknown>(\n strData: string,\n options?: JsonParseOptions\n ): TData {\n try {\n if (options?.expectComments === false) {\n return StormJSON.instance.parse(strData);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(strData, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(strData, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer =>\n typeof Buffer.isBuffer === \"function\" && Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MAAuB,OAAsB;AAClE,SAAOC,QAAW,MAAM;;;;;;;;;;CAW1B,OAAuB,UACrB,OACA,SACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,QAAQ,SAAS,UAAU,EAAE;;;;;;;;;;CAWrD,OAAc,UACZ,SACA,SACO;AACP,MAAI;AACF,OAAI,SAAS,mBAAmB,MAC9B,QAAO,UAAU,SAAS,MAAM,QAAQ;UAEpC;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,SAAS,QAJjB;GACX,oBAAoB;GACpB,GAAG;GACJ,CAC0C;AAE3C,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,SAAS,OAAO,GAAG,CAAC;AAGvD,SAAO;;;;;;;;;;CAWT,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MACb,OAAO,OAAO,aAAa,cAAc,OAAO,SAAS,EAAE;CAC7D,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
1
+ {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","errors: ParseError[]","stringifyValue"],"sources":["../../../../json/src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport { Buffer } from \"node:buffer\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(\n value: string,\n options: JsonParseOptions = {}\n ): TData {\n try {\n if (options.expectComments === false) {\n return parseValue<TData>(value);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(value, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(value, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result, options?.spaces ?? 2);\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer =>\n typeof Buffer.isBuffer === \"function\" && Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MACrB,OACA,UAA4B,EAAE,EACvB;AACP,MAAI;AACF,OAAI,QAAQ,mBAAmB,MAC7B,QAAOC,QAAkB,MAAM;UAE3B;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,OAAO,QAJf;GACX,oBAAoB;GACpB,GAAG;GACJ,CACwC;AAEzC,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC;AAGrD,SAAO;;;;;;;;;;CAWT,OAAuB,UACrB,OACA,SACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,QAAQ,SAAS,UAAU,EAAE;;;;;;;;;;CAWrD,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MACb,OAAO,OAAO,aAAa,cAAc,OAAO,SAAS,EAAE;CAC7D,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
@@ -2,40 +2,6 @@ const require_is_number = require('../../../type-checks/src/is-number.cjs');
2
2
  const require_is_undefined = require('../../../type-checks/src/is-undefined.cjs');
3
3
 
4
4
  //#region ../json/src/utils/stringify.ts
5
- const invalidKeyChars = [
6
- "@",
7
- "/",
8
- "#",
9
- "$",
10
- " ",
11
- ":",
12
- ";",
13
- ",",
14
- ".",
15
- "!",
16
- "?",
17
- "&",
18
- "=",
19
- "+",
20
- "-",
21
- "*",
22
- "%",
23
- "^",
24
- "~",
25
- "|",
26
- "\\",
27
- "\"",
28
- "'",
29
- "`",
30
- "{",
31
- "}",
32
- "[",
33
- "]",
34
- "(",
35
- ")",
36
- "<",
37
- ">"
38
- ];
39
5
  /**
40
6
  * Stringify a value to a JSON-like string.
41
7
  *
@@ -58,7 +24,7 @@ const stringify = (value, spacing = 2) => {
58
24
  switch (typeof value) {
59
25
  case "number": return `${value}`;
60
26
  case "string": return JSON.stringify(value);
61
- case "object": return `{${space}${Object.keys(value).filter((key) => !require_is_undefined.isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
27
+ case "object": return `{${space}${Object.keys(value).filter((key) => !require_is_undefined.isUndefined(value[key])).map((key) => `"${key}": ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
28
  default: return "null";
63
29
  }
64
30
  };
@@ -2,40 +2,6 @@ import { isNumber } from "../../../type-checks/src/is-number.mjs";
2
2
  import { isUndefined } from "../../../type-checks/src/is-undefined.mjs";
3
3
 
4
4
  //#region ../json/src/utils/stringify.ts
5
- const invalidKeyChars = [
6
- "@",
7
- "/",
8
- "#",
9
- "$",
10
- " ",
11
- ":",
12
- ";",
13
- ",",
14
- ".",
15
- "!",
16
- "?",
17
- "&",
18
- "=",
19
- "+",
20
- "-",
21
- "*",
22
- "%",
23
- "^",
24
- "~",
25
- "|",
26
- "\\",
27
- "\"",
28
- "'",
29
- "`",
30
- "{",
31
- "}",
32
- "[",
33
- "]",
34
- "(",
35
- ")",
36
- "<",
37
- ">"
38
- ];
39
5
  /**
40
6
  * Stringify a value to a JSON-like string.
41
7
  *
@@ -58,7 +24,7 @@ const stringify = (value, spacing = 2) => {
58
24
  switch (typeof value) {
59
25
  case "number": return `${value}`;
60
26
  case "string": return JSON.stringify(value);
61
- case "object": return `{${space}${Object.keys(value).filter((key) => !isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
27
+ case "object": return `{${space}${Object.keys(value).filter((key) => !isUndefined(value[key])).map((key) => `"${key}": ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
28
  default: return "null";
63
29
  }
64
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../json/src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key =>\n `${invalidKeyChars.some(invalidKeyChar => key.includes(invalidKeyChar)) ? `\"${key}\"` : key}: ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":";;;;AAqBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CACzC,CAGE,KACC,QACE,GAAG,gBAAgB,MAAK,mBAAkB,IAAI,SAAS,eAAe,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,IAAI,QAAQ,UAAW,MAAc,MAAM,MAAM,GAC/I,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
1
+ {"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../json/src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key => `\"${key}\": ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":";;;;;;;;;;;AA+DA,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CACzC,CAGE,KACC,QAAO,IAAI,IAAI,KAAK,QAAQ,UAAW,MAAc,MAAM,MAAM,GAClE,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
package/dist/json.cjs CHANGED
@@ -1,4 +1,7 @@
1
+ const require_is_set_string = require('./type-checks/src/is-set-string.cjs');
2
+ const require_file_path_fns = require('./path/src/file-path-fns.cjs');
1
3
  const require_is_error = require('./type-checks/src/is-error.cjs');
4
+ require('./type-checks/src/index.cjs');
2
5
  const require_read_file = require('./read-file.cjs');
3
6
  const require_write_file = require('./write-file.cjs');
4
7
  const require_storm_json = require('./json/src/storm-json.cjs');
@@ -13,9 +16,11 @@ const require_storm_json = require('./json/src/storm-json.cjs');
13
16
  */
14
17
  function readJsonFileSync(path, options) {
15
18
  const content = require_read_file.readFileSync(path);
16
- if (options) options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
17
19
  try {
18
- return require_storm_json.StormJSON.parseJson(content, options);
20
+ return require_storm_json.StormJSON.parse(require_is_set_string.isSetString(content) ? content.trim() : "{}", {
21
+ expectComments: require_file_path_fns.findFileExtension(path) === "jsonc",
22
+ ...options
23
+ });
19
24
  } catch (error) {
20
25
  if (require_is_error.isError(error)) {
21
26
  error.message = error.message.replace("JSON", path);
@@ -31,11 +36,13 @@ function readJsonFileSync(path, options) {
31
36
  * @param options - JSON parse options
32
37
  * @returns Object the JSON content of the file represents
33
38
  */
34
- async function readJsonFile(path, options) {
39
+ async function readJsonFile(path, options = {}) {
35
40
  const content = await require_read_file.readFile(path);
36
- if (options) options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
37
41
  try {
38
- return require_storm_json.StormJSON.parseJson(content, options);
42
+ return require_storm_json.StormJSON.parse(require_is_set_string.isSetString(content) ? content.trim() : "{}", {
43
+ expectComments: require_file_path_fns.findFileExtension(path) === "jsonc",
44
+ ...options
45
+ });
39
46
  } catch (error) {
40
47
  if (require_is_error.isError(error)) {
41
48
  error.message = error.message.replace("JSON", path);
@@ -51,8 +58,11 @@ async function readJsonFile(path, options) {
51
58
  * @param data - data which should be serialized to JSON and written to the file
52
59
  * @param options - JSON serialize options
53
60
  */
54
- function writeJsonFileSync(path, data, options) {
55
- const serializedJson = require_storm_json.StormJSON.stringify(data, options);
61
+ function writeJsonFileSync(path, data, options = {}) {
62
+ const serializedJson = require_storm_json.StormJSON.stringify(data, {
63
+ spaces: 2,
64
+ ...options
65
+ });
56
66
  return require_write_file.writeFileSync(path, options?.appendNewLine ? `${serializedJson}\n` : serializedJson);
57
67
  }
58
68
  /**
@@ -62,8 +72,11 @@ function writeJsonFileSync(path, data, options) {
62
72
  * @param data - data which should be serialized to JSON and written to the file
63
73
  * @param options - JSON serialize options
64
74
  */
65
- async function writeJsonFile(path, data, options) {
66
- const serializedJson = require_storm_json.StormJSON.stringify(data);
75
+ async function writeJsonFile(path, data, options = {}) {
76
+ const serializedJson = require_storm_json.StormJSON.stringify(data, {
77
+ spaces: 2,
78
+ ...options
79
+ });
67
80
  return require_write_file.writeFile(path, options?.appendNewLine ? `${serializedJson}\n` : serializedJson);
68
81
  }
69
82
 
package/dist/json.d.cts CHANGED
@@ -1,14 +1,7 @@
1
1
  import { JsonParseOptions, JsonSerializeOptions } from "./json/src/types.cjs";
2
2
 
3
3
  //#region src/json.d.ts
4
- interface JsonReadOptions extends JsonParseOptions {
5
- /**
6
- * mutable field recording whether JSON ends with new line
7
- *
8
- * @defaultValue false
9
- */
10
- endsWithNewline?: boolean;
11
- }
4
+
12
5
  /**
13
6
  * Reads a JSON file and returns the object the JSON content represents.
14
7
  *
@@ -16,7 +9,7 @@ interface JsonReadOptions extends JsonParseOptions {
16
9
  * @param options - JSON parse options
17
10
  * @returns Object the JSON content of the file represents
18
11
  */
19
- declare function readJsonFileSync<T extends object = any>(path: string, options?: JsonReadOptions): T;
12
+ declare function readJsonFileSync<T extends object = any>(path: string, options?: JsonParseOptions): T;
20
13
  /**
21
14
  * Reads a JSON file and returns the object the JSON content represents.
22
15
  *
@@ -24,7 +17,7 @@ declare function readJsonFileSync<T extends object = any>(path: string, options?
24
17
  * @param options - JSON parse options
25
18
  * @returns Object the JSON content of the file represents
26
19
  */
27
- declare function readJsonFile<T extends object = any>(path: string, options?: JsonReadOptions): Promise<T>;
20
+ declare function readJsonFile<T extends object = any>(path: string, options?: JsonParseOptions): Promise<T>;
28
21
  interface JsonWriteOptions extends JsonSerializeOptions {
29
22
  /**
30
23
  * whether to append new line at the end of JSON file
@@ -50,5 +43,5 @@ declare function writeJsonFileSync<T extends object = object>(path: string, data
50
43
  */
51
44
  declare function writeJsonFile<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): Promise<void>;
52
45
  //#endregion
53
- export { JsonReadOptions, JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync };
46
+ export { JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync };
54
47
  //# sourceMappingURL=json.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.cts","names":[],"sources":["../src/json.ts"],"sourcesContent":[],"mappings":";;;UA2BiB,eAAA,SAAwB;;AAAzC;AAgBA;AA4BA;;EAGW,eAAA,CAAA,EAAA,OAAA;;;AAkBX;AAgBA;AAoBA;;;;AAIU,iBAzFM,gBAyFN,CAAA,UAAA,MAAA,GAAA,GAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAvFE,eAuFF,CAAA,EAtFP,CAsFO;;;;;;;;iBA7DY,6DAEV,kBACT,QAAQ;UAkBM,gBAAA,SAAyB;;;;;;;;;;;;;;;iBAgB1B,iEAER,aACI;;;;;;;;iBAiBU,6DAEd,aACI,mBACT"}
1
+ {"version":3,"file":"json.d.cts","names":[],"sources":["../src/json.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AA4BA;;;;AAGU,iBA/BM,gBA+BN,CAAA,UAAA,MAAA,GAAA,GAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BE,gBA6BF,CAAA,EA5BP,CA4BO;AAkBV;AAgBA;AAoBA;;;;;iBAzDsB,6DAEX,mBACR,QAAQ;UAkBM,gBAAA,SAAyB;;;;;;;;;;;;;;;iBAgB1B,iEAER,aACG;;;;;;;;iBAiBW,6DAEd,aACG,mBACR"}
package/dist/json.d.mts CHANGED
@@ -1,14 +1,7 @@
1
1
  import { JsonParseOptions, JsonSerializeOptions } from "./json/src/types.mjs";
2
2
 
3
3
  //#region src/json.d.ts
4
- interface JsonReadOptions extends JsonParseOptions {
5
- /**
6
- * mutable field recording whether JSON ends with new line
7
- *
8
- * @defaultValue false
9
- */
10
- endsWithNewline?: boolean;
11
- }
4
+
12
5
  /**
13
6
  * Reads a JSON file and returns the object the JSON content represents.
14
7
  *
@@ -16,7 +9,7 @@ interface JsonReadOptions extends JsonParseOptions {
16
9
  * @param options - JSON parse options
17
10
  * @returns Object the JSON content of the file represents
18
11
  */
19
- declare function readJsonFileSync<T extends object = any>(path: string, options?: JsonReadOptions): T;
12
+ declare function readJsonFileSync<T extends object = any>(path: string, options?: JsonParseOptions): T;
20
13
  /**
21
14
  * Reads a JSON file and returns the object the JSON content represents.
22
15
  *
@@ -24,7 +17,7 @@ declare function readJsonFileSync<T extends object = any>(path: string, options?
24
17
  * @param options - JSON parse options
25
18
  * @returns Object the JSON content of the file represents
26
19
  */
27
- declare function readJsonFile<T extends object = any>(path: string, options?: JsonReadOptions): Promise<T>;
20
+ declare function readJsonFile<T extends object = any>(path: string, options?: JsonParseOptions): Promise<T>;
28
21
  interface JsonWriteOptions extends JsonSerializeOptions {
29
22
  /**
30
23
  * whether to append new line at the end of JSON file
@@ -50,5 +43,5 @@ declare function writeJsonFileSync<T extends object = object>(path: string, data
50
43
  */
51
44
  declare function writeJsonFile<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): Promise<void>;
52
45
  //#endregion
53
- export { JsonReadOptions, JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync };
46
+ export { JsonWriteOptions, readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync };
54
47
  //# sourceMappingURL=json.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.mts","names":[],"sources":["../src/json.ts"],"sourcesContent":[],"mappings":";;;UA2BiB,eAAA,SAAwB;;AAAzC;AAgBA;AA4BA;;EAGW,eAAA,CAAA,EAAA,OAAA;;;AAkBX;AAgBA;AAoBA;;;;AAIU,iBAzFM,gBAyFN,CAAA,UAAA,MAAA,GAAA,GAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAvFE,eAuFF,CAAA,EAtFP,CAsFO;;;;;;;;iBA7DY,6DAEV,kBACT,QAAQ;UAkBM,gBAAA,SAAyB;;;;;;;;;;;;;;;iBAgB1B,iEAER,aACI;;;;;;;;iBAiBU,6DAEd,aACI,mBACT"}
1
+ {"version":3,"file":"json.d.mts","names":[],"sources":["../src/json.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AA4BA;;;;AAGU,iBA/BM,gBA+BN,CAAA,UAAA,MAAA,GAAA,GAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BE,gBA6BF,CAAA,EA5BP,CA4BO;AAkBV;AAgBA;AAoBA;;;;;iBAzDsB,6DAEX,mBACR,QAAQ;UAkBM,gBAAA,SAAyB;;;;;;;;;;;;;;;iBAgB1B,iEAER,aACG;;;;;;;;iBAiBW,6DAEd,aACG,mBACR"}
package/dist/json.mjs CHANGED
@@ -1,4 +1,7 @@
1
+ import { isSetString } from "./type-checks/src/is-set-string.mjs";
2
+ import { findFileExtension } from "./path/src/file-path-fns.mjs";
1
3
  import { isError } from "./type-checks/src/is-error.mjs";
4
+ import "./type-checks/src/index.mjs";
2
5
  import { readFile, readFileSync } from "./read-file.mjs";
3
6
  import { writeFile, writeFileSync } from "./write-file.mjs";
4
7
  import { StormJSON } from "./json/src/storm-json.mjs";
@@ -13,9 +16,11 @@ import { StormJSON } from "./json/src/storm-json.mjs";
13
16
  */
14
17
  function readJsonFileSync(path, options) {
15
18
  const content = readFileSync(path);
16
- if (options) options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
17
19
  try {
18
- return StormJSON.parseJson(content, options);
20
+ return StormJSON.parse(isSetString(content) ? content.trim() : "{}", {
21
+ expectComments: findFileExtension(path) === "jsonc",
22
+ ...options
23
+ });
19
24
  } catch (error) {
20
25
  if (isError(error)) {
21
26
  error.message = error.message.replace("JSON", path);
@@ -31,11 +36,13 @@ function readJsonFileSync(path, options) {
31
36
  * @param options - JSON parse options
32
37
  * @returns Object the JSON content of the file represents
33
38
  */
34
- async function readJsonFile(path, options) {
39
+ async function readJsonFile(path, options = {}) {
35
40
  const content = await readFile(path);
36
- if (options) options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
37
41
  try {
38
- return StormJSON.parseJson(content, options);
42
+ return StormJSON.parse(isSetString(content) ? content.trim() : "{}", {
43
+ expectComments: findFileExtension(path) === "jsonc",
44
+ ...options
45
+ });
39
46
  } catch (error) {
40
47
  if (isError(error)) {
41
48
  error.message = error.message.replace("JSON", path);
@@ -51,8 +58,11 @@ async function readJsonFile(path, options) {
51
58
  * @param data - data which should be serialized to JSON and written to the file
52
59
  * @param options - JSON serialize options
53
60
  */
54
- function writeJsonFileSync(path, data, options) {
55
- const serializedJson = StormJSON.stringify(data, options);
61
+ function writeJsonFileSync(path, data, options = {}) {
62
+ const serializedJson = StormJSON.stringify(data, {
63
+ spaces: 2,
64
+ ...options
65
+ });
56
66
  return writeFileSync(path, options?.appendNewLine ? `${serializedJson}\n` : serializedJson);
57
67
  }
58
68
  /**
@@ -62,8 +72,11 @@ function writeJsonFileSync(path, data, options) {
62
72
  * @param data - data which should be serialized to JSON and written to the file
63
73
  * @param options - JSON serialize options
64
74
  */
65
- async function writeJsonFile(path, data, options) {
66
- const serializedJson = StormJSON.stringify(data);
75
+ async function writeJsonFile(path, data, options = {}) {
76
+ const serializedJson = StormJSON.stringify(data, {
77
+ spaces: 2,
78
+ ...options
79
+ });
67
80
  return writeFile(path, options?.appendNewLine ? `${serializedJson}\n` : serializedJson);
68
81
  }
69
82
 
package/dist/json.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"json.mjs","names":[],"sources":["../src/json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport type {\n JsonParseOptions,\n JsonSerializeOptions\n} from \"@stryke/json/types\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { readFile, readFileSync } from \"./read-file\";\nimport { writeFile, writeFileSync } from \"./write-file\";\n\nexport interface JsonReadOptions extends JsonParseOptions {\n /**\n * mutable field recording whether JSON ends with new line\n *\n * @defaultValue false\n */\n endsWithNewline?: boolean;\n}\n\n/**\n * Reads a JSON file and returns the object the JSON content represents.\n *\n * @param path - A path to a file.\n * @param options - JSON parse options\n * @returns Object the JSON content of the file represents\n */\nexport function readJsonFileSync<T extends object = any>(\n path: string,\n options?: JsonReadOptions\n): T {\n const content = readFileSync(path);\n if (options) {\n options.endsWithNewline = content.codePointAt(content.length - 1) === 10;\n }\n\n try {\n return StormJSON.parseJson<T>(content, options);\n } catch (error) {\n if (isError(error)) {\n error.message = error.message.replace(\"JSON\", path);\n throw error;\n }\n\n throw new Error(`Failed to parse JSON: ${path}`);\n }\n}\n\n/**\n * Reads a JSON file and returns the object the JSON content represents.\n *\n * @param path - A path to a file.\n * @param options - JSON parse options\n * @returns Object the JSON content of the file represents\n */\nexport async function readJsonFile<T extends object = any>(\n path: string,\n options?: JsonReadOptions\n): Promise<T> {\n const content = await readFile(path);\n if (options) {\n options.endsWithNewline = content.codePointAt(content.length - 1) === 10;\n }\n\n try {\n return StormJSON.parseJson<T>(content, options);\n } catch (error) {\n if (isError(error)) {\n error.message = error.message.replace(\"JSON\", path);\n throw error;\n }\n\n throw new Error(`Failed to parse JSON: ${path}`);\n }\n}\n\nexport interface JsonWriteOptions extends JsonSerializeOptions {\n /**\n * whether to append new line at the end of JSON file\n *\n * @defaultValue false\n */\n appendNewLine?: boolean;\n}\n\n/**\n * Serializes the given data to JSON and writes it to a file.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized to JSON and written to the file\n * @param options - JSON serialize options\n */\nexport function writeJsonFileSync<T extends object = object>(\n path: string,\n data: T,\n options?: JsonWriteOptions\n): void {\n const serializedJson = StormJSON.stringify(data, options);\n\n return writeFileSync(\n path,\n options?.appendNewLine ? `${serializedJson}\\n` : serializedJson\n );\n}\n\n/**\n * Serializes the given data to JSON and writes it to a file asynchronously.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized to JSON and written to the file\n * @param options - JSON serialize options\n */\nexport async function writeJsonFile<T extends object = object>(\n path: string,\n data: T,\n options?: JsonWriteOptions\n): Promise<void> {\n const serializedJson = StormJSON.stringify(data);\n\n return writeFile(\n path,\n options?.appendNewLine ? `${serializedJson}\\n` : serializedJson\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA2CA,SAAgB,iBACd,MACA,SACG;CACH,MAAM,UAAU,aAAa,KAAK;AAClC,KAAI,QACF,SAAQ,kBAAkB,QAAQ,YAAY,QAAQ,SAAS,EAAE,KAAK;AAGxE,KAAI;AACF,SAAO,UAAU,UAAa,SAAS,QAAQ;UACxC,OAAO;AACd,MAAI,QAAQ,MAAM,EAAE;AAClB,SAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,KAAK;AACnD,SAAM;;AAGR,QAAM,IAAI,MAAM,yBAAyB,OAAO;;;;;;;;;;AAWpD,eAAsB,aACpB,MACA,SACY;CACZ,MAAM,UAAU,MAAM,SAAS,KAAK;AACpC,KAAI,QACF,SAAQ,kBAAkB,QAAQ,YAAY,QAAQ,SAAS,EAAE,KAAK;AAGxE,KAAI;AACF,SAAO,UAAU,UAAa,SAAS,QAAQ;UACxC,OAAO;AACd,MAAI,QAAQ,MAAM,EAAE;AAClB,SAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,KAAK;AACnD,SAAM;;AAGR,QAAM,IAAI,MAAM,yBAAyB,OAAO;;;;;;;;;;AAoBpD,SAAgB,kBACd,MACA,MACA,SACM;CACN,MAAM,iBAAiB,UAAU,UAAU,MAAM,QAAQ;AAEzD,QAAO,cACL,MACA,SAAS,gBAAgB,GAAG,eAAe,MAAM,eAClD;;;;;;;;;AAUH,eAAsB,cACpB,MACA,MACA,SACe;CACf,MAAM,iBAAiB,UAAU,UAAU,KAAK;AAEhD,QAAO,UACL,MACA,SAAS,gBAAgB,GAAG,eAAe,MAAM,eAClD"}
1
+ {"version":3,"file":"json.mjs","names":[],"sources":["../src/json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport type {\n JsonParseOptions,\n JsonSerializeOptions\n} from \"@stryke/json/types\";\nimport { findFileExtension } from \"@stryke/path\";\nimport { isSetString } from \"@stryke/type-checks\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { readFile, readFileSync } from \"./read-file\";\nimport { writeFile, writeFileSync } from \"./write-file\";\n\n/**\n * Reads a JSON file and returns the object the JSON content represents.\n *\n * @param path - A path to a file.\n * @param options - JSON parse options\n * @returns Object the JSON content of the file represents\n */\nexport function readJsonFileSync<T extends object = any>(\n path: string,\n options?: JsonParseOptions\n): T {\n const content = readFileSync(path);\n\n try {\n return StormJSON.parse<T>(isSetString(content) ? content.trim() : \"{}\", {\n expectComments: findFileExtension(path) === \"jsonc\",\n ...options\n });\n } catch (error) {\n if (isError(error)) {\n error.message = error.message.replace(\"JSON\", path);\n throw error;\n }\n\n throw new Error(`Failed to parse JSON: ${path}`);\n }\n}\n\n/**\n * Reads a JSON file and returns the object the JSON content represents.\n *\n * @param path - A path to a file.\n * @param options - JSON parse options\n * @returns Object the JSON content of the file represents\n */\nexport async function readJsonFile<T extends object = any>(\n path: string,\n options: JsonParseOptions = {}\n): Promise<T> {\n const content = await readFile(path);\n\n try {\n return StormJSON.parse<T>(isSetString(content) ? content.trim() : \"{}\", {\n expectComments: findFileExtension(path) === \"jsonc\",\n ...options\n });\n } catch (error) {\n if (isError(error)) {\n error.message = error.message.replace(\"JSON\", path);\n throw error;\n }\n\n throw new Error(`Failed to parse JSON: ${path}`);\n }\n}\n\nexport interface JsonWriteOptions extends JsonSerializeOptions {\n /**\n * whether to append new line at the end of JSON file\n *\n * @defaultValue false\n */\n appendNewLine?: boolean;\n}\n\n/**\n * Serializes the given data to JSON and writes it to a file.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized to JSON and written to the file\n * @param options - JSON serialize options\n */\nexport function writeJsonFileSync<T extends object = object>(\n path: string,\n data: T,\n options: JsonWriteOptions = {}\n): void {\n const serializedJson = StormJSON.stringify(data, { spaces: 2, ...options });\n\n return writeFileSync(\n path,\n options?.appendNewLine ? `${serializedJson}\\n` : serializedJson\n );\n}\n\n/**\n * Serializes the given data to JSON and writes it to a file asynchronously.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized to JSON and written to the file\n * @param options - JSON serialize options\n */\nexport async function writeJsonFile<T extends object = object>(\n path: string,\n data: T,\n options: JsonWriteOptions = {}\n): Promise<void> {\n const serializedJson = StormJSON.stringify(data, { spaces: 2, ...options });\n\n return writeFile(\n path,\n options?.appendNewLine ? `${serializedJson}\\n` : serializedJson\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAgB,iBACd,MACA,SACG;CACH,MAAM,UAAU,aAAa,KAAK;AAElC,KAAI;AACF,SAAO,UAAU,MAAS,YAAY,QAAQ,GAAG,QAAQ,MAAM,GAAG,MAAM;GACtE,gBAAgB,kBAAkB,KAAK,KAAK;GAC5C,GAAG;GACJ,CAAC;UACK,OAAO;AACd,MAAI,QAAQ,MAAM,EAAE;AAClB,SAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,KAAK;AACnD,SAAM;;AAGR,QAAM,IAAI,MAAM,yBAAyB,OAAO;;;;;;;;;;AAWpD,eAAsB,aACpB,MACA,UAA4B,EAAE,EAClB;CACZ,MAAM,UAAU,MAAM,SAAS,KAAK;AAEpC,KAAI;AACF,SAAO,UAAU,MAAS,YAAY,QAAQ,GAAG,QAAQ,MAAM,GAAG,MAAM;GACtE,gBAAgB,kBAAkB,KAAK,KAAK;GAC5C,GAAG;GACJ,CAAC;UACK,OAAO;AACd,MAAI,QAAQ,MAAM,EAAE;AAClB,SAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,KAAK;AACnD,SAAM;;AAGR,QAAM,IAAI,MAAM,yBAAyB,OAAO;;;;;;;;;;AAoBpD,SAAgB,kBACd,MACA,MACA,UAA4B,EAAE,EACxB;CACN,MAAM,iBAAiB,UAAU,UAAU,MAAM;EAAE,QAAQ;EAAG,GAAG;EAAS,CAAC;AAE3E,QAAO,cACL,MACA,SAAS,gBAAgB,GAAG,eAAe,MAAM,eAClD;;;;;;;;;AAUH,eAAsB,cACpB,MACA,MACA,UAA4B,EAAE,EACf;CACf,MAAM,iBAAiB,UAAU,UAAU,MAAM;EAAE,QAAQ;EAAG,GAAG;EAAS,CAAC;AAE3E,QAAO,UACL,MACA,SAAS,gBAAgB,GAAG,eAAe,MAAM,eAClD"}
package/dist/toml.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_read_file = require('./read-file.cjs');
3
3
  const require_write_file = require('./write-file.cjs');
4
- let defu = require("defu");
5
- defu = require_rolldown_runtime.__toESM(defu);
6
- let __ltd_j_toml = require("@ltd/j-toml");
4
+ let smol_toml = require("smol-toml");
5
+ smol_toml = require_rolldown_runtime.__toESM(smol_toml);
7
6
 
8
7
  //#region src/toml.ts
9
8
  /**
@@ -15,7 +14,7 @@ let __ltd_j_toml = require("@ltd/j-toml");
15
14
  */
16
15
  function readTomlFileSync(path, options) {
17
16
  const content = require_read_file.readFileSync(path);
18
- return options?.specificationVersion ? (0, __ltd_j_toml.parse)(content, options.specificationVersion, options?.multilineStringJoiner, options?.useBigInt, options?.xOptions) : (0, __ltd_j_toml.parse)(content);
17
+ return smol_toml.default.parse(content, options);
19
18
  }
20
19
  /**
21
20
  * Reads a TOML file and returns the object the TOML content represents.
@@ -26,7 +25,7 @@ function readTomlFileSync(path, options) {
26
25
  */
27
26
  async function readTomlFile(path, options) {
28
27
  const content = await require_read_file.readFile(path);
29
- return options?.specificationVersion ? (0, __ltd_j_toml.parse)(content, options.specificationVersion, options?.multilineStringJoiner, options?.useBigInt, options?.xOptions) : (0, __ltd_j_toml.parse)(content);
28
+ return smol_toml.default.parse(content, options);
30
29
  }
31
30
  /**
32
31
  * Reads a TOML file and returns the object the TOML content represents.
@@ -36,12 +35,7 @@ async function readTomlFile(path, options) {
36
35
  * @param options - TOML parse options
37
36
  */
38
37
  function writeTomlFileSync(path, data, options) {
39
- return require_write_file.writeFileSync(path, (0, __ltd_j_toml.stringify)(data, (0, defu.default)(options ?? {}, {
40
- newline: "\n",
41
- newlineAround: "pairs",
42
- indent: 4,
43
- forceInlineArraySpacing: 1
44
- })));
38
+ return require_write_file.writeFileSync(path, smol_toml.default.stringify(data, options));
45
39
  }
46
40
  /**
47
41
  * Reads a TOML file and returns the object the TOML content represents.
@@ -51,12 +45,7 @@ function writeTomlFileSync(path, data, options) {
51
45
  * @param options - TOML parse options
52
46
  */
53
47
  async function writeTomlFile(path, data, options) {
54
- return require_write_file.writeFile(path, (0, __ltd_j_toml.stringify)(data, (0, defu.default)(options ?? {}, {
55
- newline: "\n",
56
- newlineAround: "pairs",
57
- indent: 4,
58
- forceInlineArraySpacing: 1
59
- })));
48
+ return require_write_file.writeFile(path, smol_toml.default.stringify(data, options));
60
49
  }
61
50
 
62
51
  //#endregion
package/dist/toml.d.cts CHANGED
@@ -1,38 +1,8 @@
1
+ import * as smol_toml0 from "smol-toml";
2
+ import TOML from "smol-toml";
3
+
1
4
  //#region src/toml.d.ts
2
- type XOptions = null | {
3
- readonly keys?: null | RegExp;
4
- readonly order?: boolean;
5
- readonly exact?: boolean;
6
- readonly multi?: boolean;
7
- readonly longer?: boolean;
8
- readonly string?: boolean;
9
- readonly comment?: boolean;
10
- readonly literal?: boolean;
11
- readonly null?: boolean;
12
- readonly tag?: null | (<Table extends object & {
13
- [key: string | symbol]: any;
14
- }, Key extends string | symbol, Array extends any[], Index extends number, Tag extends string>(this: void, each: {
15
- table: Table;
16
- key: Key;
17
- tag: Tag;
18
- } | {
19
- array: Array;
20
- index: Index;
21
- tag: Tag;
22
- } | {
23
- table: Table;
24
- key: Key;
25
- array: Array;
26
- index: Index;
27
- tag: Tag;
28
- }) => void);
29
- };
30
- interface TomlReadOptions {
31
- specificationVersion?: 1.0 | 0.5 | 0.4 | 0.3 | 0.2 | 0.1;
32
- multilineStringJoiner?: string;
33
- useBigInt?: boolean | number;
34
- xOptions?: XOptions;
35
- }
5
+
36
6
  /**
37
7
  * Reads a TOML file and returns the object the TOML content represents.
38
8
  *
@@ -40,7 +10,7 @@ interface TomlReadOptions {
40
10
  * @param options - TOML parse options
41
11
  * @returns Object the TOML content of the file represents
42
12
  */
43
- declare function readTomlFileSync<T extends object = any>(path: string, options?: TomlReadOptions): T;
13
+ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): smol_toml0.TomlTableWithoutBigInt;
44
14
  /**
45
15
  * Reads a TOML file and returns the object the TOML content represents.
46
16
  *
@@ -48,18 +18,7 @@ declare function readTomlFileSync<T extends object = any>(path: string, options?
48
18
  * @param options - TOML parse options
49
19
  * @returns Object the TOML content of the file represents
50
20
  */
51
- declare function readTomlFile<T extends object = any>(path: string, options?: TomlReadOptions): Promise<T>;
52
- interface TomlWriteOptions {
53
- integer?: number;
54
- newline?: "\n" | "\r\n";
55
- newlineAround?: "document" | "section" | "header" | "pairs" | "pair";
56
- indent?: string | number;
57
- T?: "T" | "t" | " ";
58
- Z?: "Z" | "z";
59
- xNull?: boolean;
60
- xBeforeNewlineInMultilineTable?: "," | "";
61
- forceInlineArraySpacing?: 0 | 1 | 2 | 3;
62
- }
21
+ declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<smol_toml0.TomlTableWithoutBigInt>;
63
22
  /**
64
23
  * Reads a TOML file and returns the object the TOML content represents.
65
24
  *
@@ -67,7 +26,7 @@ interface TomlWriteOptions {
67
26
  * @param data - data which should be serialized/formatted to TOML and written to the file
68
27
  * @param options - TOML parse options
69
28
  */
70
- declare function writeTomlFileSync<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): void;
29
+ declare function writeTomlFileSync(path: string, data: object, options?: Parameters<typeof TOML.stringify>[1]): void;
71
30
  /**
72
31
  * Reads a TOML file and returns the object the TOML content represents.
73
32
  *
@@ -75,7 +34,7 @@ declare function writeTomlFileSync<T extends object = any>(path: string, data: T
75
34
  * @param data - data which should be serialized/formatted to TOML and written to the file
76
35
  * @param options - TOML parse options
77
36
  */
78
- declare function writeTomlFile<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): Promise<void>;
37
+ declare function writeTomlFile(path: string, data: object, options?: Parameters<typeof TOML.stringify>[1]): Promise<void>;
79
38
  //#endregion
80
- export { TomlReadOptions, TomlWriteOptions, XOptions, readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync };
39
+ export { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync };
81
40
  //# sourceMappingURL=toml.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toml.d.cts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";KAuBY,QAAA;EAAA,SAAA,IAAQ,CAAA,EAAA,IAAA,GACK,MADL;EACK,SAAA,KAAA,CAAA,EAAA,OAAA;EAoBJ,SAAA,KAAA,CAAA,EAAA,OAAA;EAAY,SAAA,KAAA,CAAA,EAAA,OAAA;EAAU,SAAA,MAAA,CAAA,EAAA,OAAA;EACtB,SAAA,MAAA,CAAA,EAAA,OAAA;EAAc,SAAA,OAAA,CAAA,EAAA,OAAA;EAAY,SAAA,OAAA,CAAA,EAAA,OAAA;EAC1B,SAAA,IAAA,CAAA,EAAA,OAAA;EAAY,SAAA,GAAA,CAAA,EAAA,IAAA,GAAA,CAAA,CAAA,cAAA,MAAA,GAAA;IAAY,CAAA,GAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EAAA,GAAA;EAAc,CAAA,EAAA,YAAA,MAAA,GAAA,MAAA,EAAA,cAAA,GAAA,EAAA,EAAA,cAAA,MAAA,EAAA,YAAA,MAAA,CAAA,CAAA,IAAA,EAAA,IAAA,EAAA,IAAA,EAAA;IAAY,KAAA,EAFlD,KAEkD;IAAG,GAAA,EAFzC,GAEyC;IAIzD,GAAA,EAN0B,GAM1B;EAcD,CAAA,GAAA;IA0BM,KAAA,EA7CD,KA6Ca;IAEtB,KAAA,EA/CuB,KA+CvB;IACD,GAAA,EAhDoC,GAgDpC;EAAR,CAAA,GAAA;IAAO,KAAA,EA/CW,KA+CX;IAgBO,GAAA,EA/DgB,GA+DhB;IAmBD,KAAA,EAlF6B,KAkF7B;IA0BM,KAAA,EA5GqC,KA4GxB;IAE3B,GAAA,EA9G+D,GA8G/D;EACI,CAAA,EAAA,GAAA,IAAA,CAAA;CACT;AAAO,UA5GO,eAAA,CA4GP;;;;aAxGG;;;;;;;;;iBAUG,iEAEJ,kBACT;;;;;;;;iBAuBmB,6DAEV,kBACT,QAAQ;UAgBM,gBAAA;;;;;;;;;;;;;;;;;;iBAmBD,8DAER,aACI;;;;;;;;iBAuBU,0DAEd,aACI,mBACT"}
1
+ {"version":3,"file":"toml.d.cts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA6BA;;;;AAE4C,iBAF5B,gBAAA,CAE4B,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAhC,UAAgC,CAAA,OAAd,IAAA,CAAK,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAtB,UAAA,CAAsB,sBAAA;AAc5C;;;;;;AAgBA;AAesB,iBA/BA,YAAA,CA+Ba,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BvB,UA6BuB,CAAA,OA7BL,IAAA,CAAK,KA6BA,CAAA,CAAA,CAAA,CAAA,CAAA,EA7BS,OA6BT,CA7Bb,UAAA,CAAsB,sBAAA,CA6BT;;;;;;;;iBAfnB,iBAAA,uCAGJ,kBAAkB,IAAA,CAAK;;;;;;;;iBAYb,aAAA,uCAGV,kBAAkB,IAAA,CAAK,gBAChC"}
package/dist/toml.d.mts CHANGED
@@ -1,38 +1,8 @@
1
+ import * as smol_toml0 from "smol-toml";
2
+ import TOML from "smol-toml";
3
+
1
4
  //#region src/toml.d.ts
2
- type XOptions = null | {
3
- readonly keys?: null | RegExp;
4
- readonly order?: boolean;
5
- readonly exact?: boolean;
6
- readonly multi?: boolean;
7
- readonly longer?: boolean;
8
- readonly string?: boolean;
9
- readonly comment?: boolean;
10
- readonly literal?: boolean;
11
- readonly null?: boolean;
12
- readonly tag?: null | (<Table extends object & {
13
- [key: string | symbol]: any;
14
- }, Key extends string | symbol, Array extends any[], Index extends number, Tag extends string>(this: void, each: {
15
- table: Table;
16
- key: Key;
17
- tag: Tag;
18
- } | {
19
- array: Array;
20
- index: Index;
21
- tag: Tag;
22
- } | {
23
- table: Table;
24
- key: Key;
25
- array: Array;
26
- index: Index;
27
- tag: Tag;
28
- }) => void);
29
- };
30
- interface TomlReadOptions {
31
- specificationVersion?: 1.0 | 0.5 | 0.4 | 0.3 | 0.2 | 0.1;
32
- multilineStringJoiner?: string;
33
- useBigInt?: boolean | number;
34
- xOptions?: XOptions;
35
- }
5
+
36
6
  /**
37
7
  * Reads a TOML file and returns the object the TOML content represents.
38
8
  *
@@ -40,7 +10,7 @@ interface TomlReadOptions {
40
10
  * @param options - TOML parse options
41
11
  * @returns Object the TOML content of the file represents
42
12
  */
43
- declare function readTomlFileSync<T extends object = any>(path: string, options?: TomlReadOptions): T;
13
+ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): smol_toml0.TomlTableWithoutBigInt;
44
14
  /**
45
15
  * Reads a TOML file and returns the object the TOML content represents.
46
16
  *
@@ -48,18 +18,7 @@ declare function readTomlFileSync<T extends object = any>(path: string, options?
48
18
  * @param options - TOML parse options
49
19
  * @returns Object the TOML content of the file represents
50
20
  */
51
- declare function readTomlFile<T extends object = any>(path: string, options?: TomlReadOptions): Promise<T>;
52
- interface TomlWriteOptions {
53
- integer?: number;
54
- newline?: "\n" | "\r\n";
55
- newlineAround?: "document" | "section" | "header" | "pairs" | "pair";
56
- indent?: string | number;
57
- T?: "T" | "t" | " ";
58
- Z?: "Z" | "z";
59
- xNull?: boolean;
60
- xBeforeNewlineInMultilineTable?: "," | "";
61
- forceInlineArraySpacing?: 0 | 1 | 2 | 3;
62
- }
21
+ declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<smol_toml0.TomlTableWithoutBigInt>;
63
22
  /**
64
23
  * Reads a TOML file and returns the object the TOML content represents.
65
24
  *
@@ -67,7 +26,7 @@ interface TomlWriteOptions {
67
26
  * @param data - data which should be serialized/formatted to TOML and written to the file
68
27
  * @param options - TOML parse options
69
28
  */
70
- declare function writeTomlFileSync<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): void;
29
+ declare function writeTomlFileSync(path: string, data: object, options?: Parameters<typeof TOML.stringify>[1]): void;
71
30
  /**
72
31
  * Reads a TOML file and returns the object the TOML content represents.
73
32
  *
@@ -75,7 +34,7 @@ declare function writeTomlFileSync<T extends object = any>(path: string, data: T
75
34
  * @param data - data which should be serialized/formatted to TOML and written to the file
76
35
  * @param options - TOML parse options
77
36
  */
78
- declare function writeTomlFile<T extends object = any>(path: string, data: T, options?: TomlWriteOptions): Promise<void>;
37
+ declare function writeTomlFile(path: string, data: object, options?: Parameters<typeof TOML.stringify>[1]): Promise<void>;
79
38
  //#endregion
80
- export { TomlReadOptions, TomlWriteOptions, XOptions, readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync };
39
+ export { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync };
81
40
  //# sourceMappingURL=toml.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toml.d.mts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";KAuBY,QAAA;EAAA,SAAA,IAAQ,CAAA,EAAA,IAAA,GACK,MADL;EACK,SAAA,KAAA,CAAA,EAAA,OAAA;EAoBJ,SAAA,KAAA,CAAA,EAAA,OAAA;EAAY,SAAA,KAAA,CAAA,EAAA,OAAA;EAAU,SAAA,MAAA,CAAA,EAAA,OAAA;EACtB,SAAA,MAAA,CAAA,EAAA,OAAA;EAAc,SAAA,OAAA,CAAA,EAAA,OAAA;EAAY,SAAA,OAAA,CAAA,EAAA,OAAA;EAC1B,SAAA,IAAA,CAAA,EAAA,OAAA;EAAY,SAAA,GAAA,CAAA,EAAA,IAAA,GAAA,CAAA,CAAA,cAAA,MAAA,GAAA;IAAY,CAAA,GAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EAAA,GAAA;EAAc,CAAA,EAAA,YAAA,MAAA,GAAA,MAAA,EAAA,cAAA,GAAA,EAAA,EAAA,cAAA,MAAA,EAAA,YAAA,MAAA,CAAA,CAAA,IAAA,EAAA,IAAA,EAAA,IAAA,EAAA;IAAY,KAAA,EAFlD,KAEkD;IAAG,GAAA,EAFzC,GAEyC;IAIzD,GAAA,EAN0B,GAM1B;EAcD,CAAA,GAAA;IA0BM,KAAA,EA7CD,KA6Ca;IAEtB,KAAA,EA/CuB,KA+CvB;IACD,GAAA,EAhDoC,GAgDpC;EAAR,CAAA,GAAA;IAAO,KAAA,EA/CW,KA+CX;IAgBO,GAAA,EA/DgB,GA+DhB;IAmBD,KAAA,EAlF6B,KAkF7B;IA0BM,KAAA,EA5GqC,KA4GxB;IAE3B,GAAA,EA9G+D,GA8G/D;EACI,CAAA,EAAA,GAAA,IAAA,CAAA;CACT;AAAO,UA5GO,eAAA,CA4GP;;;;aAxGG;;;;;;;;;iBAUG,iEAEJ,kBACT;;;;;;;;iBAuBmB,6DAEV,kBACT,QAAQ;UAgBM,gBAAA;;;;;;;;;;;;;;;;;;iBAmBD,8DAER,aACI;;;;;;;;iBAuBU,0DAEd,aACI,mBACT"}
1
+ {"version":3,"file":"toml.d.mts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA6BA;;;;AAE4C,iBAF5B,gBAAA,CAE4B,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAhC,UAAgC,CAAA,OAAd,IAAA,CAAK,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAtB,UAAA,CAAsB,sBAAA;AAc5C;;;;;;AAgBA;AAesB,iBA/BA,YAAA,CA+Ba,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BvB,UA6BuB,CAAA,OA7BL,IAAA,CAAK,KA6BA,CAAA,CAAA,CAAA,CAAA,CAAA,EA7BS,OA6BT,CA7Bb,UAAA,CAAsB,sBAAA,CA6BT;;;;;;;;iBAfnB,iBAAA,uCAGJ,kBAAkB,IAAA,CAAK;;;;;;;;iBAYb,aAAA,uCAGV,kBAAkB,IAAA,CAAK,gBAChC"}
package/dist/toml.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { readFile, readFileSync } from "./read-file.mjs";
2
2
  import { writeFile, writeFileSync } from "./write-file.mjs";
3
- import defu from "defu";
4
- import { parse, stringify } from "@ltd/j-toml";
3
+ import TOML from "smol-toml";
5
4
 
6
5
  //#region src/toml.ts
7
6
  /**
@@ -13,7 +12,7 @@ import { parse, stringify } from "@ltd/j-toml";
13
12
  */
14
13
  function readTomlFileSync(path, options) {
15
14
  const content = readFileSync(path);
16
- return options?.specificationVersion ? parse(content, options.specificationVersion, options?.multilineStringJoiner, options?.useBigInt, options?.xOptions) : parse(content);
15
+ return TOML.parse(content, options);
17
16
  }
18
17
  /**
19
18
  * Reads a TOML file and returns the object the TOML content represents.
@@ -24,7 +23,7 @@ function readTomlFileSync(path, options) {
24
23
  */
25
24
  async function readTomlFile(path, options) {
26
25
  const content = await readFile(path);
27
- return options?.specificationVersion ? parse(content, options.specificationVersion, options?.multilineStringJoiner, options?.useBigInt, options?.xOptions) : parse(content);
26
+ return TOML.parse(content, options);
28
27
  }
29
28
  /**
30
29
  * Reads a TOML file and returns the object the TOML content represents.
@@ -34,12 +33,7 @@ async function readTomlFile(path, options) {
34
33
  * @param options - TOML parse options
35
34
  */
36
35
  function writeTomlFileSync(path, data, options) {
37
- return writeFileSync(path, stringify(data, defu(options ?? {}, {
38
- newline: "\n",
39
- newlineAround: "pairs",
40
- indent: 4,
41
- forceInlineArraySpacing: 1
42
- })));
36
+ return writeFileSync(path, TOML.stringify(data, options));
43
37
  }
44
38
  /**
45
39
  * Reads a TOML file and returns the object the TOML content represents.
@@ -49,12 +43,7 @@ function writeTomlFileSync(path, data, options) {
49
43
  * @param options - TOML parse options
50
44
  */
51
45
  async function writeTomlFile(path, data, options) {
52
- return writeFile(path, stringify(data, defu(options ?? {}, {
53
- newline: "\n",
54
- newlineAround: "pairs",
55
- indent: 4,
56
- forceInlineArraySpacing: 1
57
- })));
46
+ return writeFile(path, TOML.stringify(data, options));
58
47
  }
59
48
 
60
49
  //#endregion
package/dist/toml.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"toml.mjs","names":["parseToml","stringifyToml"],"sources":["../src/toml.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parse as parseToml, stringify as stringifyToml } from \"@ltd/j-toml\";\nimport defu from \"defu\";\nimport { readFile, readFileSync } from \"./read-file\";\nimport { writeFile, writeFileSync } from \"./write-file\";\n\nexport type XOptions = null | {\n readonly keys?: null | RegExp;\n readonly order?: boolean;\n readonly exact?: boolean;\n readonly multi?: boolean;\n readonly longer?: boolean;\n readonly string?: boolean;\n readonly comment?: boolean;\n readonly literal?: boolean;\n readonly null?: boolean;\n readonly tag?:\n | null\n | (<\n Table extends object & { [key: string | symbol]: any },\n Key extends string | symbol,\n Array extends any[],\n Index extends number,\n Tag extends string\n >(\n this: void,\n each:\n | { table: Table; key: Key; tag: Tag }\n | { array: Array; index: Index; tag: Tag }\n | { table: Table; key: Key; array: Array; index: Index; tag: Tag }\n ) => void);\n};\n\nexport interface TomlReadOptions {\n specificationVersion?: 1.0 | 0.5 | 0.4 | 0.3 | 0.2 | 0.1;\n multilineStringJoiner?: string;\n useBigInt?: boolean | number;\n xOptions?: XOptions;\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param options - TOML parse options\n * @returns Object the TOML content of the file represents\n */\nexport function readTomlFileSync<T extends object = any>(\n path: string,\n options?: TomlReadOptions\n): T {\n const content = readFileSync(path);\n\n return (\n options?.specificationVersion\n ? parseToml(\n content,\n options.specificationVersion,\n options?.multilineStringJoiner,\n options?.useBigInt,\n options?.xOptions\n )\n : parseToml(content)\n ) as T;\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param options - TOML parse options\n * @returns Object the TOML content of the file represents\n */\nexport async function readTomlFile<T extends object = any>(\n path: string,\n options?: TomlReadOptions\n): Promise<T> {\n const content = await readFile(path);\n\n return (\n options?.specificationVersion\n ? parseToml(\n content,\n options.specificationVersion,\n options?.multilineStringJoiner,\n options?.useBigInt,\n options?.xOptions\n )\n : parseToml(content)\n ) as T;\n}\n\nexport interface TomlWriteOptions {\n integer?: number;\n newline?: \"\\n\" | \"\\r\\n\";\n newlineAround?: \"document\" | \"section\" | \"header\" | \"pairs\" | \"pair\";\n indent?: string | number;\n T?: \"T\" | \"t\" | \" \";\n Z?: \"Z\" | \"z\";\n xNull?: boolean;\n xBeforeNewlineInMultilineTable?: \",\" | \"\";\n forceInlineArraySpacing?: 0 | 1 | 2 | 3;\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized/formatted to TOML and written to the file\n * @param options - TOML parse options\n */\nexport function writeTomlFileSync<T extends object = any>(\n path: string,\n data: T,\n options?: TomlWriteOptions\n): void {\n return writeFileSync(\n path,\n stringifyToml(\n data as any,\n defu(options ?? {}, {\n newline: \"\\n\",\n newlineAround: \"pairs\",\n indent: 4,\n forceInlineArraySpacing: 1\n }) as TomlWriteOptions\n )\n );\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized/formatted to TOML and written to the file\n * @param options - TOML parse options\n */\nexport async function writeTomlFile<T extends object = any>(\n path: string,\n data: T,\n options?: TomlWriteOptions\n): Promise<void> {\n return writeFile(\n path,\n stringifyToml(\n data as any,\n defu(options ?? {}, {\n newline: \"\\n\",\n newlineAround: \"pairs\",\n indent: 4,\n forceInlineArraySpacing: 1\n }) as TomlWriteOptions\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgEA,SAAgB,iBACd,MACA,SACG;CACH,MAAM,UAAU,aAAa,KAAK;AAElC,QACE,SAAS,uBACLA,MACE,SACA,QAAQ,sBACR,SAAS,uBACT,SAAS,WACT,SAAS,SACV,GACDA,MAAU,QAAQ;;;;;;;;;AAW1B,eAAsB,aACpB,MACA,SACY;CACZ,MAAM,UAAU,MAAM,SAAS,KAAK;AAEpC,QACE,SAAS,uBACLA,MACE,SACA,QAAQ,sBACR,SAAS,uBACT,SAAS,WACT,SAAS,SACV,GACDA,MAAU,QAAQ;;;;;;;;;AAuB1B,SAAgB,kBACd,MACA,MACA,SACM;AACN,QAAO,cACL,MACAC,UACE,MACA,KAAK,WAAW,EAAE,EAAE;EAClB,SAAS;EACT,eAAe;EACf,QAAQ;EACR,yBAAyB;EAC1B,CAAC,CACH,CACF;;;;;;;;;AAUH,eAAsB,cACpB,MACA,MACA,SACe;AACf,QAAO,UACL,MACAA,UACE,MACA,KAAK,WAAW,EAAE,EAAE;EAClB,SAAS;EACT,eAAe;EACf,QAAQ;EACR,yBAAyB;EAC1B,CAAC,CACH,CACF"}
1
+ {"version":3,"file":"toml.mjs","names":[],"sources":["../src/toml.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport TOML from \"smol-toml\";\nimport { readFile, readFileSync } from \"./read-file\";\nimport { writeFile, writeFileSync } from \"./write-file\";\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param options - TOML parse options\n * @returns Object the TOML content of the file represents\n */\nexport function readTomlFileSync(\n path: string,\n options?: Parameters<typeof TOML.parse>[1]\n) {\n const content = readFileSync(path);\n\n return TOML.parse(content, options);\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param options - TOML parse options\n * @returns Object the TOML content of the file represents\n */\nexport async function readTomlFile(\n path: string,\n options?: Parameters<typeof TOML.parse>[1]\n) {\n const content = await readFile(path);\n\n return TOML.parse(content, options);\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized/formatted to TOML and written to the file\n * @param options - TOML parse options\n */\nexport function writeTomlFileSync(\n path: string,\n data: object,\n options?: Parameters<typeof TOML.stringify>[1]\n): void {\n return writeFileSync(path, TOML.stringify(data, options));\n}\n\n/**\n * Reads a TOML file and returns the object the TOML content represents.\n *\n * @param path - A path to a file.\n * @param data - data which should be serialized/formatted to TOML and written to the file\n * @param options - TOML parse options\n */\nexport async function writeTomlFile(\n path: string,\n data: object,\n options?: Parameters<typeof TOML.stringify>[1]\n): Promise<void> {\n return writeFile(path, TOML.stringify(data, options));\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,iBACd,MACA,SACA;CACA,MAAM,UAAU,aAAa,KAAK;AAElC,QAAO,KAAK,MAAM,SAAS,QAAQ;;;;;;;;;AAUrC,eAAsB,aACpB,MACA,SACA;CACA,MAAM,UAAU,MAAM,SAAS,KAAK;AAEpC,QAAO,KAAK,MAAM,SAAS,QAAQ;;;;;;;;;AAUrC,SAAgB,kBACd,MACA,MACA,SACM;AACN,QAAO,cAAc,MAAM,KAAK,UAAU,MAAM,QAAQ,CAAC;;;;;;;;;AAU3D,eAAsB,cACpB,MACA,MACA,SACe;AACf,QAAO,UAAU,MAAM,KAAK,UAAU,MAAM,QAAQ,CAAC"}
@@ -1,10 +1,12 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ let node_buffer = require("node:buffer");
1
3
 
2
4
  //#region ../type-checks/src/is-buffer.ts
3
- const isBufferExists = typeof Buffer !== "undefined";
5
+ const isBufferExists = typeof node_buffer.Buffer !== "undefined";
4
6
  /**
5
7
  * Check if the provided value's type is `Buffer`
6
8
  */
7
- const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
9
+ const isBuffer = isBufferExists ? node_buffer.Buffer.isBuffer.bind(node_buffer.Buffer) : function isBuffer$1(value) {
8
10
  return false;
9
11
  };
10
12
 
@@ -1,3 +1,5 @@
1
+ import { Buffer } from "node:buffer";
2
+
1
3
  //#region ../type-checks/src/is-buffer.ts
2
4
  const isBufferExists = typeof Buffer !== "undefined";
3
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":";AAkBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO"}
1
+ {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Buffer } from \"node:buffer\";\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":";;;AAoBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO"}
@@ -23,8 +23,8 @@ const require_get_object_tag = require('./get-object-tag.cjs');
23
23
  * @param value - The value to check.
24
24
  * @returns Returns `true` if `value` is object-like, else `false`.
25
25
  */
26
- const isObjectLike = (obj) => {
27
- return typeof obj === "object" && obj !== null;
26
+ const isObjectLike = (value) => {
27
+ return typeof value === "object" && value !== null;
28
28
  };
29
29
  /**
30
30
  * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
@@ -23,8 +23,8 @@ import { getObjectTag } from "./get-object-tag.mjs";
23
23
  * @param value - The value to check.
24
24
  * @returns Returns `true` if `value` is object-like, else `false`.
25
25
  */
26
- const isObjectLike = (obj) => {
27
- return typeof obj === "object" && obj !== null;
26
+ const isObjectLike = (value) => {
27
+ return typeof value === "object" && value !== null;
28
28
  };
29
29
  /**
30
30
  * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
@@ -1 +1 @@
1
- {"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,gBAAgB,QAAiB;AAC5C,QAAO,OAAO,QAAQ,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B5C,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK"}
1
+ {"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (value: unknown) => {\n return typeof value === \"object\" && value !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,gBAAgB,UAAmB;AAC9C,QAAO,OAAO,UAAU,YAAY,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BhD,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK"}
@@ -1,9 +1,9 @@
1
1
  require('./is-buffer.cjs');
2
2
 
3
3
  //#region ../type-checks/src/type-detect.ts
4
- const globalObject = ((Obj) => {
4
+ const globalObject = ((obj) => {
5
5
  if (typeof globalThis === "object") return globalThis;
6
- Object.defineProperty(Obj, "typeDetectGlobalObject", {
6
+ Object.defineProperty(obj, "typeDetectGlobalObject", {
7
7
  get() {
8
8
  return this;
9
9
  },
@@ -1,9 +1,9 @@
1
1
  import "./is-buffer.mjs";
2
2
 
3
3
  //#region ../type-checks/src/type-detect.ts
4
- const globalObject = ((Obj) => {
4
+ const globalObject = ((obj) => {
5
5
  if (typeof globalThis === "object") return globalThis;
6
- Object.defineProperty(Obj, "typeDetectGlobalObject", {
6
+ Object.defineProperty(obj, "typeDetectGlobalObject", {
7
7
  get() {
8
8
  return this;
9
9
  },
@@ -1 +1 @@
1
- {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,QAAO;GACN,OAAO,UAAU"}
1
+ {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,QAAO;GACN,OAAO,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.33.62",
3
+ "version": "0.33.64",
4
4
  "private": false,
5
5
  "description": "A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.",
6
6
  "repository": {
@@ -105,29 +105,29 @@
105
105
  "types": "./dist/index.d.cts",
106
106
  "dependencies": {
107
107
  "@antfu/install-pkg": "^1.1.0",
108
- "@ltd/j-toml": "^1.38.0",
109
- "@storm-software/config-tools": "^1.189.32",
110
- "@stryke/convert": "^0.6.55",
111
- "@stryke/helpers": "^0.10.5",
112
- "@stryke/path": "^0.27.1",
113
- "@stryke/string-format": "^0.17.5",
108
+ "@storm-software/config-tools": "^1.189.46",
109
+ "@stryke/convert": "^0.6.57",
110
+ "@stryke/helpers": "^0.10.7",
111
+ "@stryke/path": "^0.27.3",
112
+ "@stryke/string-format": "^0.17.7",
114
113
  "chalk": "^5.6.2",
115
114
  "defu": "^6.1.4",
116
115
  "glob": "^11.1.0",
117
116
  "mlly": "1.7.4",
118
117
  "nanotar": "^0.2.1",
119
118
  "semver": "7.7.1",
120
- "yaml": "^2.8.2"
119
+ "smol-toml": "^1.6.0",
120
+ "yaml": "^2.8.3"
121
121
  },
122
122
  "devDependencies": {
123
123
  "@types/node": "^24.12.0",
124
124
  "@types/semver": "^7.7.1",
125
- "nx": "^22.5.4",
125
+ "nx": "22.6.1",
126
126
  "tinyexec": "^0.3.2",
127
127
  "tsdown": "^0.17.2"
128
128
  },
129
- "peerDependencies": { "nx": "^22.5.4" },
129
+ "peerDependencies": { "nx": "22.6.1" },
130
130
  "peerDependenciesMeta": { "nx": { "optional": true } },
131
131
  "publishConfig": { "access": "public" },
132
- "gitHead": "f8d7b1bf4c1ab0e4fa10189d82e8993dba27207a"
132
+ "gitHead": "ad0acb8f9d34c16300a0901dd4db448756480415"
133
133
  }