Home

Awesome

to-path

Converts string to a property path array.

MIT License

build:? coverage:?

Install

$ npm install --save to-path 

Usage

For more use-cases see the tests

var toPath = require('to-path');

toPath('a');          // => ['a']
toPath('a.b.c');      // => ['a', 'b', 'c']
toPath('a[0].b.c');   // => ['a', '0', 'b', 'c']
toPath('a[x].b.c');   // => ['a', 'x', 'b', 'c']
toPath('a["x"].b.c'); // => ['a', 'x', 'b', 'c']
toPath(0);            // => ['0']
toPath([1, 2, 3]);    // => ['1', '2', '3']

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.