Comparing version 3.2.0 to 4.0.0
10
index.js
@@ -456,2 +456,6 @@ var abbott = require('abbott'); | ||
righto.from = function(value){ | ||
if(arguments.length > 1){ | ||
throw new Error('righto.from called with more than one argument. Righto v4 no longer supports constructing eventuals via `from`, use `sync` instead.'); | ||
} | ||
if(isRighto(value)){ | ||
@@ -461,8 +465,2 @@ return value; | ||
if(!isResolvable(value) && typeof value === 'function'){ | ||
return righto.all(slice(arguments, 1)).get(function(args){ | ||
return righto.from(value.apply(null, args)); | ||
}); | ||
} | ||
return righto.sync(function(resolved){ | ||
@@ -469,0 +467,0 @@ return resolved; |
{ | ||
"name": "righto", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -400,2 +400,7 @@ # Righto | ||
``` | ||
righto.sync(createARighto, args...); // Calls createARighto with args..., and then returns a new righto that resolves the result | ||
righto.sync(createAPromise, args...); // Calls createAPromise with args..., and then returns a new righto that resolves the results | ||
``` | ||
## From | ||
@@ -409,4 +414,2 @@ | ||
righto.from(5); // Returns a new righto that resolves 5 | ||
righto.from(createARighto, args...); // Calls createARighto with args..., and then returns a new righto that resolves the result | ||
righto.from(createAPromise, args...); // Calls createAPromise with args..., and then returns a new righto that resolves the result | ||
``` | ||
@@ -416,3 +419,3 @@ | ||
Sometimes it may be required to pass a resolvable (a righto, or promise) without as an argument, | ||
Sometimes it may be required to pass a resolvable (a righto, or promise) as an argument | ||
rather than passing the resolved value of the resolvable. you can do this using `righto.value(resolvable)` | ||
@@ -470,6 +473,7 @@ | ||
## Surely (resolve [error?, results...?]) | ||
## Surely | ||
You can resolve a task to an array containing either | ||
the error or results from a righto with `righto.surely` | ||
the error or results from a righto with `righto.surely`, | ||
which resolves to an array in the form of `[error?, results...?]`. | ||
@@ -476,0 +480,0 @@ ```javascript |
@@ -1432,3 +1432,3 @@ var test = require('tape'), | ||
test('from tasks that return eventuals', function(t){ | ||
test('sync tasks that return eventuals', function(t){ | ||
t.plan(2); | ||
@@ -1448,4 +1448,4 @@ | ||
var x = righto.from(makeRighto, 5), | ||
y = righto.from(makePromise, 10); | ||
var x = righto.sync(makeRighto, 5), | ||
y = righto.sync(makePromise, 10); | ||
@@ -1458,3 +1458,3 @@ righto.mate(x, y)(function(error, x, y){ | ||
test('from tasks with eventual args', function(t){ | ||
test('sync tasks with eventual args', function(t){ | ||
t.plan(1); | ||
@@ -1472,3 +1472,3 @@ | ||
var result = righto.from(makeRighto, x); | ||
var result = righto.sync(makeRighto, x); | ||
@@ -1480,22 +1480,34 @@ result(function(error, x){ | ||
test('from promise lazy executes', function(t){ | ||
t.plan(2); | ||
test('sync promise lazy executes', function(t){ | ||
t.plan(3); | ||
var ran; | ||
function makePromise(){ | ||
function makePromise(x){ | ||
return new Promise(function(resolve){ | ||
ran = true; | ||
resolve(); | ||
resolve(x); | ||
}); | ||
} | ||
var result = righto.from(makePromise); | ||
var result = righto.sync(makePromise, 1); | ||
t.notOk(ran, 'Promise has not run by now'); | ||
result(function(){ | ||
result(function(error, value){ | ||
t.equal(value, 1); | ||
t.ok(ran, 'Promise has run by now'); | ||
}); | ||
}); | ||
test('from wrap function', function(t){ | ||
t.plan(1); | ||
function something(){} | ||
var result = righto.from(something); | ||
result(function(error, result){ | ||
t.equal(result, something, 'Wrapped a function in a righto'); | ||
}); | ||
}); | ||
@@ -1502,0 +1514,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
71108
1821
752