export { J as JSONError } from "./packem_shared/json-error.d-COL8oxF_.js"; import { k as CodeFrameOptions, l as JsonReviver } from "./packem_shared/types.d-B-T1rDxl.js"; import { J as JsonValue } from "./packem_shared/json-value.d-DZqAihX4.js"; export { toPath } from '@visulima/path/utils'; import 'node:fs'; import 'fdir'; /** * Asserts that the provided contents are valid for writing to a file. * Valid contents can be a string, an ArrayBuffer, or an ArrayBuffer view (e.g., Uint8Array). * @param contents The file contents to validate. * @throws {TypeError} If the contents are not a string, ArrayBuffer, or ArrayBuffer view. * @example * ```javascript * import { assertValidFileContents } from "@visulima/fs"; // Assuming this util is exported * * try { * assertValidFileContents("Hello, world!"); * assertValidFileContents(new Uint8Array([72, 101, 108, 108, 111])); // "Hello" * assertValidFileContents(new ArrayBuffer(8)); * console.log("File contents are valid."); * } catch (error) { * console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view. * } * * try { * assertValidFileContents(123); // Invalid content type * } catch (error) { * console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view. * } * ``` */ declare const assertValidFileContents: (contents: any) => void; /** * Asserts that the provided path is a valid file or directory path. * A valid path must be a non-empty string or a URL instance. * @param fileOrDirectoryPath The path to validate. * @throws {TypeError} If the path is not a non-empty string or a URL. * @example * ```javascript * import { assertValidFileOrDirectoryPath } from "@visulima/fs"; // Assuming this util is exported * * try { * assertValidFileOrDirectoryPath("/path/to/file.txt"); * assertValidFileOrDirectoryPath(new URL("file:///path/to/file.txt")); * console.log("Path is valid."); * } catch (error) { * console.error(error.message); // Path must be a non-empty string or URL. * } * * try { * assertValidFileOrDirectoryPath(""); // Invalid path * } catch (error) { * console.error(error.message); // Path must be a non-empty string or URL. * } * ``` */ declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void; declare function parseJson(string: string, filename?: string, options?: CodeFrameOptions): JsonValue; declare function parseJson(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): JsonValue; /** * Strips comments from a JSON string. * Handles both single-line (//) and multi-line (/* ... */) comments. * @param jsonString The JSON string possibly containing comments. * @param [options] Optional configuration for stripping comments. * @param [options.whitespace] If `true` (default), comments are replaced with whitespace to preserve line numbers and character positions. If `false`, comments are removed entirely. * @returns The JSON string with comments stripped. * @example * ```javascript * import { stripJsonComments } from "@visulima/fs"; // Assuming this util is exported * * const jsonWithComments = `{ * // This is a single-line comment * "name": "John Doe", * "age": 30, /* This is a * multi-line comment */ * "city": "New York" * }`; * * const stripped = stripJsonComments(jsonWithComments); * console.log(stripped); * // Output (with whitespace=true): * // { * // * // "name": "John Doe", * // "age": 30, /* * // * // "city": "New York" * // } * * const strippedWithoutWhitespace = stripJsonComments(jsonWithComments, { whitespace: false }); * console.log(strippedWithoutWhitespace); * // Output (with whitespace=false): * // { * // "name": "John Doe", * // "age": 30, * // "city": "New York" * // } * ``` */ declare const stripJsonComments: (jsonString: string, options?: { whitespace?: boolean; }) => string; export { assertValidFileContents, assertValidFileOrDirectoryPath, parseJson, stripJsonComments };