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

righto

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

righto - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

41

CHANGELOG.md

@@ -0,3 +1,42 @@

# V5
`righto.reduce` is now more reasonable, and will now always treat the first parameter as an array of values/eventuals, rather than assuming they were functions to be called with righto. Migration is trivial:
## Old style:
```javascript
function a(callback){
callback(null, 1);
}
function b(callback){
callback(null, 2);
}
// Old style:
var result = righto.reduce([a, b]);
// New style: wrap the tasks as eventuals:
var result = righto.reduce([righto(a), righto(b)]);
```
if you need to pass values to each task, use a custom reducer:
## Old style:
```javascript
function a(lastResult, callback){
callback(null, lastResult + 1);
}
function b(lastResult, callback){
callback(null, lastResult + 2);
}
// Old style:
var result = righto.reduce([a, b]);
// New style: a reducer that passes the result into the next function:
var result = righto.reduce([a, b], (result, next) => righto(next, result));
```
# V4
`righto.from` is now more reasonable, and will always either return a righto passed to it, or return a righto that resolves that value passed.

@@ -4,0 +43,0 @@ This means it can no longer be used to call promise-returning functions, but that is already available with `righto.sync`

2

index.js

@@ -446,3 +446,3 @@ var abbott = require('abbott');

if(!hasSeed){
seed = righto(values.shift());
seed = values.shift();
}

@@ -449,0 +449,0 @@

{
"name": "righto",
"version": "4.0.0",
"version": "5.0.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "directories": {

@@ -257,3 +257,3 @@ # Righto

righto.reduce takes N tasks, or an Array of tasks as the first argument,
righto.reduce takes an Array of values (an an eventual that resolves to an array) as the first argument,
resolves them from left-to-right, optionally passing the result of the last, and the next task to a reducer.

@@ -280,3 +280,3 @@

var result = righto.reduce([a, b]);
var result = righto.reduce([righto(a), righto(b)]);

@@ -283,0 +283,0 @@ result(function(error, finalResult){

@@ -350,26 +350,2 @@ var test = require('tape'),

test('righto.reduce', function(t){
t.plan(4);
var aCalled;
function a(callback){
aCalled = true;
t.pass('a called');
callback(null, 1);
}
function b(callback){
t.ok(aCalled, 'b called after a');
callback(null, 2);
}
var result = righto.reduce([a, b]);
result(function(error, finalResult){
t.notOk(error, 'no error');
t.equal(finalResult, 2, 'Got correct final result');
});
});
test('righto.reduce eventuals', function(t){

@@ -438,2 +414,15 @@ t.plan(4);

test('righto.reduce with values custom reducer no seed', function(t){
t.plan(2);
var result = righto.reduce([1, 2, 3], function(result, next){
return righto.sync((a) => a + next, result);
});
result(function(error, finalResult){
t.notOk(error, 'no error');
t.deepEqual(finalResult, 6, 'Got correct final result');
});
});
test('righto.reduce no items', function(t){

@@ -440,0 +429,0 @@ t.plan(2);

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