@jupyterlab/observables 2.1.1-alpha.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,226 +1,226 @@
1
- import { IDisposable } from '@phosphor/disposable';
2
- import { ISignal } from '@phosphor/signaling';
3
- import { IObservable } from './modeldb';
4
- /**
5
- * A map which can be observed for changes.
6
- */
7
- export interface IObservableMap<T> extends IDisposable, IObservable {
8
- /**
9
- * The type of the Observable.
10
- */
11
- type: 'Map';
12
- /**
13
- * A signal emitted when the map has changed.
14
- */
15
- readonly changed: ISignal<this, IObservableMap.IChangedArgs<T>>;
16
- /**
17
- * The number of key-value pairs in the map.
18
- */
19
- readonly size: number;
20
- /**
21
- * Set a key-value pair in the map
22
- *
23
- * @param key - The key to set.
24
- *
25
- * @param value - The value for the key.
26
- *
27
- * @returns the old value for the key, or undefined
28
- * if that did not exist.
29
- */
30
- set(key: string, value: T): T | undefined;
31
- /**
32
- * Get a value for a given key.
33
- *
34
- * @param key - the key.
35
- *
36
- * @returns the value for that key.
37
- */
38
- get(key: string): T | undefined;
39
- /**
40
- * Check whether the map has a key.
41
- *
42
- * @param key - the key to check.
43
- *
44
- * @returns `true` if the map has the key, `false` otherwise.
45
- */
46
- has(key: string): boolean;
47
- /**
48
- * Get a list of the keys in the map.
49
- *
50
- * @returns - a list of keys.
51
- */
52
- keys(): string[];
53
- /**
54
- * Get a list of the values in the map.
55
- *
56
- * @returns - a list of values.
57
- */
58
- values(): T[];
59
- /**
60
- * Remove a key from the map
61
- *
62
- * @param key - the key to remove.
63
- *
64
- * @returns the value of the given key,
65
- * or undefined if that does not exist.
66
- */
67
- delete(key: string): T | undefined;
68
- /**
69
- * Set the ObservableMap to an empty map.
70
- */
71
- clear(): void;
72
- /**
73
- * Dispose of the resources held by the map.
74
- */
75
- dispose(): void;
76
- }
77
- /**
78
- * The interfaces associated with an IObservableMap.
79
- */
80
- export declare namespace IObservableMap {
81
- /**
82
- * The change types which occur on an observable map.
83
- */
84
- type ChangeType = 'add'
85
- /**
86
- * An entry was removed.
87
- */
88
- | 'remove'
89
- /**
90
- * An entry was changed.
91
- */
92
- | 'change';
93
- /**
94
- * The changed args object which is emitted by an observable map.
95
- */
96
- interface IChangedArgs<T> {
97
- /**
98
- * The type of change undergone by the map.
99
- */
100
- type: ChangeType;
101
- /**
102
- * The key of the change.
103
- */
104
- key: string;
105
- /**
106
- * The old value of the change.
107
- */
108
- oldValue: T | undefined;
109
- /**
110
- * The new value of the change.
111
- */
112
- newValue: T | undefined;
113
- }
114
- }
115
- /**
116
- * A concrete implementation of IObservbleMap<T>.
117
- */
118
- export declare class ObservableMap<T> implements IObservableMap<T> {
119
- /**
120
- * Construct a new observable map.
121
- */
122
- constructor(options?: ObservableMap.IOptions<T>);
123
- /**
124
- * The type of the Observable.
125
- */
126
- readonly type: 'Map';
127
- /**
128
- * A signal emitted when the map has changed.
129
- */
130
- readonly changed: ISignal<this, IObservableMap.IChangedArgs<T>>;
131
- /**
132
- * Whether this map has been disposed.
133
- */
134
- readonly isDisposed: boolean;
135
- /**
136
- * The number of key-value pairs in the map.
137
- */
138
- readonly size: number;
139
- /**
140
- * Set a key-value pair in the map
141
- *
142
- * @param key - The key to set.
143
- *
144
- * @param value - The value for the key.
145
- *
146
- * @returns the old value for the key, or undefined
147
- * if that did not exist.
148
- *
149
- * @throws if the new value is undefined.
150
- *
151
- * #### Notes
152
- * This is a no-op if the value does not change.
153
- */
154
- set(key: string, value: T): T | undefined;
155
- /**
156
- * Get a value for a given key.
157
- *
158
- * @param key - the key.
159
- *
160
- * @returns the value for that key.
161
- */
162
- get(key: string): T | undefined;
163
- /**
164
- * Check whether the map has a key.
165
- *
166
- * @param key - the key to check.
167
- *
168
- * @returns `true` if the map has the key, `false` otherwise.
169
- */
170
- has(key: string): boolean;
171
- /**
172
- * Get a list of the keys in the map.
173
- *
174
- * @returns - a list of keys.
175
- */
176
- keys(): string[];
177
- /**
178
- * Get a list of the values in the map.
179
- *
180
- * @returns - a list of values.
181
- */
182
- values(): T[];
183
- /**
184
- * Remove a key from the map
185
- *
186
- * @param key - the key to remove.
187
- *
188
- * @returns the value of the given key,
189
- * or undefined if that does not exist.
190
- */
191
- delete(key: string): T | undefined;
192
- /**
193
- * Set the ObservableMap to an empty map.
194
- */
195
- clear(): void;
196
- /**
197
- * Dispose of the resources held by the map.
198
- */
199
- dispose(): void;
200
- private _map;
201
- private _itemCmp;
202
- private _changed;
203
- private _isDisposed;
204
- }
205
- /**
206
- * The namespace for `ObservableMap` class statics.
207
- */
208
- export declare namespace ObservableMap {
209
- /**
210
- * The options used to initialize an observable map.
211
- */
212
- interface IOptions<T> {
213
- /**
214
- * An optional initial set of values.
215
- */
216
- values?: {
217
- [key: string]: T;
218
- };
219
- /**
220
- * The item comparison function for change detection on `set`.
221
- *
222
- * If not given, strict `===` equality will be used.
223
- */
224
- itemCmp?: (first: T, second: T) => boolean;
225
- }
226
- }
1
+ import { IDisposable } from '@phosphor/disposable';
2
+ import { ISignal } from '@phosphor/signaling';
3
+ import { IObservable } from './modeldb';
4
+ /**
5
+ * A map which can be observed for changes.
6
+ */
7
+ export interface IObservableMap<T> extends IDisposable, IObservable {
8
+ /**
9
+ * The type of the Observable.
10
+ */
11
+ type: 'Map';
12
+ /**
13
+ * A signal emitted when the map has changed.
14
+ */
15
+ readonly changed: ISignal<this, IObservableMap.IChangedArgs<T>>;
16
+ /**
17
+ * The number of key-value pairs in the map.
18
+ */
19
+ readonly size: number;
20
+ /**
21
+ * Set a key-value pair in the map
22
+ *
23
+ * @param key - The key to set.
24
+ *
25
+ * @param value - The value for the key.
26
+ *
27
+ * @returns the old value for the key, or undefined
28
+ * if that did not exist.
29
+ */
30
+ set(key: string, value: T): T | undefined;
31
+ /**
32
+ * Get a value for a given key.
33
+ *
34
+ * @param key - the key.
35
+ *
36
+ * @returns the value for that key.
37
+ */
38
+ get(key: string): T | undefined;
39
+ /**
40
+ * Check whether the map has a key.
41
+ *
42
+ * @param key - the key to check.
43
+ *
44
+ * @returns `true` if the map has the key, `false` otherwise.
45
+ */
46
+ has(key: string): boolean;
47
+ /**
48
+ * Get a list of the keys in the map.
49
+ *
50
+ * @returns - a list of keys.
51
+ */
52
+ keys(): string[];
53
+ /**
54
+ * Get a list of the values in the map.
55
+ *
56
+ * @returns - a list of values.
57
+ */
58
+ values(): T[];
59
+ /**
60
+ * Remove a key from the map
61
+ *
62
+ * @param key - the key to remove.
63
+ *
64
+ * @returns the value of the given key,
65
+ * or undefined if that does not exist.
66
+ */
67
+ delete(key: string): T | undefined;
68
+ /**
69
+ * Set the ObservableMap to an empty map.
70
+ */
71
+ clear(): void;
72
+ /**
73
+ * Dispose of the resources held by the map.
74
+ */
75
+ dispose(): void;
76
+ }
77
+ /**
78
+ * The interfaces associated with an IObservableMap.
79
+ */
80
+ export declare namespace IObservableMap {
81
+ /**
82
+ * The change types which occur on an observable map.
83
+ */
84
+ type ChangeType = 'add'
85
+ /**
86
+ * An entry was removed.
87
+ */
88
+ | 'remove'
89
+ /**
90
+ * An entry was changed.
91
+ */
92
+ | 'change';
93
+ /**
94
+ * The changed args object which is emitted by an observable map.
95
+ */
96
+ interface IChangedArgs<T> {
97
+ /**
98
+ * The type of change undergone by the map.
99
+ */
100
+ type: ChangeType;
101
+ /**
102
+ * The key of the change.
103
+ */
104
+ key: string;
105
+ /**
106
+ * The old value of the change.
107
+ */
108
+ oldValue: T | undefined;
109
+ /**
110
+ * The new value of the change.
111
+ */
112
+ newValue: T | undefined;
113
+ }
114
+ }
115
+ /**
116
+ * A concrete implementation of IObservbleMap<T>.
117
+ */
118
+ export declare class ObservableMap<T> implements IObservableMap<T> {
119
+ /**
120
+ * Construct a new observable map.
121
+ */
122
+ constructor(options?: ObservableMap.IOptions<T>);
123
+ /**
124
+ * The type of the Observable.
125
+ */
126
+ readonly type: 'Map';
127
+ /**
128
+ * A signal emitted when the map has changed.
129
+ */
130
+ readonly changed: ISignal<this, IObservableMap.IChangedArgs<T>>;
131
+ /**
132
+ * Whether this map has been disposed.
133
+ */
134
+ readonly isDisposed: boolean;
135
+ /**
136
+ * The number of key-value pairs in the map.
137
+ */
138
+ readonly size: number;
139
+ /**
140
+ * Set a key-value pair in the map
141
+ *
142
+ * @param key - The key to set.
143
+ *
144
+ * @param value - The value for the key.
145
+ *
146
+ * @returns the old value for the key, or undefined
147
+ * if that did not exist.
148
+ *
149
+ * @throws if the new value is undefined.
150
+ *
151
+ * #### Notes
152
+ * This is a no-op if the value does not change.
153
+ */
154
+ set(key: string, value: T): T | undefined;
155
+ /**
156
+ * Get a value for a given key.
157
+ *
158
+ * @param key - the key.
159
+ *
160
+ * @returns the value for that key.
161
+ */
162
+ get(key: string): T | undefined;
163
+ /**
164
+ * Check whether the map has a key.
165
+ *
166
+ * @param key - the key to check.
167
+ *
168
+ * @returns `true` if the map has the key, `false` otherwise.
169
+ */
170
+ has(key: string): boolean;
171
+ /**
172
+ * Get a list of the keys in the map.
173
+ *
174
+ * @returns - a list of keys.
175
+ */
176
+ keys(): string[];
177
+ /**
178
+ * Get a list of the values in the map.
179
+ *
180
+ * @returns - a list of values.
181
+ */
182
+ values(): T[];
183
+ /**
184
+ * Remove a key from the map
185
+ *
186
+ * @param key - the key to remove.
187
+ *
188
+ * @returns the value of the given key,
189
+ * or undefined if that does not exist.
190
+ */
191
+ delete(key: string): T | undefined;
192
+ /**
193
+ * Set the ObservableMap to an empty map.
194
+ */
195
+ clear(): void;
196
+ /**
197
+ * Dispose of the resources held by the map.
198
+ */
199
+ dispose(): void;
200
+ private _map;
201
+ private _itemCmp;
202
+ private _changed;
203
+ private _isDisposed;
204
+ }
205
+ /**
206
+ * The namespace for `ObservableMap` class statics.
207
+ */
208
+ export declare namespace ObservableMap {
209
+ /**
210
+ * The options used to initialize an observable map.
211
+ */
212
+ interface IOptions<T> {
213
+ /**
214
+ * An optional initial set of values.
215
+ */
216
+ values?: {
217
+ [key: string]: T;
218
+ };
219
+ /**
220
+ * The item comparison function for change detection on `set`.
221
+ *
222
+ * If not given, strict `===` equality will be used.
223
+ */
224
+ itemCmp?: (first: T, second: T) => boolean;
225
+ }
226
+ }