neuron-normalize
v1.0.2
Published
neuron-normalize
Downloads
2
Readme
neuron-normalize
Normalize a module id to a url to a standard pathname.
Install
$ npm install neuron-normalize --save
Usage
var options = {
root: '/mod'
};
var normalize = require('neuron-normalize')(options);
normalize.parse('zepto');
->
{
package: 'zepto@*',
package_name: 'zepto',
id: 'zepto@*/zepto.js',
version: '*',
path: '/zepto.js'
}
normalize.to_url('zepto');
->
'/mod/zepto/*/zepto.js'
normalize.to_package('/mod/zepto/*/zepto.js');
->
{
package: 'zepto@*',
package_name: 'zepto',
id: 'zepto@*/zepto.js',
version: '*',
path: '/zepto.js'
}
options
- root
String
Absolute path from root to the module. Required
Module File Object
type: Object
- package: <module_name>@<version>
- package_name: `<module_name>`
- id: `<module_name>@<version><file_path>`
- version: `<major>.<minor>.<patch>`, default to `'*'`
- path: `/path/to/<filename>.<ext>`, default to `/<package-name>.js`
API
normalize.parse(id)
- id
String
formatted module id
Returns Object
Module File Object
normalize.to_url(id)
- id
String
formatted module id
'[email protected]/lib/zepto.js'
Returns Path
Absolute pathname of a file to the id, or undefined
if not id passed in.
'/mod/zepto/1.0.0/lib/zepto.js'
normalize.to_package(pathname)
- pathname
Path
Absolute pathname of a file
'/mod/zepto/*/zepto.js'
Returns Object
Module File Object
License
MIT