forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeRecord.js
More file actions
50 lines (44 loc) · 1.6 KB
/
makeRecord.js
File metadata and controls
50 lines (44 loc) · 1.6 KB
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
/**
* When Flow 0.29 is released (very soon), we can use this Record type
* instead of the builtin immutable.js Record type. This is better
* because all the fields are actually typed, unlike the builtin one.
* This depends on a performance fix that will go out in 0.29 though;
* @module utils/makeRecord
*/
import * as I from "immutable";
/**
* @memberof utils/makeRecord
* @static
*/
export type Record<T: Object> = {
equals<A>(other: A): boolean,
get<A>(key: $Keys<T>, notSetValue?: any): A,
getIn<A>(keyPath: Array<any>, notSetValue?: any): A,
hasIn<A>(keyPath: Array<any>): boolean,
set<A>(key: $Keys<T>, value: A): Record<T>,
setIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>,
merge(values: $Shape<T>): Record<T>,
mergeIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>,
delete<A>(key: $Keys<T>, value: A): Record<T>,
deleteIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>,
update<A>(key: $Keys<T>, value: A): Record<T>,
updateIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>,
remove<A>(key: $Keys<T>): Record<T>,
toJS(): T
} & T;
/**
* Make an immutable record type
*
* @param spec - the keys and their default values
* @return a state record factory function
* @memberof utils/makeRecord
* @static
*/
function makeRecord<T>(spec: T & Object): () => Record<T> {
return I.Record(spec);
}
export default makeRecord;