1.0.2 • Published 9 years ago

neuron-normalize v1.0.2

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

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

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago