1.0.4 • Published 9 years ago

path-to-object v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

path-to-object

Converts string such 'a.b.c' to object {a: {b: {c: {}}}}

Installation

npm install path-to-object

Example usage

var pathToObject = require('path-to-object');

pathToObject('a.b.c.d'); // {a: {b: {c: {d: {}}}}

// Passing second param will set last field's value
pathToObject('a.b.c', true); // {a: {b: {c: true}}}

// Helper contains method to get or set value by string path
var myObj = {
    a: {
        b: 5
    }
};

pathToObject.value(myObj, 'a.b'); // 5
pathToObject.value(myObj, 'a.b', 10); // {a: {b: 10}}
pathToObject.value(myObj, 'a.b'); // 10
1.0.4

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago