| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index dbc782c2dbe6802be7892cccf0a84017c923fd7c..7cf416cfbd240bfd8f85b8ec9dc331b5649df117 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -6131,6 +6131,31 @@ size_t v8::Map::Size() const {
|
| }
|
|
|
|
|
| +Local<Array> Map::AsArray() const {
|
| + i::Handle<i::JSMap> obj = Utils::OpenHandle(this);
|
| + i::Isolate* isolate = obj->GetIsolate();
|
| + i::Factory* factory = isolate->factory();
|
| + LOG_API(isolate, "Map::AsArray");
|
| + ENTER_V8(isolate);
|
| + i::Handle<i::OrderedHashMap> table(i::OrderedHashMap::cast(obj->table()));
|
| + int length = table->NumberOfElements();
|
| + i::Handle<i::FixedArray> result = factory->NewFixedArray(length);
|
| + for (int i = 0; i < length; ++i) {
|
| + if (table->KeyAt(i)->IsTheHole()) continue;
|
| + i::HandleScope handle_scope(isolate);
|
| + i::Handle<i::FixedArray> entry = factory->NewFixedArray(2);
|
| + entry->set(0, table->KeyAt(i));
|
| + entry->set(1, table->ValueAt(i));
|
| + i::Handle<i::JSArray> entry_array =
|
| + factory->NewJSArrayWithElements(entry, i::FAST_ELEMENTS, 2);
|
| + result->set(i, *entry_array);
|
| + }
|
| + i::Handle<i::JSArray> result_array =
|
| + factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length);
|
| + return Utils::ToLocal(result_array);
|
| +}
|
| +
|
| +
|
| Local<v8::Set> v8::Set::New(Isolate* isolate) {
|
| i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
| LOG_API(i_isolate, "Set::New");
|
| @@ -6146,6 +6171,27 @@ size_t v8::Set::Size() const {
|
| }
|
|
|
|
|
| +Local<Array> Set::AsArray() const {
|
| + i::Handle<i::JSSet> obj = Utils::OpenHandle(this);
|
| + i::Isolate* isolate = obj->GetIsolate();
|
| + i::Factory* factory = isolate->factory();
|
| + LOG_API(isolate, "Set::AsArray");
|
| + ENTER_V8(isolate);
|
| + i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table()));
|
| + int length = table->NumberOfElements();
|
| + i::Handle<i::FixedArray> result = factory->NewFixedArray(length);
|
| + for (int i = 0; i < length; ++i) {
|
| + i::Object* key = table->KeyAt(i);
|
| + if (!key->IsTheHole()) {
|
| + result->set(i, key);
|
| + }
|
| + }
|
| + i::Handle<i::JSArray> result_array =
|
| + factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length);
|
| + return Utils::ToLocal(result_array);
|
| +}
|
| +
|
| +
|
| bool Value::IsPromise() const {
|
| auto self = Utils::OpenHandle(this);
|
| return i::Object::IsPromise(self);
|
|
|