add dot-prop

This commit is contained in:
Sam Verschueren
2016-01-13 08:48:52 +01:00
parent 1984ea435f
commit 8b515b2363
2 changed files with 21 additions and 0 deletions

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
dot-prop/dot-prop.d.ts vendored Normal file
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;
}