mirror of
https://github.com/matrix-construct/construct
synced 2024-12-29 00:44:17 +01:00
ircd::js: Vector construction from Object of array type.
This commit is contained in:
parent
d2b3bedca6
commit
0fbbed7daf
1 changed files with 12 additions and 0 deletions
|
@ -101,6 +101,18 @@ struct vector<value>
|
|||
infallibleAppend(value(t));
|
||||
}
|
||||
|
||||
vector(const object &obj)
|
||||
:JS::AutoVectorRooter<jsapi_type>{*cx}
|
||||
{
|
||||
if(!is_array(obj))
|
||||
throw internal_error("Object is not an array");
|
||||
|
||||
const auto len(obj.size());
|
||||
reserve(obj.size());
|
||||
for(size_t i(0); i < len; ++i)
|
||||
infallibleAppend(get(obj, i));
|
||||
}
|
||||
|
||||
vector(const size_t &size)
|
||||
:JS::AutoVectorRooter<jsapi_type>{*cx}
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue