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

union-type

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

union-type - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

.tern-port

2

package.json
{
"name": "union-type",
"version": "0.3.2",
"version": "0.3.3",
"description": "Union types for JavaScript",

@@ -5,0 +5,0 @@ "main": "union-type.js",

@@ -47,3 +47,3 @@ var assert = require('assert');

Age.Age('12');
}, /bad value/);
}, /wrong value/);
});

@@ -68,3 +68,3 @@ it('throws on too many arguments', function() {

Exists.Exists('12');
}, /bad value/);
}, /wrong value/);
});

@@ -75,13 +75,13 @@ });

var Shape = Type({Shape: [Type.ListOf(Point)]}).Shape;
assert.throws(function(){
Shape([1,Point.Point(1,2),3]);
assert.throws(function() {
Shape([1, Point.Point(1,2), 3]);
}, /wrong value 1 passed to location first in List/);
assert.throws(function(){
Shape([Point.Point(1,2), Point.Point('3',1)]);
}, /wrong value 3 passed to location first in Point/);
Shape([Point.Point(1,2), Point.Point(1,2)]);
assert.throws(function() {
Shape([Point.Point(1, 2), Point.Point('3', 1)]);
}, /wrong value/);
Shape([Point.Point(1, 2), Point.Point(1, 2)]);
Shape([]);
assert.throws(function(){
assert.throws(function() {
Shape("not a List")
}, /wrong value not a List passed to location first in List/);
}, /wrong value/);
});

@@ -186,2 +186,11 @@ it('nest types', function() {

});
it('does not throw with Type.check = false if no case handler found', function() {
Type.check = false;
Action.case({
Translate: function(x, y) {
return x + y;
}
}, Action.Rotate(90));
Type.check = true;
});
});

@@ -188,0 +197,0 @@ describe('caseOn', function() {

@@ -39,3 +39,3 @@ var curryN = require('ramda/src/curryN');

var strVal = typeof v === 'string' ? "'" + v + "'" : v; // put the value in quotes if it's a string
throw new TypeError('bad value ' + strVal + ' passed as ' + numToStr[i] + ' argument to constructor ' + name);
throw new TypeError('wrong value ' + strVal + ' passed as ' + numToStr[i] + ' argument to constructor ' + name);
}

@@ -100,6 +100,8 @@ }

}
var args = wildcard === true ? [arg]
: arg !== undefined ? valueToArray(value).concat([arg])
: valueToArray(value);
return handler.apply(undefined, args);
if (handler !== undefined) {
var args = wildcard === true ? [arg]
: arg !== undefined ? valueToArray(value).concat([arg])
: valueToArray(value);
return handler.apply(undefined, args);
}
}

@@ -130,4 +132,4 @@

obj.prototype[Symbol ? Symbol.iterator : '@@iterator'] = createIterator;
obj.prototype.case = function (cases) { return obj.case(cases, this); }
obj.prototype.caseOn = function (cases) { return obj.caseOn(cases, this); }
obj.prototype.case = function (cases) { return obj.case(cases, this); };
obj.prototype.caseOn = function (cases) { return obj.caseOn(cases, this); };

@@ -147,8 +149,8 @@ for (key in desc) {

List: function (array) {
try{
try {
for(var n = 0; n < array.length; n++) {
innerType(array[n])
innerType(array[n]);
}
} catch (e) {
throw TypeError('wrong value '+array[n]+' passed to location '+numToStr[n]+' in List')
throw new TypeError('wrong value '+ array[n] + ' passed to location ' + numToStr[n] + ' in List');
}

@@ -159,4 +161,4 @@ return true;

return compose(validate, List.List);
}
};
module.exports = Type;
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