main
Last change
on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
484 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import escape from "./escape.mjs";
|
---|
| 2 | import CompilationJsonPointerError from "./errors/CompilationJsonPointerError.mjs"; // compile :: String[] -> String
|
---|
| 3 | const compile = tokens => {
|
---|
| 4 | try {
|
---|
| 5 | if (tokens.length === 0) {
|
---|
| 6 | return '';
|
---|
| 7 | }
|
---|
| 8 | return `/${tokens.map(escape).join('/')}`;
|
---|
| 9 | } catch (error) {
|
---|
| 10 | throw new CompilationJsonPointerError('JSON Pointer compilation of tokens encountered an error.', {
|
---|
| 11 | tokens,
|
---|
| 12 | cause: error
|
---|
| 13 | });
|
---|
| 14 | }
|
---|
| 15 | };
|
---|
| 16 | export default compile; |
---|
Note:
See
TracBrowser
for help on using the repository browser.