module-normalize
v1.0.2
Published
module-normalize
Downloads
7
Readme
module-normalize
Normalize a module id or module url.
Install
$ npm install module-normalize --save
Usage
var normalize = require('module-normalize');
normalize.id('jquery'); // 'jquery@*'
normalize.id('jquery/jquery.js'); // 'jquery@*/jquery.js'
normalize.id('[email protected]'); // '[email protected]'
// scoped module id
normalize.id('@facebook/jquery/jquery.js'); // '@facebook/jquery/*/jquery.js'
normalize.url_from_id('jquery') // '/jquery/*/jquery.js'
normalize.url_from_id('@facebook/jquery'); // '/facebook/jquery/*/jquery.js'
// specify scope
mormalize.url_from_id('[email protected]', {
scope: 'facebook'
});
// '/facebook/jquery/2.0.0/jquery.js'
normalize.parse_id(id)
[@<scope>/]<name>[@<version>][<path>]
Returns Object
- scope the package scope, default to
''
- name the name of the package
- version the version of the package, default ot
'*'
if not specified. - path defualt to
''
- id the normalized id
- package package is the subtle string of
id
excludingpath
License
MIT