module-normalize

1.0.2 • Public • Published

Build Status

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('jquery@1.9.0');       // 'jquery@1.9.0'
 
// 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('jquery@2.0.0', {
  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 excluding path

License

MIT

Package Sidebar

Install

npm i module-normalize

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • kael