
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
synchronized-promise
Advanced tools
Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package
Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package
npm install synchronized-promise --save
First, you need to require the synchronized-promise
packgage, for JavaScript:
const sp = require('synchronized-promise')
For TypeScript or ES6 later JavaScript:
import sp from 'synchronized-promise'
Then call it as the following example:
// An promise base async function
let asyncFunction = (value) => {
return new Promise((resolve, reject) => {
setTimeout(function () {
resolve(value)
}, 2000)
})
}
// regular usage
asyncFunction(5).then(value => value === 5)
// make it synchronized
let syncFunc = sp(asyncFunction)
const value = syncFunc(5) // value === 5
See test.js
for usage in details.
Thanks goes to these wonderful people (emoji key):
侠小然 💻 | Clar Charron 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package
The npm package synchronized-promise receives a total of 4,032 weekly downloads. As such, synchronized-promise popularity was classified as popular.
We found that synchronized-promise 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.