diff --git a/include/ircd/js/object.h b/include/ircd/js/object.h index ec3f84450..20190f0d1 100644 --- a/include/ircd/js/object.h +++ b/include/ircd/js/object.h @@ -85,6 +85,7 @@ struct object template object(json_t, args&&...); object(array_t, const size_t &length); object(const JS::HandleValueArray &); + object(std::initializer_list>>); object(const value &); object(JSObject *const &); object(JSObject &); @@ -146,6 +147,19 @@ object::object(const value &val) throw type_error("Value is not an Object"); } +template +object::object(std::initializer_list>> list) +:object{} +{ + for(const auto &pair : list) + { + const auto &key(pair.first); + const auto &val(pair.second); + if(!JS_SetProperty(*cx, *this, key, val)) + throw jserror(jserror::pending); + } +} + template object::object(const JS::HandleValueArray &values) :object::root::type