|
1 | 1 | /* eslint-disable no-unused-vars */ |
2 | | -"use strict"; |
| 2 | +import $Refs from "./refs.js"; |
| 3 | +import _parse from "./parse.js"; |
| 4 | +import normalizeArgs from "./normalize-args.js"; |
| 5 | +import resolveExternal from "./resolve-external.js"; |
| 6 | +import _bundle from "./bundle.js"; |
| 7 | +import _dereference from "./dereference.js"; |
| 8 | +import * as url from "./util/url.js"; |
| 9 | +import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError, isHandledError, JSONParserErrorGroup } from "./util/errors.js"; |
| 10 | +import maybe from "call-me-maybe"; |
| 11 | +import { ono } from "@jsdevtools/ono"; |
3 | 12 |
|
4 | | -const $Refs = require("./refs"); |
5 | | -const _parse = require("./parse"); |
6 | | -const normalizeArgs = require("./normalize-args"); |
7 | | -const resolveExternal = require("./resolve-external"); |
8 | | -const _bundle = require("./bundle"); |
9 | | -const _dereference = require("./dereference"); |
10 | | -const url = require("./util/url"); |
11 | | -const { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError, isHandledError, JSONParserErrorGroup } = require("./util/errors"); |
12 | | -const maybe = require("call-me-maybe"); |
13 | | -const { ono } = require("@jsdevtools/ono"); |
14 | | - |
15 | | -module.exports = $RefParser; |
16 | | -module.exports.default = $RefParser; |
17 | | -module.exports.JSONParserError = JSONParserError; |
18 | | -module.exports.InvalidPointerError = InvalidPointerError; |
19 | | -module.exports.MissingPointerError = MissingPointerError; |
20 | | -module.exports.ResolverError = ResolverError; |
21 | | -module.exports.ParserError = ParserError; |
22 | | -module.exports.UnmatchedParserError = UnmatchedParserError; |
23 | | -module.exports.UnmatchedResolverError = UnmatchedResolverError; |
| 13 | +export default $RefParser; |
| 14 | +export { JSONParserError }; |
| 15 | +export { InvalidPointerError }; |
| 16 | +export { MissingPointerError }; |
| 17 | +export { ResolverError }; |
| 18 | +export { ParserError }; |
| 19 | +export { UnmatchedParserError }; |
| 20 | +export { UnmatchedResolverError }; |
24 | 21 |
|
25 | 22 | /** |
26 | 23 | * This class parses a JSON schema, builds a map of its JSON references and their resolved values, |
@@ -281,3 +278,13 @@ function finalize (parser) { |
281 | 278 | throw new JSONParserErrorGroup(parser); |
282 | 279 | } |
283 | 280 | } |
| 281 | + |
| 282 | +export const parse = $RefParser.parse.bind($RefParser); |
| 283 | +export const resolve = $RefParser.resolve.bind($RefParser); |
| 284 | +export const bundle = $RefParser.bundle.bind($RefParser); |
| 285 | +export const dereference = $RefParser.dereference.bind($RefParser); |
| 286 | + |
| 287 | +// CommonJS default export hack |
| 288 | +if (typeof module === "object" && typeof module.exports === "object") { |
| 289 | + module.exports = Object.assign(module.exports.default, module.exports); |
| 290 | +} |
0 commit comments