Comparing version 0.1.6 to 0.1.7
@@ -1,4 +0,32 @@ | ||
export { JSON5ParseOptions, JSON5StringifyOptions, parseJSON5 } from './json5.js'; | ||
export { JSONCParseError, JSONCParseOptions, parseJSONC } from './jsonc.js'; | ||
export { parseYAML, parseYAMLOptions, stringifyYAML, stringifyYAMLOptions } from './yaml.js'; | ||
export { JSON5ParseOptions, JSON5StringifyOptions, parseJSON5, stringifyJSON5 } from './json5.js'; | ||
export { JSONCParseError, JSONCParseOptions, parseJSONC, stringifyJSONC } from './jsonc.js'; | ||
export { YAMLParseOptions, YAMLStringifyOptions, parseYAML, stringifyYAML } from './yaml.js'; | ||
import { F as FormatOptions } from './shared/confbox.9745c98f.js'; | ||
export { parseTOML, stringifyTOML } from './toml.js'; | ||
/** | ||
* Converts a [JSON](https://www.json.org/json-en.html) string into an object. | ||
* | ||
* Indentation status is auto-detected and preserved when stringifying back using `stringifyJSON` | ||
*/ | ||
declare function parseJSON<T = unknown>(text: string, options?: JSONParseOptions): T; | ||
/** | ||
* Converts a JavaScript value to a [JSON](https://www.json.org/json-en.html) string. | ||
* | ||
* Indentation status is auto detected and preserved when using value from parseJSON. | ||
*/ | ||
declare function stringifyJSON(value: any, options?: JSONStringifyOptions): string; | ||
interface JSONParseOptions extends FormatOptions { | ||
/** | ||
* A function that transforms the results. This function is called for each member of the object. | ||
*/ | ||
reviver?: (this: any, key: string, value: any) => any; | ||
} | ||
interface JSONStringifyOptions extends FormatOptions { | ||
/** | ||
* A function that transforms the results. This function is called for each member of the object. | ||
*/ | ||
replacer?: (this: any, key: string, value: any) => any; | ||
} | ||
export { type JSONParseOptions, type JSONStringifyOptions, parseJSON, stringifyJSON }; |
@@ -0,1 +1,3 @@ | ||
import { F as FormatOptions } from './shared/confbox.9745c98f.js'; | ||
/** | ||
@@ -10,3 +12,11 @@ * Converts a [JSON5](https://json5.org/) string into an object. | ||
declare function parseJSON5<T = unknown>(text: string, options?: JSON5ParseOptions): T; | ||
interface JSON5ParseOptions { | ||
/** | ||
* Converts a JavaScript value to a [JSON5](https://json5.org/) string. | ||
* | ||
* @param value | ||
* @param options | ||
* @returns The JSON string converted from the JavaScript value. | ||
*/ | ||
declare function stringifyJSON5(value: any, options?: JSON5StringifyOptions): string; | ||
interface JSON5ParseOptions extends FormatOptions { | ||
/** | ||
@@ -21,3 +31,3 @@ * A function that alters the behavior of the parsing process, or an array of | ||
} | ||
interface JSON5StringifyOptions { | ||
interface JSON5StringifyOptions extends FormatOptions { | ||
/** | ||
@@ -30,3 +40,3 @@ * A function that alters the behavior of the stringification process, or an | ||
*/ | ||
replacer?: ((this: any, key: string, value: any) => any) | (string | number)[] | null; | ||
replacer?: ((this: any, key: string, value: any) => any) | null; | ||
/** | ||
@@ -51,2 +61,2 @@ * A String or Number object that's used to insert white space into the | ||
export { type JSON5ParseOptions, type JSON5StringifyOptions, parseJSON5 }; | ||
export { type JSON5ParseOptions, type JSON5StringifyOptions, parseJSON5, stringifyJSON5 }; |
@@ -0,1 +1,3 @@ | ||
import { F as FormatOptions } from './shared/confbox.9745c98f.js'; | ||
/** | ||
@@ -6,4 +8,5 @@ * | ||
* @NOTE On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. | ||
* Therefore, always check the errors list to find out if the input was valid. | ||
* | ||
* @NOTE Comments and trailing commas are not preserved after parsing. | ||
* | ||
* @template T The type of the return value. | ||
@@ -15,3 +18,13 @@ * @param text The string to parse as JSONC. | ||
declare function parseJSONC<T = unknown>(text: string, options?: JSONCParseOptions): T; | ||
interface JSONCParseOptions { | ||
/** | ||
* Converts a JavaScript value to a [JSONC](https://github.com/microsoft/node-jsonc-parser) string. | ||
* | ||
* @NOTE Comments and trailing commas are not preserved in the output. | ||
* | ||
* @param value | ||
* @param options | ||
* @returns The JSON string converted from the JavaScript value. | ||
*/ | ||
declare function stringifyJSONC(value: any, options?: JSONCStringifyOptions): string; | ||
interface JSONCParseOptions extends FormatOptions { | ||
disallowComments?: boolean; | ||
@@ -22,2 +35,4 @@ allowTrailingComma?: boolean; | ||
} | ||
interface JSONCStringifyOptions extends FormatOptions { | ||
} | ||
interface JSONCParseError { | ||
@@ -29,2 +44,2 @@ error: number; | ||
export { type JSONCParseError, type JSONCParseOptions, parseJSONC }; | ||
export { type JSONCParseError, type JSONCParseOptions, type JSONCStringifyOptions, parseJSONC, stringifyJSONC }; |
/** | ||
* Converts a [TOML](https://toml.io/) string into an object. | ||
* | ||
* @NOTE Comments and indentation is not preserved after parsing. | ||
* | ||
@@ -13,2 +14,4 @@ * @template T The type of the return value. | ||
* | ||
* @NOTE Comments and indentation is not preserved in the output. | ||
* | ||
* @param value | ||
@@ -15,0 +18,0 @@ * @param options |
@@ -0,1 +1,3 @@ | ||
import { F as FormatOptions } from './shared/confbox.9745c98f.js'; | ||
/** | ||
@@ -6,2 +8,4 @@ * Converts a [YAML](https://yaml.org/) string into an object. | ||
* | ||
* @NOTE Comments are not preserved after parsing. | ||
* | ||
* @NOTE This function does **not** support schema-specific tag resolution restrictions. | ||
@@ -17,6 +21,8 @@ * So, the JSON schema is not as strictly defined in the YAML specification. | ||
*/ | ||
declare function parseYAML<T = unknown>(text: string, options?: parseYAMLOptions): T; | ||
declare function parseYAML<T = unknown>(text: string, options?: YAMLParseOptions): T; | ||
/** | ||
* Converts a JavaScript value to a [YAML](https://yaml.org/) string. | ||
* | ||
* @NOTE Comments are not preserved in the output. | ||
* | ||
* @param value | ||
@@ -26,4 +32,4 @@ * @param options | ||
*/ | ||
declare function stringifyYAML(value: any, options?: stringifyYAMLOptions): string; | ||
interface parseYAMLOptions { | ||
declare function stringifyYAML(value: any, options?: YAMLStringifyOptions): string; | ||
interface YAMLParseOptions extends FormatOptions { | ||
/** string to be used as a file path in error/warning messages. */ | ||
@@ -40,3 +46,3 @@ filename?: string | undefined; | ||
} | ||
interface stringifyYAMLOptions { | ||
interface YAMLStringifyOptions extends FormatOptions { | ||
/** indentation width to use (in spaces). */ | ||
@@ -93,2 +99,2 @@ indent?: number | undefined; | ||
export { parseYAML, type parseYAMLOptions, stringifyYAML, type stringifyYAMLOptions }; | ||
export { type YAMLParseOptions, type YAMLStringifyOptions, parseYAML, stringifyYAML }; |
{ | ||
"name": "confbox", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Compact and high quality YAML, TOML, JSONC and JSON5 parsers", | ||
@@ -65,7 +65,8 @@ "keywords": [ | ||
"@types/node": "^20.12.7", | ||
"@vitest/coverage-v8": "^1.4.0", | ||
"@vitest/coverage-v8": "^1.5.0", | ||
"automd": "^0.3.7", | ||
"changelogen": "^0.5.5", | ||
"detect-indent": "^7.0.1", | ||
"eslint": "^9.0.0", | ||
"eslint-config-unjs": "^0.3.0-rc.6", | ||
"eslint-config-unjs": "0.3.0-rc.6", | ||
"jiti": "^1.21.0", | ||
@@ -82,6 +83,6 @@ "js-toml": "^1.0.0", | ||
"unbuild": "^2.0.0", | ||
"vitest": "^1.4.0", | ||
"vitest": "^1.5.0", | ||
"yaml": "^2.4.1" | ||
}, | ||
"packageManager": "pnpm@8.15.3" | ||
"packageManager": "pnpm@9.0.1" | ||
} |
@@ -20,2 +20,4 @@ # confbox | ||
✅ [JSON](https://www.json.org/json-en.html) | ||
With perfect bundling: | ||
@@ -33,2 +35,4 @@ | ||
✨ Auto detects indentation and whitespace when parsing and preservers when serializing | ||
> [!NOTE] | ||
@@ -71,5 +75,9 @@ > Use [unjs/c12](https://github.com/unjs/c12) for a full featured configuration loader! | ||
parseJSON5, | ||
stringifyJSON5, | ||
parseJSONC, | ||
stringifyJSONC, | ||
parseYAML, | ||
stringifyYAML, | ||
parseJSON, | ||
stringifyJSON, | ||
parseTOML, | ||
@@ -85,5 +93,9 @@ stringifyTOML, | ||
parseJSON5, | ||
stringifyJSON5, | ||
parseJSONC, | ||
stringifyJSONC, | ||
parseYAML, | ||
stringifyYAML, | ||
parseJSON, | ||
stringifyJSON, | ||
parseTOML, | ||
@@ -99,5 +111,9 @@ stringifyTOML, | ||
parseJSON5, | ||
stringifyJSON5, | ||
parseJSONC, | ||
stringifyJSONC, | ||
parseYAML, | ||
stringifyYAML, | ||
parseJSON, | ||
stringifyJSON, | ||
parseTOML, | ||
@@ -112,2 +128,8 @@ stringifyTOML, | ||
### `parseJSON(text, options?)` | ||
Converts a [JSON](https://www.json.org/json-en.html) string into an object. | ||
Indentation status is auto-detected and preserved when stringifying back using `stringifyJSON` | ||
### `parseJSON5(text, options?)` | ||
@@ -129,4 +151,18 @@ | ||
### `stringifyTOML(text)` | ||
### `stringifyJSON(value, options?)` | ||
Converts a JavaScript value to a [JSON](https://www.json.org/json-en.html) string. | ||
Indentation status is auto detected and preserved when using value from parseJSON. | ||
### `stringifyJSON5(value, options?)` | ||
Converts a JavaScript value to a [JSON5](https://json5.org/) string. | ||
### `stringifyJSONC(value, options?)` | ||
Converts a JavaScript value to a [JSONC](https://github.com/microsoft/node-jsonc-parser) string. | ||
### `stringifyTOML(value)` | ||
Converts a JavaScript value to a [TOML](https://toml.io/) string. | ||
@@ -133,0 +169,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
268776
39
1527
206
21
7