@ac-kit/format-jsonc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @ac-kit/format-jsonc
2
+
3
+ JSON with Comments — JSON plus `//` and `/* */` comments and trailing commas,
4
+ the dialect `tsconfig.json` and VS Code settings files are written in.
5
+
6
+ The reason it is its own package is fidelity: editing a value in a JSONC
7
+ document must not delete the comments around it. `editJsonc` rewrites only the
8
+ span that changed.
9
+
10
+ ```ts
11
+ import { editJsonc, parseJsonc } from "@ac-kit/format-jsonc";
12
+
13
+ parseJsonc(`{
14
+ // which port to listen on
15
+ "port": 8080,
16
+ }`);
17
+
18
+ // The comment above "port" survives.
19
+ editJsonc(source, ["port"], 9090);
20
+ ```
21
+
22
+ Also exposes `printJsonc`, `createJsoncEdits`, and
23
+ `JsoncParseStream`/`JsoncPrintStream` over `@ac-kit/format-core`.
24
+
25
+ Portable: no Node.js built-ins, so it runs unchanged in browsers, Deno, Bun and
26
+ edge runtimes.
27
+
28
+ See the
29
+ [generated API docs](https://anthochamp.github.io/node-essentials/api/format-jsonc/)
30
+ for the full reference.
package/dist/edit.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { PropertyPath, TextEdit } from "@ac-kit/core";
2
+ import { type FormattingOptions } from "jsonc-parser";
3
+ /**
4
+ * Returns the minimal {@link TextEdit}s needed to set `value` at `path`.
5
+ *
6
+ * High-fidelity: uses `jsonc-parser.modify()` — the returned edits are minimal
7
+ * AST patches, so comments on untouched keys are preserved verbatim.
8
+ */
9
+ export declare function createJsoncEdits(source: string, path: PropertyPath, value: unknown, formattingOptions?: FormattingOptions): TextEdit[];
10
+ /** Applies {@link createJsoncEdits} result back to `source`. */
11
+ export declare function applyJsoncEdits(source: string, edits: TextEdit[]): string;
12
+ /**
13
+ * Sets `value` at `path` in a JSONC source string, preserving comments.
14
+ *
15
+ * Combines {@link createJsoncEdits} and {@link applyJsoncEdits}.
16
+ */
17
+ export declare function editJsonc(source: string, path: PropertyPath, value: unknown, formattingOptions?: FormattingOptions): string;
18
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AACtE,OAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,OAAO,EACd,iBAAiB,CAAC,EAAE,iBAAiB,GACnC,QAAQ,EAAE,CAKZ;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,OAAO,EACd,iBAAiB,CAAC,EAAE,iBAAiB,GACnC,MAAM,CAKR"}
package/dist/edit.js ADDED
@@ -0,0 +1,27 @@
1
+ import { applyTextEdits } from "@ac-kit/core";
2
+ import jsonc from "jsonc-parser";
3
+ /**
4
+ * Returns the minimal {@link TextEdit}s needed to set `value` at `path`.
5
+ *
6
+ * High-fidelity: uses `jsonc-parser.modify()` — the returned edits are minimal
7
+ * AST patches, so comments on untouched keys are preserved verbatim.
8
+ */
9
+ export function createJsoncEdits(source, path, value, formattingOptions) {
10
+ // jsonc-parser's Edit is `{ offset, length, content }` — same as TextEdit
11
+ return jsonc.modify(source, path, value, {
12
+ formattingOptions,
13
+ });
14
+ }
15
+ /** Applies {@link createJsoncEdits} result back to `source`. */
16
+ export function applyJsoncEdits(source, edits) {
17
+ return applyTextEdits(source, edits);
18
+ }
19
+ /**
20
+ * Sets `value` at `path` in a JSONC source string, preserving comments.
21
+ *
22
+ * Combines {@link createJsoncEdits} and {@link applyJsoncEdits}.
23
+ */
24
+ export function editJsonc(source, path, value, formattingOptions) {
25
+ return applyTextEdits(source, createJsoncEdits(source, path, value, formattingOptions));
26
+ }
27
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAiC,MAAM,cAAc,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAc,EACd,IAAkB,EAClB,KAAc,EACd,iBAAqC;IAErC,0EAA0E;IAC1E,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,IAA2B,EAAE,KAAK,EAAE;QAC/D,iBAAiB;KACjB,CAAe,CAAC;AAClB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,KAAiB;IAChE,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACxB,MAAc,EACd,IAAkB,EAClB,KAAc,EACd,iBAAqC;IAErC,OAAO,cAAc,CACpB,MAAM,EACN,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type ParseError } from "jsonc-parser";
2
+ /** Thrown when JSONC source contains parse errors. */
3
+ export declare class JsoncParseError extends Error {
4
+ readonly offset: number;
5
+ readonly length: number;
6
+ readonly code: ParseError["error"];
7
+ constructor(error: ParseError);
8
+ }
9
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtD,sDAAsD;AACtD,qBAAa,eAAgB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAEnC,YAAY,KAAK,EAAE,UAAU,EAQ5B;CACD"}
package/dist/error.js ADDED
@@ -0,0 +1,15 @@
1
+ import jsonc from "jsonc-parser";
2
+ /** Thrown when JSONC source contains parse errors. */
3
+ export class JsoncParseError extends Error {
4
+ offset;
5
+ length;
6
+ code;
7
+ constructor(error) {
8
+ super(`${jsonc.printParseErrorCode(error.error)} (${error.offset},${error.offset + error.length})`);
9
+ this.offset = error.offset;
10
+ this.length = error.length;
11
+ this.code = error.error;
12
+ this.name = "JsoncParseError";
13
+ }
14
+ }
15
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,cAAc,CAAC;AAEtD,sDAAsD;AACtD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAChC,MAAM,CAAS;IACf,MAAM,CAAS;IACf,IAAI,CAAsB;IAEnC,YAAY,KAAiB;QAC5B,KAAK,CACJ,GAAG,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAC5F,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ export * from "./edit.js";
2
+ export * from "./error.js";
3
+ export * from "./parse-stream.js";
4
+ export * from "./parse.js";
5
+ export * from "./print-stream.js";
6
+ export * from "./print.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./edit.js";
2
+ export * from "./error.js";
3
+ export * from "./parse-stream.js";
4
+ export * from "./parse.js";
5
+ export * from "./print-stream.js";
6
+ export * from "./print.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type ParseOptions } from "jsonc-parser";
2
+ import type { JsonValue } from "type-fest";
3
+ /** Buffers a byte stream and emits one parsed JSONC value on flush. */
4
+ export declare class JsoncParseStream extends TransformStream<Uint8Array, JsonValue> {
5
+ constructor(options?: ParseOptions);
6
+ }
7
+ //# sourceMappingURL=parse-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-stream.d.ts","sourceRoot":"","sources":["../src/parse-stream.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,uEAAuE;AACvE,qBAAa,gBAAiB,SAAQ,eAAe,CAAC,UAAU,EAAE,SAAS,CAAC;IAC3E,YAAY,OAAO,GAAE,YAAiB,EAYrC;CACD"}
@@ -0,0 +1,18 @@
1
+ import { wholeTextParseTransformer } from "@ac-kit/format-core";
2
+ import jsonc from "jsonc-parser";
3
+ import { JsoncParseError } from "./error.js";
4
+ /** Buffers a byte stream and emits one parsed JSONC value on flush. */
5
+ export class JsoncParseStream extends TransformStream {
6
+ constructor(options = {}) {
7
+ const parseOptions = { allowTrailingComma: true, ...options };
8
+ super(wholeTextParseTransformer((source) => {
9
+ const errors = [];
10
+ const result = jsonc.parse(source, errors, parseOptions);
11
+ if (errors.length > 0) {
12
+ throw new JsoncParseError(errors[0]);
13
+ }
14
+ return result;
15
+ }, "JSONC"));
16
+ }
17
+ }
18
+ //# sourceMappingURL=parse-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-stream.js","sourceRoot":"","sources":["../src/parse-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAA4B,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,uEAAuE;AACvE,MAAM,OAAO,gBAAiB,SAAQ,eAAsC;IAC3E,YAAY,OAAO,GAAiB,EAAE;QACrC,MAAM,YAAY,GAAiB,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;QAC5E,KAAK,CACJ,yBAAyB,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,MAAM,MAAM,GAAuB,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAc,CAAC;YACtE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC,EAAE,OAAO,CAAC,CACX,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,6 @@
1
+ import { type ParseOptions } from "jsonc-parser";
2
+ import type { JsonValue } from "type-fest";
3
+ export type JsoncParseOptions = ParseOptions;
4
+ /** Parses a JSONC string, stripping comments. */
5
+ export declare function parseJsonc(source: string, options?: JsoncParseOptions): JsonValue;
6
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAc,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE7C,iDAAiD;AACjD,wBAAgB,UAAU,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAgD,GACvD,SAAS,CAOX"}
package/dist/parse.js ADDED
@@ -0,0 +1,12 @@
1
+ import jsonc from "jsonc-parser";
2
+ import { JsoncParseError } from "./error.js";
3
+ /** Parses a JSONC string, stripping comments. */
4
+ export function parseJsonc(source, options = { allowTrailingComma: true }) {
5
+ const errors = [];
6
+ const result = jsonc.parse(source, errors, options);
7
+ if (errors.length > 0) {
8
+ throw new JsoncParseError(errors[0]);
9
+ }
10
+ return result;
11
+ }
12
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,cAAc,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7C,iDAAiD;AACjD,MAAM,UAAU,UAAU,CACzB,MAAc,EACd,OAAO,GAAsB,EAAE,kBAAkB,EAAE,IAAI,EAAE;IAEzD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAc,CAAC;IACjE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { JsonValue } from "type-fest";
2
+ export type JsoncPrintStreamOptions = {
3
+ indent?: number | string;
4
+ replacer?: Parameters<typeof JSON.stringify>[1];
5
+ };
6
+ /** Emits each incoming {@link JsonValue} as UTF-8 encoded JSONC. */
7
+ export declare class JsoncPrintStream extends TransformStream<JsonValue, Uint8Array> {
8
+ constructor(options?: JsoncPrintStreamOptions);
9
+ }
10
+ //# sourceMappingURL=print-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-stream.d.ts","sourceRoot":"","sources":["../src/print-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,oEAAoE;AACpE,qBAAa,gBAAiB,SAAQ,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC;IAC3E,YAAY,OAAO,GAAE,uBAA4B,EAahD;CACD"}
@@ -0,0 +1,10 @@
1
+ import { textPrintTransformer } from "@ac-kit/format-core";
2
+ /** Emits each incoming {@link JsonValue} as UTF-8 encoded JSONC. */
3
+ export class JsoncPrintStream extends TransformStream {
4
+ constructor(options = {}) {
5
+ // biome-ignore lint/suspicious/noExplicitAny: JSON.stringify overload resolution fails in TS7 when the replacer type is widened
6
+ const stringify = JSON.stringify;
7
+ super(textPrintTransformer((value) => stringify(value, options.replacer, options.indent), "JSONC"));
8
+ }
9
+ }
10
+ //# sourceMappingURL=print-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-stream.js","sourceRoot":"","sources":["../src/print-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAQ3D,oEAAoE;AACpE,MAAM,OAAO,gBAAiB,SAAQ,eAAsC;IAC3E,YAAY,OAAO,GAA4B,EAAE;QAChD,gIAAgI;QAChI,MAAM,SAAS,GAAG,IAAI,CAAC,SAIZ,CAAC;QACZ,KAAK,CACJ,oBAAoB,CACnB,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,EAC7D,OAAO,CACP,CACD,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,8 @@
1
+ import type { JsonValue } from "type-fest";
2
+ export type JsoncPrintOptions = {
3
+ indent?: number | string;
4
+ replacer?: Parameters<typeof JSON.stringify>[1];
5
+ };
6
+ /** Serializes a value to a JSON string (comments are not preserved in print). */
7
+ export declare function printJsonc(value: JsonValue, options?: JsoncPrintOptions): string;
8
+ //# sourceMappingURL=print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../src/print.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,UAAU,CACzB,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAER"}
package/dist/print.js ADDED
@@ -0,0 +1,5 @@
1
+ /** Serializes a value to a JSON string (comments are not preserved in print). */
2
+ export function printJsonc(value, options) {
3
+ return JSON.stringify(value, options?.replacer, options?.indent) ?? "null";
4
+ }
5
+ //# sourceMappingURL=print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.js","sourceRoot":"","sources":["../src/print.ts"],"names":[],"mappings":"AAOA,iFAAiF;AACjF,MAAM,UAAU,UAAU,CACzB,KAAgB,EAChB,OAA2B;IAE3B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC;AAC5E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@ac-kit/format-jsonc",
3
+ "version": "0.1.0",
4
+ "description": "JSON with Comments (JSONC) parse and print streams over @ac-kit/format-core.",
5
+ "keywords": [
6
+ "comments",
7
+ "json",
8
+ "jsonc",
9
+ "parser",
10
+ "streams"
11
+ ],
12
+ "homepage": "https://anthochamp.github.io/node-essentials/api/format-jsonc/",
13
+ "bugs": {
14
+ "url": "https://github.com/anthochamp/node-essentials/issues"
15
+ },
16
+ "license": "BSD-3-Clause",
17
+ "author": "Anthony Champagne <dev@anthonychampagne.fr>",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/anthochamp/node-essentials.git",
21
+ "directory": "packages/format-jsonc"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "main": "./dist/index.js",
29
+ "exports": {
30
+ ".": "./dist/index.js",
31
+ "./file": "./dist/file.js"
32
+ },
33
+ "publishConfig": {
34
+ "main": "./dist/index.js",
35
+ "exports": {
36
+ ".": "./dist/index.js",
37
+ "./file": "./dist/file.js"
38
+ },
39
+ "access": "public"
40
+ },
41
+ "scripts": {
42
+ "compile": "tsc -p ./tsconfig.build.json -outDir dist",
43
+ "compile:check": "tsc -noEmit -p ./tsconfig.json",
44
+ "clean": "rimraf dist",
45
+ "build": "yarn clean && yarn compile",
46
+ "test": "yarn run -T vitest run",
47
+ "prepack": "yarn build"
48
+ },
49
+ "dependencies": {
50
+ "@ac-kit/core": "^0.1.0",
51
+ "@ac-kit/format-core": "^0.1.0",
52
+ "@types/node": "^26.5.1",
53
+ "jsonc-parser": "^3.3.1",
54
+ "type-fest": "^5.8.0"
55
+ },
56
+ "devDependencies": {
57
+ "@ac-kit/tsconfig": "0.1.0",
58
+ "@ac-kit/typedoc-config": "0.1.0",
59
+ "@ac-kit/vitest-config": "0.1.0",
60
+ "@typescript/native": "typescript@7.0.2",
61
+ "rimraf": "6.1.3",
62
+ "typedoc": "0.28.20",
63
+ "typescript": "@typescript/typescript6@6.0.2"
64
+ },
65
+ "engines": {
66
+ "node": ">=24"
67
+ }
68
+ }