Skip to content

Commit e9e0d3c

Browse files
minor refactoring
1 parent 3013b32 commit e9e0d3c

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

lib/util.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,19 @@ var debug = require('debug'),
44
_isFunction = require('lodash/lang/isFunction'),
55
protocolPattern = /^[a-z0-9.+-]+:\/\//i;
66

7-
module.exports = {
8-
/**
9-
* Writes messages to stdout.
10-
* Log messages are suppressed by default, but can be enabled by setting the DEBUG variable.
11-
* @type {function}
12-
*/
13-
debug: debug('json-schema-ref-parser'),
14-
cwd: cwd,
15-
isUrl: isUrl,
16-
getHash: getHash,
17-
stripHash: stripHash,
18-
extname: extname,
19-
doCallback: doCallback
20-
};
7+
/**
8+
* Writes messages to stdout.
9+
* Log messages are suppressed by default, but can be enabled by setting the DEBUG variable.
10+
* @type {function}
11+
*/
12+
exports.debug = debug('json-schema-ref-parser');
2113

2214
/**
2315
* Returns the current working directory (in Node) or the current page URL (in browsers).
2416
*
2517
* @returns {string}
2618
*/
27-
function cwd() {
19+
exports.cwd = function cwd() {
2820
return process.browser ? location.href : process.cwd() + '/';
2921
}
3022

@@ -34,7 +26,7 @@ function cwd() {
3426
* @param {string} path
3527
* @returns {boolean}
3628
*/
37-
function isUrl(path) {
29+
exports.isUrl = function isUrl(path) {
3830
return protocolPattern.test(path);
3931
}
4032

@@ -44,7 +36,7 @@ function isUrl(path) {
4436
* @param {string} path
4537
* @returns {string}
4638
*/
47-
function getHash(path) {
39+
exports.getHash = function getHash(path) {
4840
var hashIndex = path.indexOf('#');
4941
if (hashIndex >= 0) {
5042
return path.substr(hashIndex);
@@ -58,7 +50,7 @@ function getHash(path) {
5850
* @param {string} path
5951
* @returns {string}
6052
*/
61-
function stripHash(path) {
53+
exports.stripHash = function stripHash(path) {
6254
var hashIndex = path.indexOf('#');
6355
if (hashIndex >= 0) {
6456
path = path.substr(0, hashIndex);
@@ -72,7 +64,7 @@ function stripHash(path) {
7264
* @param {string} path
7365
* @returns {string}
7466
*/
75-
function extname(path) {
67+
exports.extname = function extname(path) {
7668
var lastDot = path.lastIndexOf('.');
7769
if (lastDot >= 0) {
7870
return path.substr(lastDot).toLowerCase();
@@ -87,7 +79,7 @@ function extname(path) {
8779
* @param {*} [err]
8880
* @param {...*} [params]
8981
*/
90-
function doCallback(callback, err, params) {
82+
exports.doCallback = function doCallback(callback, err, params) {
9183
if (_isFunction(callback)) {
9284
var args = Array.prototype.slice.call(arguments, 1);
9385

0 commit comments

Comments
 (0)