New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-try

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-try - npm Package Compare versions

Comparing version 0.0.8 to 0.0.11

test.js

13

async-try.js

@@ -6,8 +6,19 @@ /**

module.exports.TRY = function (desc, fn, fail, succ){
function getErrorObject(){
try { throw Error('') } catch(err) { return err; }
}
var err = getErrorObject();
var caller_line = err.stack.split("\n")[4];
var index = caller_line.indexOf("at ");
var clean = caller_line.slice(index+2, caller_line.length);
fn(function(){
var argsArray = _.toArray(arguments);
var error = _.first(argsArray);
var stackTrace
var args = _.rest(argsArray);
if (error) {
fail("while " + desc + "\n -> " + error );
fail(error + "\n"+ ((_.isString(desc) && !_.isEmpty(desc))?(" | While " + desc):"") + " at:" + clean );
}

@@ -14,0 +25,0 @@ else if (_.isFunction(succ)) {

2

package.json
{
"name": "async-try",
"version": "0.0.8",
"version": "0.0.11",
"main": "async-try.js",

@@ -5,0 +5,0 @@ "repository": {

async-try, helper module to debug asyncronous code.
usage:
```
```JavaScript
var _ = require("lodash");

@@ -14,4 +14,4 @@ var TRY = require("async-try").TRY;

console.log("...dary");
callback(null, "legendary!");
}, time*1000 );
callback(null, "legendary!");
} else {

@@ -22,27 +22,30 @@ callback("need more patience");

var throwErr = function(error){
Throw new Error(error);
TRY( "waiting for it", waitForIt(5), console.log, function(result){
console.log("This module is " + result);
})
var dontWait = function(callback){
TRY( "pretending to wait for it", waitForIt(2), callback, function(result){
console.log("This module is " + result);
});
}
```
Then for
```
TRY( "waiting for it", waitForIt(5), throwErr, function(result){
TRY( "not waiting for it", dontWait, throwErr, function(result){
console.log("This module is " + result);
})
```
we get
```
will output
```AsciiDoc
this module is legen...
...wait for it...
this module is legen...
...wait for it...
[ERROR] need more patience
| While pretending to wait for it at: dontWait (C:\Users\DayoAdeyemi\vm5.6\dev-
vm\vagrant\ece-dev\projects\async-try\test.js:27:2)
| While not waiting for it at: Object.<anonymous> (C:\Users\DayoAdeyemi\vm5.6\d
ev-vm\vagrant\ece-dev\projects\async-try\test.js:35:1)
...dary
This module is legendary!
```
But for
```
TRY( "waiting for it", waitForIt(2), throwErr, function(result){
console.log("This module is " + result);
})
```
```
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