forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json-pointer.d.ts
83 lines (79 loc) · 2.2 KB
/
json-pointer.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Type definitions for json-pointer 1.0 l
// Project: https://www.npmjs.org/package/json-pointer
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "json-pointer" {
function JSON_Pointer(object: Object): JSON_Pointer.JSON_PointerWrap;
module JSON_Pointer {
/**
* Wrap an object with accessors
*/
/**
* Looks up a JSON pointer in an object.
*/
function get(object: Object, pointer: string): any;
/**
* Set a value for a JSON pointer on object.
*/
function set(object: Object, pointer: string, value: any): void;
/**
* Removes an attribute of object referenced by pointer
*/
function remove(object: Object, pointer: string): void;
/**
* Creates a dictionary object (pointer -> value).
*/
function dict(object: Object): Object;
/**
* Just like: each(pointer.dict(obj), iterator);
*/
function walk(object: Object, iterator: (value: any, key: string) => void): void;
/**
* Tests if an object has a value for a JSON pointer.
*/
function has(object: Object, pointer: string): boolean;
/**
* Escapes a reference token.
*/
function escape(str: string): string;
/**
* Unescape a reference token.
*/
function unescape(str: string): string;
/**
* Converts a JSON pointer into an array of reference tokens.
*/
function parse(str: string): string[];
/**
* Builds a json pointer from an array of reference tokens.
*/
function compile(str: string[]): string;
interface JSON_PointerWrap {
/**
* Looks up a JSON pointer in an object.
*/
get(pointer: string): any;
/**
* Set a value for a JSON pointer on object.
*/
set(pointer: string, value: any): void;
/**
* Removes an attribute of object referenced by pointer
*/
remove(pointer: string): void;
/**
* Creates a dictionary object (pointer -> value).
*/
dict(): Object;
/**
* Just like: each(pointer.dict(obj), iterator);
*/
walk(iterator: (value: any, key: string) => void): void;
/**
* Tests if an object has a value for a JSON pointer.
*/
has(pointer: string): boolean;
}
}
export = JSON_Pointer;
}