resolvewithplus
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "resolvewithplus", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"license" : "MIT", | ||
@@ -5,0 +5,0 @@ "main": "src/resolvewithplus.js", |
@@ -15,3 +15,3 @@ resolvewithplus | ||
``` | ||
_resolvewithplus_, however, is a new version of [resolvewith][1] behaviour with additional non-standard behaviour included. It recognizes [bower][3] module dependencies and it recognizes the [browser property][4] in a package.json (or bower.json) to define browser-specific entry files. | ||
_resolvewithplus_, however, is a new version of [resolvewith][1] behaviour with additional non-standard behaviour included. It recognizes [bower][3] module dependencies and it recognizes the [browser property][4] in a package.json (or bower.json) to define browser-specific entry files. It also locates and returns 'ts' files. | ||
@@ -18,0 +18,0 @@ ```javascript |
@@ -5,10 +5,9 @@ // Filename: resolvewithplus.js | ||
var fs = require('fs'), | ||
path = require('path'); | ||
const fs = require('fs'), | ||
path = require('path'); | ||
var resolvewithplus = module.exports = (function (o) { | ||
const resolvewithplus = module.exports = (o => { | ||
o = function (requirepath, withpath, opts) { | ||
return o.begin(requirepath, withpath, opts || {}); | ||
}; | ||
o = (requirepath, withpath, opts) => | ||
o.begin(requirepath, withpath, opts || {}); | ||
@@ -26,3 +25,3 @@ // https://nodejs.org/api/modules.html#modules_module_require_id | ||
// | ||
o.begin = function (requirepath, withpath, opts) { | ||
o.begin = (requirepath, withpath, opts) => { | ||
var fullpath = null, | ||
@@ -54,12 +53,11 @@ altrequirepath = null; | ||
o.isdirpath = function (p) { | ||
return /^\.?\.?(\/|\\)/.test(p); | ||
}; | ||
o.isdirpath = (p) => | ||
/^\.?\.?(\/|\\)/.test(p); | ||
o.isrelpath = function (p) { | ||
return /^.\.?(?=\/)/.test(p) | ||
|| /^.\.?(?=\\)/.test(p); | ||
}; | ||
o.isrelpath = (p) => | ||
/^.\.?(?=\/)/.test(p) | ||
|| /^.\.?(?=\\)/.test(p); | ||
o.iscoremodule = function (p) { | ||
o.iscoremodule = (p) => { | ||
try { | ||
@@ -72,3 +70,3 @@ return p === require.resolve(p); | ||
o.isfilesync = function (file) { | ||
o.isfilesync = (file) => { | ||
var stat; | ||
@@ -85,3 +83,3 @@ | ||
o.getbrowserindex = function (packagejson, opts) { | ||
o.getbrowserindex = (packagejson, opts) => { | ||
var browserobj = opts && opts.browser && packagejson.browser, | ||
@@ -95,5 +93,5 @@ indexprop, | ||
} else if (typeof browserobj === 'object') { | ||
indexprop = Object.keys(browserobj).filter(function (prop) { | ||
return /index.js$/.test(prop); | ||
})[0]; | ||
indexprop = Object.keys(browserobj).filter((prop) => ( | ||
/index.[tj]s$/.test(prop) | ||
))[0]; | ||
indexval = indexprop in browserobj && browserobj[indexprop]; | ||
@@ -106,6 +104,5 @@ } | ||
o.getpackagepath = function (jsonfile, opts) { | ||
return o.isfilesync(jsonfile) && (jsonfile = require(jsonfile)) && | ||
o.getpackagepath = (jsonfile, opts) => | ||
o.isfilesync(jsonfile) && (jsonfile = require(jsonfile)) && | ||
(o.getbrowserindex(jsonfile, opts) || jsonfile.main); | ||
}; | ||
@@ -119,3 +116,3 @@ // https://nodejs.org/api/modules.html#modules_module_require_id | ||
// 4. If X.node is a file, load X.node as binary addon. STOP | ||
o.getasfilesync = function (f) { | ||
o.getasfilesync = (f) => { | ||
var filepath = null; | ||
@@ -127,6 +124,6 @@ | ||
['.js', | ||
'.ts', | ||
'.json', | ||
'.node'].some(function (ext) { | ||
return o.isfilesync(f + ext) && (filepath = f + ext); | ||
}); | ||
'.node'].some((ext) => ( | ||
o.isfilesync(f + ext) && (filepath = f + ext))); | ||
} | ||
@@ -147,3 +144,3 @@ | ||
// 4. If X/index.node is a file, load X/index.node as binary addon. STOP | ||
o.getasdirsync = function (d, opts) { | ||
o.getasdirsync = (d, opts) => { | ||
var filepath = null, | ||
@@ -160,6 +157,6 @@ relpath, | ||
['index.js', | ||
'index.ts', | ||
'index.json', | ||
'index.node'].some(function (f) { | ||
return o.isfilesync(path.join(d, f)) && (filepath = path.join(d, f)); | ||
}); | ||
'index.node'].some((f) => ( | ||
o.isfilesync(path.join(d, f)) && (filepath = path.join(d, f)))); | ||
} | ||
@@ -170,3 +167,3 @@ | ||
o.getasfileordir = function (requirepath, withpath, opts) { | ||
o.getasfileordir = (requirepath, withpath, opts) => { | ||
var temppath; | ||
@@ -192,6 +189,6 @@ | ||
// array sorting so that longer paths are tested first (closer to withpath) | ||
o.getasnode_module = function (n, start, opts) { | ||
var dirarr = o.getasnode_module_paths(n, start, opts).sort(function (a, b) { | ||
return a.length > b.length; | ||
}); | ||
o.getasnode_module = (n, start, opts) => { | ||
var dirarr = o.getasnode_module_paths(n, start, opts).sort((a, b) => ( | ||
a.length > b.length | ||
)); | ||
@@ -203,3 +200,3 @@ return (function next (dirarr, x) { | ||
o.getfirstparent_packagejson = function (start) { | ||
o.getfirstparent_packagejson = (start) => { | ||
var join = path.join, | ||
@@ -223,3 +220,3 @@ parts = start.split(path.sep), x, | ||
o.getbower_alternate_requirepath = function (start, requirepath, opts) { | ||
o.getbower_alternate_requirepath = (start, requirepath, opts) => { | ||
var parent_packagejson = o.getfirstparent_packagejson(start), | ||
@@ -249,3 +246,3 @@ alternate_requirepath; | ||
// 5. return DIRS | ||
o.getasnode_module_paths = function (n, start, opts) { | ||
o.getasnode_module_paths = (n, start, opts) => { | ||
var join = path.join, | ||
@@ -275,8 +272,7 @@ parts = start.split(path.sep), x, | ||
o.getasdirname = function (p) { | ||
return path.resolve(path.extname(p) ? path.dirname(p) : p); | ||
}; | ||
o.getasdirname = (p) => | ||
path.resolve(path.extname(p) ? path.dirname(p) : p); | ||
return o; | ||
}()); | ||
})(); |
14002
317