Skip to content

neuron-js/neuron-normalize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version npm module downloads per month Build Status Dependency Status

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
'zepto@1.0.0/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

About

Normalize a module id into a standard pathname

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published