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

overload2

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overload2 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

test/ambiguous.js

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # overload2

## [0.2.1] - 2017-09
### Fixed
* In the previous version, if argument is valued with null / undefined and param is not defined with NULL / UNDEFINED, overload2 will conclude that the argument and the param are not matching, even if the param's datatype accepts null / undefined. It is really ambiguous and has been corrected in this version.
## [0.2.0] - 2017-06, Mutable Param

@@ -7,0 +13,0 @@

11

overload2.js

@@ -392,4 +392,7 @@ /**

Param.prototype.satisfy = function(value) {
if (value === null && this.nil) return true;
if (value === undefined && this.undef) return true;
// if (value === null && this.nil) return true;
// if (value === undefined && this.undef) return true;
if (value === null) return this.nil;
if (value === undefined) return this.undef;
return this.type.match(value);

@@ -672,3 +675,3 @@ };

for (var i = 0, type; i < args.length; i++) {
type = typeof args[i];
type = (args[i] === null) ? 'null' : typeof args[i];
if (type === 'object') type = args[i].constructor.name;

@@ -704,3 +707,2 @@ types.push(type);

if (arguments.length > 2) {
console.warn('redundant arguments found');
}

@@ -720,3 +722,2 @@ }

if (arguments.length > 1) {
console.warn('redundant arguments found');
}

@@ -723,0 +724,0 @@ this._defaultMethod = method;

{
"name": "overload2",
"version": "0.2.0",
"version": "0.2.1",
"description": "Elegant solution for function overloading in JavaScript",
"main": "overload2.js",
"directories": {
"test": "./node_modules/.bin/mocha"
"test": "test"
},

@@ -23,3 +23,5 @@ "scripts": {

"constructor-overloading",
"strongly-typed"
"strongly-typed",
"signatures",
"function-signatures"
],

@@ -26,0 +28,0 @@ "author": "youngoat@163.com",

@@ -138,10 +138,11 @@ # overload2

| Predefined Data Type | Remark |
| :-------------------------- | :------------- |
| __overload2.Type.ANY__ | Anything. |
| __overload2.Type.BOOLEAN__ | It must be `true` or `false`, anything else including instance of `Boolean` is unmatched. |
| __overload2.Type.CHAR__ | A string whose length equals 1, e.g. "a" |
| __overload2.Type.NUMBER__ | A number, but NOT instance of `Number`. |
| __overload2.Type.SCALAR__ | A number, string or boolean, but NOT instance of `Number`, `String` or `Boolean`. |
| __overload2.Type.STRING__ | A string, but NOT instance of `String`. |
| Predefined Data Type | Remark |
| :---------------------------- | :------------- |
| __overload2.Type.ANY__ | Anything. |
| __overload2.Type.BOOLEAN__ | It must be `true` or `false`, anything else including instance of `Boolean` is unmatched. |
| __overload2.Type.CHAR__ | A string whose length equals 1, e.g. "a" |
| __overload2.Type.NUMBER__ | A number, but NOT instance of `Number`. |
| __overload2.Type.PLAIN_OBJECT__ | An object whose constructor is `Object` instead of anything else. |
| __overload2.Type.SCALAR__ | A number, string or boolean, but NOT instance of `Number`, `String` or `Boolean`. |
| __overload2.Type.STRING__ | A string, but NOT instance of `String`. |

@@ -148,0 +149,0 @@ ATTENTION:

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