
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
An alternative to Promises.
To redraw the UI once it finishes, or to close a DB connection after consumers are done with it.
Of course, you can’t finalize a Promise, but you can finalize a FunQ:
function openDb() {
return (
new FunQ({ value: { db: null } })
.onSuccess((value, resolve, reject) => {
openDb(/* ... */,
result => {
value.db = result
resolve()
},
error => reject(error))
})
.onFinished((error, value) => {
if (error) console.error(error)
closeDb(value.db)
})
)
}
loadMyData()
.onSuccess((value, resolve, reject) => {
value.db.select(/* ... */,
result => {
value.result = result
resolve()
},
error => reject(error))
})
.onSuccess((value) => {
// Do something with value.result
})
Because you want something to finish immediately? Like your unit tests?
With FunQ, you have a choice of running callbacks now (in sync) or deferred (async, just like Promises), depending on what you need. It comes with the following method pairs:
Each after... method runs after the current function returns; each on... method runs immediately (once it's their turn).
You have full control, and no surprises.
npm i fun-q
or
yarn add fun-q
import { FunQ } from 'fun-q'
new FunQ({ value: { answer: 42 } })
.onSuccess((value, resolve, reject) => {
value.answer = 11
resolve()
})
.onError((e, value, resolve, reject) => {
value.answer = 22
resolve()
})
.onFinished((e, value, resolve, reject) => {
console.log(value.answer) // 11
})
import { FunQ } from 'fun-q'
new FunQ({ value: { a: false, b: false } })
.onSuccessResolveAll([
(v, resolve) => {
v.a = true
resolve()
},
(v, resolve) => {
v.b = true
resolve()
},
])
.onFinished((e, v) => {
console.log(v) // { a: true, b: true }
})
Check the unit tests for more examples.
MIT
FAQs
An alternative to Promises.
The npm package fun-q receives a total of 5 weekly downloads. As such, fun-q popularity was classified as not popular.
We found that fun-q 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.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.