![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
promise-faker
Advanced tools
Provides promise-like APIs but runs synchronously. This module is useful for controlling flows.
Provides Promise
-like APIs but runs synchronously. This module is useful for controlling flows.
$ npm install promise-faker
import FakePromise from 'promise-faker'
// Write flows as normal Promise does
function factory (p) {
const result = p.resolve(1)
.then(() => {
return 2
})
// Not to make the following chain.
return p.resolve(result, true)
}
// Then, run them as synchronous flows
factory(FakePromise) // 2
factory(Promise) // Promise {2}
FakePromise actually runs synchronously:
Promise.resolve(1).then(console.log)
console.log(2)
// 2
// 1
FakePromise.resolve(3).then(console.log)
console.log(4)
// 3
// 4
Function(resolve, reject)
Returns a fake promise
?boolean=false
The additional parameter only for FakePromise
, and if this parameter is true
, it will try to get the final value or throw an error if there is a rejection.FakePromise.resolve(FakePromise.resolve(1), true)
// 1
FakePromise.resolve(FakePromise.reject('2'), true)
// -> throw '2'
And if the fake promise is still pending, an Error('pending unexpectedly')
error will thrown.
const p = new FakePromise((resolve, reject) => {
return 1
})
try {
FakePromise.resolve(p, true)
} catch (e) {
console.log(e.message) // 'pending unexpectedly'
}
Similar as Promise.reject
, but returns a fake promise
Similar as Promise.all
, but returns a fake promise
Similar as promise.then
, but returns a fake promise
Similar as promise.catch
, but returns a fake promise
The FakePromise
instance could even be await
ed
console.log(await FakePromise.resolve(1)) // 1
await FakePromise.reject('error') // throw 'error'
MIT
FAQs
Provides promise-like APIs but runs synchronously. This module is useful for controlling flows.
The npm package promise-faker receives a total of 0 weekly downloads. As such, promise-faker popularity was classified as not popular.
We found that promise-faker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.