1.5.0 • Published 9 years ago

dobj v1.5.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

dobj

Object deep dot access. set, get, del methods available


License

MIT License see LICENSE file.

Installation

npm install dobj

API documentation

get(path:string) : *

var obj = {
    a: {
        b: {
            c: 'test'
        }
    }
};

dobj(obj).get('a.b.c');
// => 'test'

set(path:string, value:*) : dobj

var obj = {
    a: {
        b: {
            c: 'test'
        }
    }
};

dobj(obj)
    .set('a.b.c', 'ok')
    .get('a.b.c');
// => 'ok'

forceSet(path:string, value:*) : dobj

This method sets the property (by path) even if the path does not exists. For example:

var obj = {};

dobj(obj)
    .forceSet('a.b.c', 'ok')
    .get('a.b.c');
// => 'ok'

del(path:string) : dobj

var obj = {
    a: {
        b: {
            c: 'test'
        }
    }
};

dobj(obj)
    .del('a.b.c')
    .get('a.b.c');
// => undefined

silentGet(path:string) : * and silentDel(path:string) : dobj

These methods are a "silent" versions of get and del. If you call them on paths that does not exists no exception will be thrown. If path is incorrect silentGet will return undefined and silentDel will remain silent and return dobj as normal del.

1.5.0

9 years ago

1.4.4

10 years ago

1.4.3

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.0

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago