Permalink
Browse files

rename to shortcircuit

  • Loading branch information...
1 parent d79e304 commit e52e82df7803cbc32a36a348aa8c9b3f5ee313d8 @jsdnxx committed Mar 13, 2013
Showing with 40 additions and 39 deletions.
  1. +35 −33 README.md
  2. +5 −6 package.json
View
68 README.md
@@ -1,58 +1,60 @@
-# connective-promise
-boolean (true/false) and first order (some/every) logic with promises
+# shortcircuit
+asynchronous short circuit evaluation
+
+> Nature operates in the shortest way possible."
+-Aristotle
## installation
- $ npm install connective-promise
+ $ npm install shortcircuit
## usage
```js
-var connectiveP = require('connective-promise')
-var or = connectiveP.or
-var and = connectiveP.and
-var not = connectiveP.not
-var every = connectiveP.every
-var some = connectiveP.some
-var Q = require('your favorite promises implementation')
-
-function userIsAuthenticated () {
- return Q.resolve(true)
-}
+ var shortcircuit = require('shortcircuit')
+ var or = shortcircuit.or
+ var and = shortcircuit.and
+ var not = shortcircuit.not
+ var every = shortcircuit.every
+ var some = shortcircuit.some
+ var Q = require('your favorite promises implementation')
-weGetSignal = Q.resolve(true)
+ function userIsAuthenticated () {
+ return Q.resolve(true)
+ }
-weAreReady = false
+ weGetSignal = Q.resolve(true)
-connectiveP.or(weAreReady, weGetSignal, userIsAuthenticated, weGetSignal)
-// => Promise<true>,
-// terms evaluated in serial, so userIsAuthenticated not called
+ weAreReady = false
+ shortcircuit.or(weAreReady, weGetSignal, userIsAuthenticated, weGetSignal)
+ // => Promise<true>,
+ // terms evaluated in serial, so userIsAuthenticated not called
-connectiveP.some(weAreReady, userIsAuthenticated, weGetSignal)
-// => Promise<true>,
-// terms evaluated in parallel, so userIsAuthenticated is called
+ shortcircuit.some(weAreReady, userIsAuthenticated, weGetSignal)
+ // => Promise<true>,
+ // terms evaluated in parallel, so userIsAuthenticated is called
-connectiveP.all(weAreReady, userIsAuthenticated, weGetSignal)
-// => Promise<false>,
-// terms evaluated in serial so userIsAuthenticated is not called
+ shortcircuit.all(weAreReady, userIsAuthenticated, weGetSignal)
+ // => Promise<false>,
+ // terms evaluated in serial so userIsAuthenticated is not called
-connectiveP.every(weAreReady, userIsAuthenticated, weGetSignal))
-// => Promise<false>,
-// terms evaluated in parallel, so userIsAuthenticated is not called
+ shortcircuit.every(weAreReady, userIsAuthenticated, weGetSignal))
+ // => Promise<false>,
+ // terms evaluated in parallel, so userIsAuthenticated is not called
-connectiveP.not(userIsAuthenticated)
-// => Promise<false>
+ shortcircuit.not(userIsAuthenticated)
+ // => Promise<false>
```
## about
-`connective-promise` helps you compose boolean values, boolean promises, and continuations (functions without parameters) returning booleans or boolean promises.
+`shortcircuit` helps you compose boolean values, boolean promises, and continuations (functions without parameters) returning booleans or boolean promises.
In synchronous code, it can be useful to depend on operator precedence for control flow, for example, to evaluate a function depending on a certain value:
@@ -62,9 +64,9 @@ In this case, we would only have to check for authorization if the user passes t
Now, we could have those be promise-returning functions and write:
- var showPage = connectiveP.or(todayIsTuesday, connectiveP.and(userIsAuthenticated, userIsAuthorized))
+ var showPage = shortcircuit.or(todayIsTuesday, shortcircuit.and(userIsAuthenticated, userIsAuthorized))
-where userIsAuthenticated is a function which returns a promise. Here, if the term is necessary to evaluate the overall truth of the statement, `connective-promise` will invoke the function and await the promised value.
+where userIsAuthenticated is a function which returns a promise. Here, if the term is necessary to evaluate the overall truth of the statement, `shortcircuit` will invoke the function and await the promised value.
In cases where there are no side effects and latency is more important than economy of computation, you can evaluate the terms in parallel.
View
11 package.json
@@ -1,7 +1,7 @@
{
- "name": "connective-promise",
- "version": "0.5.1",
- "description": "boolean (true/false) and first order (some/every) logic with promises",
+ "name": "shortcircuit",
+ "version": "0.5.2",
+ "description": "asynchronous short circuit evaluation",
"keywords": [
"boolean",
"first order logic",
@@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
- "url": "git@github.com:AgileDiagnosis/connective-promise.git"
+ "url": "git@github.com:AgileDiagnosis/shortcircuit.git"
},
"author": "Agile Diagnosis <hello@agilediagnosis.com",
"contributors": [
@@ -30,10 +30,9 @@
"chai": "~1.5.0",
"mocha": "~1.8.1",
"sinon": "~1.5.2",
- "q": "~0.8.12",
"ski": "~1.0.0"
},
"dependencies": {
- "q": "~0.8.12"
+ "q": "~0.9.2"
}
}

0 comments on commit e52e82d

Please sign in to comment.