1
1
"use strict" ;
2
2
3
- const Options = require ( "./options" ) ;
4
3
const $Refs = require ( "./refs" ) ;
5
- const parse = require ( "./parse" ) ;
4
+ const _parse = require ( "./parse" ) ;
6
5
const normalizeArgs = require ( "./normalize-args" ) ;
7
6
const resolveExternal = require ( "./resolve-external" ) ;
8
- const bundle = require ( "./bundle" ) ;
9
- const dereference = require ( "./dereference" ) ;
7
+ const _bundle = require ( "./bundle" ) ;
8
+ const _dereference = require ( "./dereference" ) ;
10
9
const url = require ( "./util/url" ) ;
11
10
const { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError, isHandledError, JSONParserErrorGroup } = require ( "./util/errors" ) ;
12
11
const maybe = require ( "call-me-maybe" ) ;
13
12
const { ono } = require ( "@jsdevtools/ono" ) ;
14
13
15
14
module . exports = $RefParser ;
15
+ module . exports . default = $RefParser ;
16
16
module . exports . JSONParserError = JSONParserError ;
17
17
module . exports . InvalidPointerError = InvalidPointerError ;
18
18
module . exports . MissingPointerError = MissingPointerError ;
@@ -56,7 +56,7 @@ function $RefParser () {
56
56
* @param {function } [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
57
57
* @returns {Promise } - The returned promise resolves with the parsed JSON schema object.
58
58
*/
59
- $RefParser . parse = function ( path , schema , options , callback ) {
59
+ $RefParser . parse = function parse ( path , schema , options , callback ) {
60
60
let Class = this ; // eslint-disable-line consistent-this
61
61
let instance = new Class ( ) ;
62
62
return instance . parse . apply ( instance , arguments ) ;
@@ -73,7 +73,7 @@ $RefParser.parse = function (path, schema, options, callback) {
73
73
* @param {function } [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
74
74
* @returns {Promise } - The returned promise resolves with the parsed JSON schema object.
75
75
*/
76
- $RefParser . prototype . parse = async function ( path , schema , options , callback ) {
76
+ $RefParser . prototype . parse = async function parse ( path , schema , options , callback ) {
77
77
let args = normalizeArgs ( arguments ) ;
78
78
let promise ;
79
79
@@ -111,7 +111,7 @@ $RefParser.prototype.parse = async function (path, schema, options, callback) {
111
111
}
112
112
else {
113
113
// Parse the schema file/url
114
- promise = parse ( args . path , this . $refs , args . options ) ;
114
+ promise = _parse ( args . path , this . $refs , args . options ) ;
115
115
}
116
116
117
117
let me = this ;
@@ -156,7 +156,7 @@ $RefParser.prototype.parse = async function (path, schema, options, callback) {
156
156
* @returns {Promise }
157
157
* The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
158
158
*/
159
- $RefParser . resolve = function ( path , schema , options , callback ) {
159
+ $RefParser . resolve = function resolve ( path , schema , options , callback ) {
160
160
let Class = this ; // eslint-disable-line consistent-this
161
161
let instance = new Class ( ) ;
162
162
return instance . resolve . apply ( instance , arguments ) ;
@@ -175,7 +175,7 @@ $RefParser.resolve = function (path, schema, options, callback) {
175
175
* @returns {Promise }
176
176
* The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
177
177
*/
178
- $RefParser . prototype . resolve = async function ( path , schema , options , callback ) {
178
+ $RefParser . prototype . resolve = async function resolve ( path , schema , options , callback ) {
179
179
let me = this ;
180
180
let args = normalizeArgs ( arguments ) ;
181
181
@@ -201,7 +201,7 @@ $RefParser.prototype.resolve = async function (path, schema, options, callback)
201
201
* @param {function } [callback] - An error-first callback. The second parameter is the bundled JSON schema object
202
202
* @returns {Promise } - The returned promise resolves with the bundled JSON schema object.
203
203
*/
204
- $RefParser . bundle = function ( path , schema , options , callback ) {
204
+ $RefParser . bundle = function bundle ( path , schema , options , callback ) {
205
205
let Class = this ; // eslint-disable-line consistent-this
206
206
let instance = new Class ( ) ;
207
207
return instance . bundle . apply ( instance , arguments ) ;
@@ -218,13 +218,13 @@ $RefParser.bundle = function (path, schema, options, callback) {
218
218
* @param {function } [callback] - An error-first callback. The second parameter is the bundled JSON schema object
219
219
* @returns {Promise } - The returned promise resolves with the bundled JSON schema object.
220
220
*/
221
- $RefParser . prototype . bundle = async function ( path , schema , options , callback ) {
221
+ $RefParser . prototype . bundle = async function bundle ( path , schema , options , callback ) {
222
222
let me = this ;
223
223
let args = normalizeArgs ( arguments ) ;
224
224
225
225
try {
226
226
await this . resolve ( args . path , args . schema , args . options ) ;
227
- bundle ( me , args . options ) ;
227
+ _bundle ( me , args . options ) ;
228
228
finalize ( me ) ;
229
229
return maybe ( args . callback , Promise . resolve ( me . schema ) ) ;
230
230
}
@@ -243,7 +243,7 @@ $RefParser.prototype.bundle = async function (path, schema, options, callback) {
243
243
* @param {function } [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
244
244
* @returns {Promise } - The returned promise resolves with the dereferenced JSON schema object.
245
245
*/
246
- $RefParser . dereference = function ( path , schema , options , callback ) {
246
+ $RefParser . dereference = function dereference ( path , schema , options , callback ) {
247
247
let Class = this ; // eslint-disable-line consistent-this
248
248
let instance = new Class ( ) ;
249
249
return instance . dereference . apply ( instance , arguments ) ;
@@ -259,13 +259,13 @@ $RefParser.dereference = function (path, schema, options, callback) {
259
259
* @param {function } [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
260
260
* @returns {Promise } - The returned promise resolves with the dereferenced JSON schema object.
261
261
*/
262
- $RefParser . prototype . dereference = async function ( path , schema , options , callback ) {
262
+ $RefParser . prototype . dereference = async function dereference ( path , schema , options , callback ) {
263
263
let me = this ;
264
264
let args = normalizeArgs ( arguments ) ;
265
265
266
266
try {
267
267
await this . resolve ( args . path , args . schema , args . options ) ;
268
- dereference ( me , args . options ) ;
268
+ _dereference ( me , args . options ) ;
269
269
finalize ( me ) ;
270
270
return maybe ( args . callback , Promise . resolve ( me . schema ) ) ;
271
271
}
0 commit comments