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

synchron

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

synchron - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "synchron",
"version": "1.0.1",
"version": "1.0.2",
"description": "Wait till async functions end and forces a synchron process without blocking",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,3 +15,3 @@ # Synchron

Create a new instance of Synchro and use the methods `return` and `throw`. The `wait` method will wait until
`return` or `throw` was executed.
`return` or `throw` was called.

@@ -22,11 +22,20 @@ ```javascript

setTimeout(function(){
asyncTimeout.return('success');
// do something
console.log('inside setTimeout');
// and than call done
asyncTimeout.done();
}, 500);
var ret = asyncTimeout.wait();
console.log(ret); // --> "success"
// non-blocking wait until done was called
asyncTimeout.wait();
console.log('back in main');
// this will output:
// --------------------
// inside setTimeout
// back in main
```
Create a new instance and pass a function to wrap the asnyc function into a synchron function call.
The warpped function will run in the context of Synchron, so you can use `this.return` and/or `this.throw`.
Create a new instance and pass a function to wrap the asnyc call into a synchron function.
The warpped function will run in the context of `Synchron`, so you can use `this.return` and/or `this.throw`.
If you like to exit the async function without returning a result just call `this.return()` without a parameter or call `this.done()`.

@@ -48,7 +57,9 @@

try {
// here is the synchron function call
var data = readFileSync('./testfile.txt');
console.log(data);
} catch (err){
// if an error occours the function will throw it and you can catch it
console.log(err); // maybe an error like: "ENOENT: no such file or directory, open './testfile.txt'"
}
```
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