Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

synchronized-promise

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

synchronized-promise

Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

synchronized-promise

All Contributors

npm version Build Status

Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package

Installation

npm install synchronized-promise --save

Usage

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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


侠小然

💻

Clar Charron

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 02 Apr 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc