ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<v8::Value> value) { if (value.IsEmpty()) return ScriptPromise(); if (value->IsPromise()) { return ScriptPromise(scriptState, value); } RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); resolver->resolve(value); return promise; }
ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<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::Handle<v8::Value> value) : m_scriptState(scriptState) { if (value.IsEmpty()) return; if (!V8PromiseCustom::isPromise(value, scriptState->isolate()) && !value->IsPromise()) { m_promise = ScriptValue(scriptState, v8::Handle<v8::Value>()); V8ThrowException::throwTypeError("the given value is not a Promise", scriptState->isolate()); return; } m_promise = ScriptValue(scriptState, value); }