Comparing version 5.0.0 to 5.1.0
@@ -439,6 +439,2 @@ var abbott = require('abbott'); | ||
if(!values.length){ | ||
return righto.from(undefined); | ||
} | ||
values = values.slice(); | ||
@@ -450,2 +446,6 @@ | ||
if(!values.length){ | ||
return righto.from(seed); | ||
} | ||
return values.reduce(function(previous, next){ | ||
@@ -452,0 +452,0 @@ return righto.sync(reducer, previous, righto.value(next)); |
{ | ||
"name": "righto", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"main": "index.js", | ||
@@ -10,2 +10,3 @@ "directories": { | ||
"test": "node test", | ||
"coverage": "covert test", | ||
"watchtest": "watchify -d test/index.js -o test/index.browser.js" | ||
@@ -20,2 +21,3 @@ }, | ||
"console-watch": "^1.0.2", | ||
"covert": "^1.1.0", | ||
"linklocal": "^2.5.2", | ||
@@ -22,0 +24,0 @@ "tape": "^4.4.0", |
@@ -14,3 +14,35 @@ # Righto | ||
## Signature: | ||
`righto(cps-function, ...args) -> fn(err-back)` | ||
where: | ||
a cps-function has signature: `cps-function(...args, err-back) -> void` | ||
an err-back has signature: `err-back(error, ...results) -> void` | ||
## Examples | ||
Simple Example: read some files | ||
```javascript | ||
var fs = require('fs'); | ||
function concatStrings(a, b, callback){ | ||
callback(null, a + b); | ||
}; | ||
var myFile = righto(fs.readFile, 'utf8' 'myFile.txt'); | ||
var mySecondFile = righto(fs.readFile, 'utf8', 'mySecondFile.txt'); | ||
var concattedFiles = righto(concatStrings, myFile, mySecondFile); | ||
concattedFiles(function(error, result){ | ||
console.log(error); // null | ||
console.log(result); // the two concatted files. | ||
}); | ||
``` | ||
A more involved example: return a document for a user while checking permissions. | ||
```javascript | ||
// Make a task from an err-back function | ||
@@ -50,2 +82,4 @@ var document = righto(db.Documents.get, documentId); | ||
The inventor of JavaScript said it was cool in a tweet once: https://twitter.com/BrendanEich/status/1059210746163130368 | ||
## Usage: | ||
@@ -64,3 +98,3 @@ | ||
```javascript | ||
function foo(callback){ | ||
function getFoo(callback){ | ||
setTimeout(function(){ | ||
@@ -67,0 +101,0 @@ callback(null, 'foo'); |
@@ -1280,6 +1280,14 @@ var test = require('tape'), | ||
d(function(){ | ||
var trace = getResults().log[0]; | ||
var logResults = getResults().log; | ||
var trace = logResults[0]; | ||
t.equal(trace.split(/\n/g).length, 7); | ||
t.ok(~trace.indexOf('ERROR SOURCE')); | ||
if(~trace.indexOf('COVERED')){ | ||
// Running coverage. | ||
t.pass(); | ||
t.pass(); | ||
return; | ||
} else { | ||
t.equal(trace.split(/\n/g).length, 7); | ||
t.ok(~trace.indexOf('ERROR SOURCE')); | ||
} | ||
@@ -1286,0 +1294,0 @@ righto._debug = false; |
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
73138
1821
786
5