Merge pull request #7603 from SamVerschueren/dot-prop

add dot-prop
This commit is contained in:
Horiuchi_H
2016-01-14 16:35:53 +09:00
2 changed files with 21 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
/// <reference path="./dot-prop.d.ts" />
import * as dotProp from 'dot-prop';
dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
const obj = {foo: {bar: 'a'}};
dotProp.set(obj, 'foo.bar', 'b');
dotProp.set(obj, 'foo.baz', 'x');
dotProp.set(obj, 'foo.dot\\.dot', 'unicorn');
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for dot-prop
// Project: https://github.com/sindresorhus/dot-prop
// Definitions by: Sam Verschueren <https://github.com/samverschueren>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "dot-prop" {
export function get(object: any, path: string): any;
export function set(object: any, path: string, value: any): void;
}