Skip to content

Commit

Permalink
Update sanctuary-type-identifiers to version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaq committed May 5, 2020
1 parent 83b0894 commit 87a3eda
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
],
"dependencies": {
"sanctuary-show": "^2.0.0",
"sanctuary-type-identifiers": "^2.0.0"
"sanctuary-type-identifiers": "^3.0.0"
},
"devDependencies": {
"c8": "^7.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/future.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export function isFuture(x){
return x instanceof Future || type(x) === $$type;
}

// Compliance with sanctuary-type-identifiers versions 1 and 2.
// To prevent sanctuary-type-identifiers version 3 from identifying 'Future'
// as being of the type denoted by $$type, we ensure that
// Future.constructor.prototype is equal to Future.
Future['@@type'] = $$type;
Future.constructor = {prototype: Future};

Future[FL.of] = resolve;
Future[FL.chainRec] = chainRec;

Expand Down
5 changes: 5 additions & 0 deletions src/par.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export function Par (sequential){
var $$type = namespace + '/ConcurrentFuture@' + version;
var zeroInstance = new ConcurrentFuture(never);

// Compliance with sanctuary-type-identifiers versions 1 and 2.
// To prevent sanctuary-type-identifiers version 3 from identifying
// 'Par' as being of the type denoted by $$type, we ensure that
// Par.constructor.prototype is equal to Par.
Par['@@type'] = $$type;
Par.constructor = {prototype: Par};

Par[FL.of] = function Par$of(x){
return new ConcurrentFuture(resolve(x));
Expand Down
2 changes: 2 additions & 0 deletions test/arbitraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const {
jsv.bool,
jsv.falsy,
jsv.constant(new Error('Kapot')),
jsv.constant(Future),
jsv.constant(Par),
tie('anyFunction')
),
any: jsv.oneof(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/0.error.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test('invalidArity constructs a TypeError', function (){
});

var mockType = function (identifier){
return {'constructor': {'@@type': identifier}, '@@show': function (){
return {'@@type': identifier, '@@show': function (){
return 'mockType("' + identifier + '")';
}};
};
Expand Down

0 comments on commit 87a3eda

Please sign in to comment.