Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
callforth
Advanced tools
Readme
A tiny utility library to replace callbacks with Promises where possible. Don't callback, callforth!
It simply includes a hand-full of functions I see myself re-implementing in nearly every project. So I might as well put them in a package.
Do things like:
await timeout(3000)
await eventOn(videoElement, "loadeddata")
const message = await eventOn(webWorker, "message")
npm install callforth
Now you can:
import { eventOn, timeout, polling } from "callforth"
Alternatively, include this script and:
<script src="./path/to/callforth.umd.js"></script>
<script>
const { eventOn, timeout, polling } = window.callforth
</script>
eventOn
const payload = await eventOn(target, successEvent, errorEvent)
EventTarget
- any object you can call addEventListener
on.string
- name of the event you want to await.string
(optional) - if this event fires, the promise is rejected.Promise<any>
- wraps callback result (callbacks first argument)timeout
await timeout(delay)
int
- milliseconds after which the Promise should resolves.Promise<void>
polling
await polling(predicate, { maxTries, interval })
any -> boolean
- delay in milliseconds after which the Promise should resolve.object
(optional)
int
(default = 10) - maximum number of times to call predicate before giving up.int
(default = 10) - delay in milliseconds between calls of predicate.Promise<void>
async function loadScript(url) {
let script = document.createElement("script")
script.src = url
await eventOn(script, "loaded")
}
async function primesLessThen(number) {
primeWorker.postMessage(number)
const result = await eventOn(primeWorker, "message")
return result
}
FAQs
A tiny utility library to conveniently replace callbacks with Promises.
The npm package callforth receives a total of 10,802 weekly downloads. As such, callforth popularity was classified as popular.
We found that callforth 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.