Socket
Socket
Sign inDemoInstall

@kaciras/deasync

Package Overview
Dependencies
19
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

26

index.js

@@ -34,10 +34,10 @@ "use strict";

let state = State.Pending;
let value;
let valueOrError;
args.push((err, res) => {
if (err) {
value = err;
valueOrError = err;
state = State.Rejected;
}
else {
value = res;
valueOrError = res;
state = State.Fulfilled;

@@ -49,9 +49,6 @@ }

if (state === State.Rejected) {
throw value;
throw valueOrError;
}
else if (state === State.Fulfilled) {
return value;
}
else {
throw new Error("Invalid state, it's a bug in @kaciras/deasync");
return valueOrError;
}

@@ -69,3 +66,3 @@ };

let state = State.Pending;
let value;
let valueOrError;
if (!isThenable(promise)) {

@@ -75,6 +72,6 @@ return promise;

promise.then(res => {
value = res;
valueOrError = res;
state = State.Fulfilled;
}, err => {
value = err;
valueOrError = err;
state = State.Rejected;

@@ -84,11 +81,8 @@ });

if (state === State.Rejected) {
throw value;
throw valueOrError;
}
else if (state === State.Fulfilled) {
return value;
}
else {
throw new Error("Invalid state, it's a bug in @kaciras/deasync");
return valueOrError;
}
}
exports.awaitSync = awaitSync;
{
"name": "@kaciras/deasync",
"version": "0.2.1",
"version": "0.2.2",
"description": "Turns async code into sync via JavaScript wrapper of Node event loop, support both callback and promise",

@@ -34,3 +34,4 @@ "author": "Kaciras <Kaciras@protonmail.com>",

"install": "node script/prebuild.js install",
"test": "mocha"
"test": "mocha",
"test:coverage": "nyc mocha"
},

@@ -42,2 +43,3 @@ "dependencies": {

"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@kaciras/eslint-config-core": "^1.5.0",

@@ -49,2 +51,3 @@ "@kaciras/eslint-config-typescript": "^1.5.0",

"mocha": "^9.0.0",
"nyc": "^15.1.0",
"ts-node": "^10.0.0",

@@ -51,0 +54,0 @@ "typescript": "^4.3.2"

@@ -5,6 +5,7 @@ # DeAsync

[![Build Status](https://www.travis-ci.com/Kaciras/deasync.svg?branch=master)](https://www.travis-ci.com/Kaciras/deasync)
[![codecov](https://codecov.io/gh/Kaciras/deasync/branch/master/graph/badge.svg?token=ST7ROWQH0Z)](https://codecov.io/gh/Kaciras/deasync)
DeAsync turns async code into sync, implemented with a blocking mechanism by calling Node.js event loop at JavaScript layer. The core of deasync is writen in C++.
This project is a fork from [abbr/deasync](https://github.com/abbr/deasync) and rewrite with modern code. There are some new features added: TypeScript types, Promise support, and prebuild binaries.
This project is forked from [abbr/deasync](https://github.com/abbr/deasync) and rewrite in modern code. There are some new features added: TypeScript types, Promise support, and prebuild binaries.

@@ -25,3 +26,5 @@ ## Motivation

```npm install @kaciras/deasync```
```shell
npm install @kaciras/deasync
```

@@ -34,2 +37,4 @@ By default, Deasync downloads prebuild binary from GitHub releases

Deasync exports two APIs: `deasync` for callback style function, and `awaitSync` for Promise.
### `deasync(function)`

@@ -55,3 +60,3 @@

The `awaitSync` causes execution to pause until a Promise is settled (that is, fulfilled or rejected), and to resume execution of the async function after fulfillment. When resumed, the returned value of the `awaitSync` is that of the fulfilled Promise. If the Promise is rejected, the `awaitSync` throws the rejected value.
The `awaitSync` causes execution to pause until a Promise is settled (that is, fulfilled or rejected), and to resume execution of after fulfillment. When resumed, the returned value of the `awaitSync` is that of the fulfilled Promise. If the Promise is rejected, the `awaitSync` throws the rejected value.

@@ -58,0 +63,0 @@ This function is similar with keyword `await` but synchronously.

@@ -21,3 +21,3 @@ const { execSync } = require("child_process");

return `${name}-v${version}-${runtime}-v${abi}-${platform}-${arch}.tar.br`;
return `${name}-v${version}-${runtime}-${abi}-${platform}-${arch}.tar.br`;
}

@@ -24,0 +24,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc