-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.js
53 lines (47 loc) · 981 Bytes
/
list.js
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
const { Chunk, ChunkIterator } = require('./chunk')
const { Group } = require('./group')
const { Form } = require('./form')
const { Prop } = require('./prop')
const { ID } = require('./id')
/**
* A container for a list (LIST) and its items.
* @class List
* @extends Group
*/
class List extends Group {
/**
* 4 byte ID for this type.
* @static
* @accessor
* @type {ID}
*/
static get ID() {
return ID.from('LIST')
}
/**
* `List` class constructor
*/
constructor(opts, optionsWhenAssumedGroup) {
if (optionsWhenAssumedGroup) {
opts = optionsWhenAssumedGroup
}
super(List.ID, opts)
}
/**
* An accessor for all PROP items in this list.
* @accessor
* @type {Array<Mixed>}
*/
get props() {
return this.toArray().filter((item) => {
const id = (item && item.id && item.id.toString && item.id.toString())
return 'PROP' === id
})
}
}
/**
* Module exports.
*/
module.exports = {
List
}