Skip to content

Commit

Permalink
chore: update sanctuary (ramda#3422)
Browse files Browse the repository at this point in the history
  • Loading branch information
ridge-kimani authored Nov 16, 2023
1 parent 73789d6 commit 4261fb1
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 100 deletions.
74 changes: 21 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@
"rimraf": "^5.0.5",
"rollup": "^1.32.1",
"rollup-plugin-uglify": "^6.0.4",
"sanctuary": "^0.7.x",
"sanctuary": "^3.1.0",
"sanctuary-identity": "^2.1.0",
"sanctuary3": "npm:sanctuary@^3.1.0",
"sinon": "^7.3.2",
"testem": "^3.10.1",
"xyz": "^4.0.0"
Expand Down
10 changes: 4 additions & 6 deletions test/both.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S = require('sanctuary');
const { Just, Nothing } = require('sanctuary');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');
Expand Down Expand Up @@ -32,13 +32,11 @@ describe('both', function() {
});

it('accepts fantasy-land applicative functors', function() {
var Just = S.Just;
var Nothing = S.Nothing;
eq(R.both(Just(true), Just(true)), Just(true));
eq(R.both(Just(true), Just(false)), Just(false));
eq(R.both(Just(true), Nothing()), Nothing());
eq(R.both(Nothing(), Just(false)), Nothing());
eq(R.both(Nothing(), Nothing()), Nothing());
eq(R.both(Just(true), Nothing), Nothing);
eq(R.both(Nothing, Just(false)), Nothing);
eq(R.both(Nothing, Nothing), Nothing);
});

});
6 changes: 2 additions & 4 deletions test/complement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S = require('sanctuary');
const { Nothing, Just} = require('sanctuary');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');
Expand All @@ -20,11 +20,9 @@ describe('complement', function() {
});

it('accepts fantasy-land functors', function() {
var Just = S.Just;
var Nothing = S.Nothing;
eq(R.complement(Just(true)), Just(false));
eq(R.complement(Just(false)), Just(true));
eq(R.complement(Nothing()), Nothing());
eq(R.complement(Nothing), Nothing);
});

});
11 changes: 4 additions & 7 deletions test/either.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S = require('sanctuary');
const { Nothing, Just } = require('sanctuary');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');
Expand Down Expand Up @@ -32,14 +32,11 @@ describe('either', function() {
});

it('accepts fantasy-land applicative functors', function() {
var Just = S.Just;
var Nothing = S.Nothing;
eq(R.either(Just(true), Just(true)), Just(true));
eq(R.either(Just(true), Just(false)), Just(true));
eq(R.either(Just(false), Just(false)), Just(false));
eq(R.either(Just(true), Nothing()), Nothing());
eq(R.either(Nothing(), Just(false)), Nothing());
eq(R.either(Nothing(), Nothing()), Nothing());
eq(R.either(Just(true), Nothing), Nothing);
eq(R.either(Nothing, Just(false)), Nothing);
eq(R.either(Nothing, Nothing), Nothing);
});

});
4 changes: 2 additions & 2 deletions test/of.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S = require('sanctuary');
const { Maybe, Just } = require('sanctuary');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');
Expand All @@ -14,6 +14,6 @@ describe('of', function() {
});

it('dispatches to an available of method', function() {
eq(R.of(S.Maybe, 100), S.Just(100));
eq(R.of(Maybe, 100), Just(100));
});
});
10 changes: 5 additions & 5 deletions test/partition.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S = require('sanctuary');
var { Nothing, Just } = require('sanctuary');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');
Expand Down Expand Up @@ -28,11 +28,11 @@ describe('partition', function() {
});

it('works with other filterables', function() {
eq(R.partition(R.isEmpty, S.Just(3)),
[S.Nothing(), S.Just(3)]
eq(R.partition(R.isEmpty, Just(3)),
[Nothing, Just(3)]
);
eq(R.partition(R.complement(R.isEmpty), S.Just(3)),
[S.Just(3), S.Nothing()]
eq(R.partition(R.complement(R.isEmpty), Just(3)),
[Just(3), Nothing]
);
});

Expand Down
20 changes: 9 additions & 11 deletions test/sequence.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var S = require('sanctuary');
const { Right, Left, Either, Just, Nothing } = require('sanctuary3');
const { Right, Left, Either, Just, Nothing, Maybe } = require('sanctuary');
var Id = require('sanctuary-identity');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');

var ofArray = R.of(Array);
var ofEither = R.of(S.Either);
var ofMaybe = R.of(S.Maybe);
var ofEither = R.of(Either);
var ofMaybe = R.of(Maybe);

describe('sequence', function() {

Expand All @@ -21,15 +20,15 @@ describe('sequence', function() {
});

it('operates on a list of applicatives', function() {
eq(R.sequence(ofMaybe, [S.Just(3), S.Just(4), S.Just(5)]), S.Just([3, 4, 5]));
eq(R.sequence(ofMaybe, [S.Just(3), S.Nothing(), S.Just(5)]), S.Nothing());
eq(R.sequence(ofMaybe, [Just(3), Just(4), Just(5)]), Just([3, 4, 5]));
eq(R.sequence(ofMaybe, [Just(3), Nothing, Just(5)]), Nothing);
});

it('traverses left to right', function() {
eq(R.sequence(ofEither, [S.Right(1), S.Right(2)]), S.Right([1, 2]));
eq(R.sequence(ofEither, [S.Right(1), S.Left('XXX')]), S.Left('XXX'));
eq(R.sequence(ofEither, [S.Left('XXX'), S.Right(1)]), S.Left('XXX'));
eq(R.sequence(ofEither, [S.Left('XXX'), S.Left('YYY')]), S.Left('XXX'));
eq(R.sequence(ofEither, [Right(1), Right(2)]), Right([1, 2]));
eq(R.sequence(ofEither, [Right(1), Left('XXX')]), Left('XXX'));
eq(R.sequence(ofEither, [Left('XXX'), Right(1)]), Left('XXX'));
eq(R.sequence(ofEither, [Left('XXX'), Left('YYY')]), Left('XXX'));
});

it('dispatches to `traverse` method', function() {
Expand All @@ -42,5 +41,4 @@ describe('sequence', function() {
eq(R.sequence(Either, Just(Left('X'))), Left('X'));
eq(R.sequence(Either, Nothing), Right(Nothing));
});

});
19 changes: 9 additions & 10 deletions test/traverse.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var S = require('sanctuary');
const { Right, Left, Either, Maybe, Just, Nothing } = require('sanctuary3');
const { Right, Left, Either, Maybe, Just, Nothing } = require('sanctuary');
var Id = require('sanctuary-identity');

var R = require('../source/index.js');
var eq = require('./shared/eq.js');

var ofArray = R.of(Array);
var ofEither = R.of(S.Either);
var ofMaybe = R.of(S.Maybe);
var ofEither = R.of(Either);
var ofMaybe = R.of(Maybe);


describe('traverse', function() {
Expand All @@ -22,8 +21,8 @@ describe('traverse', function() {
});

it('operates on a list of applicatives', function() {
eq(R.traverse(ofMaybe, R.map(R.add(10)), [S.Just(3), S.Just(4), S.Just(5)]), S.Just([13, 14, 15]));
eq(R.traverse(ofMaybe, R.map(R.add(10)), [S.Just(3), S.Nothing(), S.Just(5)]), S.Nothing());
eq(R.traverse(ofMaybe, R.map(R.add(10)), [Just(3), Just(4), Just(5)]), Just([13, 14, 15]));
eq(R.traverse(ofMaybe, R.map(R.add(10)), [Just(3), Nothing, Just(5)]), Nothing);
});

it('operates on a list of FL-applicatives', function() {
Expand All @@ -33,10 +32,10 @@ describe('traverse', function() {
});

it('traverses left to right', function() {
eq(R.traverse(ofEither, R.identity, [S.Right(1), S.Right(2)]), S.Right([1, 2]));
eq(R.traverse(ofEither, R.identity, [S.Right(1), S.Left('XXX')]), S.Left('XXX'));
eq(R.traverse(ofEither, R.identity, [S.Left('XXX'), S.Right(1)]), S.Left('XXX'));
eq(R.traverse(ofEither, R.identity, [S.Left('XXX'), S.Left('YYY')]), S.Left('XXX'));
eq(R.traverse(ofEither, R.identity, [Right(1), Right(2)]), Right([1, 2]));
eq(R.traverse(ofEither, R.identity, [Right(1), Left('XXX')]), Left('XXX'));
eq(R.traverse(ofEither, R.identity, [Left('XXX'), Right(1)]), Left('XXX'));
eq(R.traverse(ofEither, R.identity, [Left('XXX'), Left('YYY')]), Left('XXX'));
});

it('dispatches to `traverse` method', function() {
Expand Down

0 comments on commit 4261fb1

Please sign in to comment.