Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9583267
item-list-result.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
item-list-result.ts
View Options
import
CollectionItem
from
"./collection-item.js"
;
import
type
Collection
from
"./collection.js"
;
export
class
ItemListResult
<
T
extends
Collection
>
{
constructor
(
public
items
:
CollectionItem
<
T
>
[],
public
fields_with_attachments
:
string
[],
public
attachments
:
{
[
id
:
string
]
:
CollectionItem
}
=
{}
)
{
items
.
forEach
((
item
)
=>
item
.
setParentList
(
this
));
}
// this generator method makes the instance of this class iterable with for..of
*
[
Symbol
.
iterator
]()
:
Iterator
<
CollectionItem
<
T
>>
{
for
(
const
item
of
this
.
items
)
{
yield
item
;
}
}
get
empty
()
:
boolean
{
return
this
.
items
.
length
===
0
;
}
serialize
()
:
{
items
:
Record
<
string
,
unknown
>
[];
attachments
:
Record
<
string
,
Record
<
string
,
unknown
>>
;
fields_with_attachments
:
string
[];
}
{
return
{
items
:
this
.
items
.
map
((
item
)
=>
item
.
serializeBody
()),
attachments
:
Object
.
fromEntries
(
Object
.
entries
(
this
.
attachments
).
map
(([
id
,
item
])
=>
[
id
,
item
.
serializeBody
(),
])
),
fields_with_attachments
:
this
.
fields_with_attachments
,
};
}
static
fromSerialized
<
T
extends
Collection
>
(
collection
:
T
,
serialized
:
{
items
:
any
[];
attachments
:
{
[
id
:
string
]
:
any
};
fields_with_attachments
:
string
[];
}
)
:
ItemListResult
<
Collection
>
{
return
new
ItemListResult
<
T
>
(
serialized
.
items
.
map
((
item_data
)
=>
CollectionItem
.
fromSerialized
(
collection
,
item_data
,
serialized
.
attachments
)
),
serialized
.
fields_with_attachments
,
serialized
.
attachments
);
}
flattenWithAttachments
()
{
return
{
...
this
.
attachments
,
...
Object
.
fromEntries
(
this
.
items
.
map
((
item
)
=>
[
item
.
id
,
item
])),
};
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Oct 11, 09:16 (3 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
930651
Default Alt Text
item-list-result.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment