1.0.2 • Published 10 years ago

module-normalize v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

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