Skip to main content

Built and signed on GitHub Actions

Library to write out the contents of a JavaScript object structure to the file system in a granular directory structure.

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
3 months ago (0.1.4)
Package root>path_encoder.ts
/** * Encode a path element so that it does not contain any forward slashes (and can be decoded). * This is a tiny subset of URI element encoding. * * @param element The path element string to encode. * @returns An encoded string guaranteed not to contain forward slashes. */ export function encodePathElement(element: string): string { return element.replaceAll("%", "%25").replaceAll("/", "%2F"); } /** * Perform the reverse of {@linkcode encodePathElement}: decode a path element back to its original form. * * @param element The path element to decode. * @returns The decoded path element */ export function decodePathElement(element: string): string { return element.replaceAll("%2F", "/").replaceAll("%25", "%"); }