Sha256: 78ff6c04689bf3380b8b530ded9e187f4e0841915fd26f32a48cf638d01f76d3
Contents?: true
Size: 573 Bytes
Versions: 35
Compression:
Stored size: 573 Bytes
Contents
function promiseState(promise) { var uniqueValue = window['Symbol'] ? Symbol('unique') : Math.random().toString(36) function notifyPendingOrResolved(value) { if (value === uniqueValue) { return Promise.resolve({ state: 'pending' }) } else { return Promise.resolve({ state: 'fulfilled', value: value }) } } function notifyRejected(reason) { return Promise.resolve({ state: 'rejected', value: reason }) } var race = [promise, Promise.resolve(uniqueValue)] return Promise.race(race).then(notifyPendingOrResolved, notifyRejected) }
Version data entries
35 entries across 35 versions & 1 rubygems