Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bcoe/any-path
:rage2: make the keys on an object path.sep agnostic.
https://github.com/bcoe/any-path
Last synced: about 2 months ago
JSON representation
:rage2: make the keys on an object path.sep agnostic.
- Host: GitHub
- URL: https://github.com/bcoe/any-path
- Owner: bcoe
- License: isc
- Created: 2015-12-20T02:35:23.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-21T03:04:44.000Z (about 9 years ago)
- Last Synced: 2024-10-20T14:24:01.901Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-cross-platform-nodejs - any-path - Use Windows and POSIX paths interchangeably when fetching values from an object. (Libraries / Filesystem)
- awesome - bcoe/any-path - :rage2: make the keys on an object path.sep agnostic. (JavaScript)
README
# any-path
[![Build Status](https://travis-ci.org/bcoe/any-path.png)](https://travis-ci.org/bcoe/any-path)
[![Coverage Status](https://coveralls.io/repos/bcoe/any-path/badge.svg?branch=master)](https://coveralls.io/r/bcoe/any-path?branch=master)
[![NPM version](https://img.shields.io/npm/v/any-path.svg)](https://www.npmjs.com/package/any-path)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 (`\`, `/`).```javascript
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.
```js
var o = anyPath({
'.\\foo\\bar\\README.md': {name: 'README.md'}
})
o.__restore__().should.deep.equal({
'.\\foo\\bar\\README.md': {name: 'README.md'}
})
```## License
ISC