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

clues

Package Overview
Dependencies
Maintainers
2
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clues - npm Package Compare versions

Comparing version 3.5.1 to 3.5.2

8

clues.js

@@ -124,3 +124,9 @@ (function(self) {

duration = new Date();
return fn.apply(logic || {}, args);
try {
return fn.apply(logic || {}, args);
} catch(e) {
if (e && e.stack && typeof $global.$logError === 'function')
$global.$logError(e);
throw e;
}
})

@@ -127,0 +133,0 @@ .then(function(d) {

2

package.json
{
"name": "clues",
"version": "3.5.1",
"version": "3.5.2",
"description": "Lightweight logic tree solver using promises.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -148,2 +148,4 @@ [![NPM Version][npm-image]][npm-url]

You can provide a function called `$logError` in the `$global` object to record any true javascript errors (with `.stack`) when they occur. For proper logging it is important to capture the error at source, as the dependencies might be optional - in which case the error never reaches the original request.
### making arguments optional with the underscore prefix

@@ -150,0 +152,0 @@ If any argument to a function resolves as a rejected promise (i.e. errored) then the function will not run and simply be rejected as well. But sometimes we want to continue nevertheless. Any argument to any function can be made optional by prefixing the argument name with an underscore. If the resolution of the optional argument returns a rejected promise (or the optional argument does not exist), then the value of this argument to the function will simply be `undefined`.

@@ -98,4 +98,41 @@ var clues = require('../clues'),

});
describe('$logError',function() {
var logic = {
stack_error: function() { throw new Error('error');},
rejection: function() { throw 'error';},
optional: function(_stack_error,_rejection) {
return 'OK';
}
};
it('should log an error with stack',function() {
var facts = Object.create(logic),error;
return clues(facts,'stack_error',{$logError:function(e) {error = e;}})
.catch(Object)
.then(function() {
assert.equal(error.message,'error');
});
});
it('should not log an error with no stack',function() {
var facts = Object.create(logic),error;
return clues(facts,'rejection',{$logError:function(e) {error = e;}})
.catch(Object)
.then(function() {
assert.equal(error,undefined);
});
});
it('should log an error even if only used optionally',function() {
var facts = Object.create(logic),error;
return clues(facts,'optional',{$logError:function(e) {error = e;}})
.catch(Object)
.then(function() {
assert.equal(error.message,'error');
});
});
});
});
});
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