Comparing version 1.3.0 to 1.4.0
@@ -18,2 +18,6 @@ (function initLazyAss() { | ||
function isError(e) { | ||
return e instanceof Error; | ||
} | ||
function toString(arg, k) { | ||
@@ -76,2 +80,6 @@ if (isPrimitive(arg)) { | ||
function lazyAssLogic(condition) { | ||
if (isError(condition)) { | ||
return condition; | ||
} | ||
var fn = typeof condition === 'function' ? condition : null; | ||
@@ -78,0 +86,0 @@ |
{ | ||
"name": "lazy-ass", | ||
"description": "Lazy assertions without performance penalty", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"author": { | ||
"name": "Gleb Bahmutov", | ||
"email": "gleb.bahmutov@gmail.com" | ||
}, | ||
"bugs": { | ||
@@ -11,3 +14,3 @@ "url": "https://github.com/bahmutov/lazy-ass/issues" | ||
"pre-git": { | ||
"commit-msg": "validate-commit-msg", | ||
"commit-msg": "simple", | ||
"pre-commit": [ | ||
@@ -23,13 +26,2 @@ "npm test" | ||
}, | ||
"release": { | ||
"verifyConditions": [ | ||
{ | ||
"path": "@semantic-release/condition-travis" | ||
}, | ||
{ | ||
"path": "condition-node-version", | ||
"node": "4.2.2" | ||
} | ||
] | ||
}, | ||
"contributors": [], | ||
@@ -41,3 +33,3 @@ "dependencies": {}, | ||
"condition-node-version": "1.2.0", | ||
"coveralls": "2.11.4", | ||
"coveralls": "2.11.6", | ||
"expect.js": "0.3.1", | ||
@@ -48,7 +40,7 @@ "git-issues": "1.2.0", | ||
"grunt-clean-console": "0.1.1", | ||
"grunt-cli": "0.1.13", | ||
"grunt-cli": "1.0.0-rc1", | ||
"grunt-contrib-concat": "0.5.1", | ||
"grunt-contrib-copy": "0.8.2", | ||
"grunt-contrib-jshint": "0.11.3", | ||
"grunt-contrib-uglify": "0.11.0", | ||
"grunt-contrib-jshint": "1.0.0", | ||
"grunt-contrib-uglify": "0.11.1", | ||
"grunt-contrib-watch": "0.6.1", | ||
@@ -59,3 +51,3 @@ "grunt-deps-ok": "0.9.0", | ||
"grunt-mocha-test": "0.12.7", | ||
"grunt-nice-package": "0.10.1", | ||
"grunt-nice-package": "0.10.2", | ||
"grunt-npm2bower-sync": "0.9.1", | ||
@@ -66,10 +58,11 @@ "jshint-stylish": "2.1.0", | ||
"karma-coverage": "0.5.3", | ||
"karma-mocha": "0.2.1", | ||
"karma-phantomjs-launcher": "0.2.1", | ||
"matchdep": "1.0.0", | ||
"mocha": "2.3.4", | ||
"karma-mocha": "0.2.2", | ||
"karma-phantomjs-launcher": "1.0.0", | ||
"matchdep": "1.0.1", | ||
"mocha": "2.4.5", | ||
"phantomjs": "2.1.3", | ||
"pkgfiles": "2.3.0", | ||
"pre-git": "1.4.0", | ||
"semantic-release": "6.0.3", | ||
"time-grunt": "1.2.2" | ||
"pre-git": "3.4.0", | ||
"semantic-release": "6.2.0", | ||
"time-grunt": "1.3.0" | ||
}, | ||
@@ -97,9 +90,20 @@ "engines": { | ||
"main": "index.js", | ||
"release": { | ||
"verifyConditions": [ | ||
{ | ||
"path": "@semantic-release/condition-travis" | ||
}, | ||
{ | ||
"path": "condition-node-version", | ||
"node": "4.2.2" | ||
} | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bahmutov/lazy-ass.git" | ||
"url": "git+https://github.com/bahmutov/lazy-ass.git" | ||
}, | ||
"scripts": { | ||
"build": "grunt", | ||
"commit": "git-issues && commit-wizard", | ||
"build": "grunt", | ||
"coveralls": "cat coverage/PhantomJS*/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
@@ -111,7 +115,9 @@ "demo": "grunt gh-pages", | ||
"pkgfiles": "pkgfiles", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"size": "tarball=\"$(npm pack .)\"; wc -c \"${tarball}\"; tar tvf \"${tarball}\"; rm \"${tarball}\";", | ||
"test": "grunt test", | ||
"watch": "grunt watch", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
} | ||
"watch": "grunt watch" | ||
}, | ||
"readme": "ERROR: No README data found!", | ||
"_id": "lazy-ass@0.0.0-semantic-release" | ||
} |
@@ -114,2 +114,44 @@ # lazy-ass | ||
## Rethrowing errors | ||
If the condition itself is an instance of Error, it is simply rethrown (synchronously or | ||
asynchronously). | ||
```js | ||
lazyAss(new Error('foo')); | ||
// Uncaught Error: foo | ||
``` | ||
Useful to make sure errors in the promise chains are | ||
[not silently ignored](https://glebbahmutov.com/blog/why-promises-need-to-be-done/). | ||
For example, a rejected promise below this will be ignored. | ||
```js | ||
var p = new Promise(function (resolve, reject) { | ||
reject(new Error('foo')); | ||
}); | ||
p.then(...); | ||
``` | ||
We can catch it and rethrow it *synchronously*, but it will be ignored too (same way, | ||
only one step further) | ||
```js | ||
var p = new Promise(function (resolve, reject) { | ||
reject(new Error('foo')); | ||
}); | ||
p.then(..., lazyAss); | ||
``` | ||
But we can actually trigger global error if we rethrow the error *asynchronously* | ||
```js | ||
var p = new Promise(function (resolve, reject) { | ||
reject(new Error('foo')); | ||
}); | ||
p.then(..., lazyAssync); | ||
// Uncaught Error: foo | ||
``` | ||
## Predicate function as a condition | ||
@@ -116,0 +158,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18627
163
260
34