Skip to content
/ any-path Public

:rage2: make the keys on an object path.sep agnostic.

License

Notifications You must be signed in to change notification settings

bcoe/any-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

any-path

Build Status Coverage Status NPM version

For when the keys in an object represent paths, and you want to be able to fetch them regardless of your operating system's preference for path separators (\, /).

var assert = require('assert')

var ap = require('./')
var o = ap({
  './node_modules/any-path/package.json': {name: 'any-path'}
})

assert.equal(
  o['.\\node_modules\\any-path\\package.json'].name, 'any-path'
) // lookup works \o/

assert.equal(
  o['./node_modules/any-path/package.json'].name, 'any-path'
) // lookup works \o/

assert.equal(
  o['.\\node_modules/any-path\\package.json'].name, 'any-path'
) // lookup works \o/

API

__restore__

Put the object back into its initial state.

var o = anyPath({
  '.\\foo\\bar\\README.md': {name: 'README.md'}
})
o.__restore__().should.deep.equal({
  '.\\foo\\bar\\README.md': {name: 'README.md'}
})

License

ISC

About

:rage2: make the keys on an object path.sep agnostic.

Resources

License

Stars

Watchers

Forks

Packages

No packages published