mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 19:09:18 +08:00
add dot-prop
This commit is contained in:
12
dot-prop/dot-prop-tests.ts
Normal file
12
dot-prop/dot-prop-tests.ts
Normal 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
9
dot-prop/dot-prop.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user