Comparing version 0.2.0 to 0.2.1
@@ -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 @@ |
@@ -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: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122639
21
1998
423