pathnorm

0.0.2 • Public • Published

pathnorm

Build Status

fix path.normalize to cross platform

API

var
path = require('path'),
pathnorm = require('pathnorm');

pathnorm.normalize(p, [useSep='/'])

p normalize as path with separator useSep

e.g.

pathnorm.normalize('a/b/c');   //=> 'a/b/c'
pathnorm.normalize('a\\b\\c'); //=> 'a/b/c'

pathnorm.normalize('a/b/c', '/');    //=> 'a\\b\\c'
pathnorm.normalize('a\\b\\c', '\\'); //=> 'a\\b\\c'

//it returns `true` on all platform
pathnorm.normalize('a/b/c', pathnorm.sep) === path.normalize('a/b/c');

pathnorm.sep

a file separator of your platform. (e.g. if you use windows, pathnorm.sep is '\\', or if you use unix like os, pathnorm.sep is '/')

pathnorm.seps

the separator of each platforms.

such a object:

{
  win32: '\\',
  darwin:  '/',
  freebsd: '/',
  linux:   '/',
  sunos:   '/',
}

License

this library licensed Apache-2.0

Author

Tsuyusato Kitsune make.just.on@gmail.com

Dependents (0)

Package Sidebar

Install

npm i pathnorm

Weekly Downloads

0

Version

0.0.2

License

Apache-2.0

Last publish

Collaborators

  • makenowjust