ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Local<v8::Value> value) { if (value.IsEmpty()) return ScriptPromise(); if (value->IsPromise()) { return ScriptPromise(scriptState, value); } InternalResolver resolver(scriptState); ScriptPromise promise = resolver.promise(); resolver.resolve(value); return promise; }
ScriptPromise::ScriptPromise(ScriptState* scriptState, v8::Local<v8::Value> value) : m_scriptState(scriptState) { if (value.IsEmpty()) return; if (!value->IsPromise()) { m_promise = ScriptValue(scriptState, v8::Local<v8::Value>()); V8ThrowException::throwTypeError(scriptState->isolate(), "the given value is not a Promise"); return; } m_promise = ScriptValue(scriptState, value); }
result_t util_base::isPromise(v8::Local<v8::Value> v, bool& retVal) { retVal = v->IsPromise(); return 0; }