package.es.compile.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apidom-json-pointer Show documentation
Show all versions of apidom-json-pointer Show documentation
Evaluate JSON Pointer expressions against ApiDOM.
The newest version!
import escape from "./escape.mjs";
import CompilationJsonPointerError from "./errors/CompilationJsonPointerError.mjs"; // compile :: String[] -> String
const compile = tokens => {
try {
if (tokens.length === 0) {
return '';
}
return `/${tokens.map(escape).join('/')}`;
} catch (error) {
throw new CompilationJsonPointerError('JSON Pointer compilation of tokens encountered an error.', {
tokens,
cause: error
});
}
};
export default compile;