Comparing version 3.0.1 to 3.1.0
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -43,3 +41,3 @@ | ||
function Genfun() { | ||
var genfun = this || {}; | ||
var genfun = this || Object.create(Genfun.prototype); | ||
genfun.methods = []; | ||
@@ -268,3 +266,3 @@ genfun.cache = { key: [], methods: [], state: Genfun.UNINITIALIZED }; | ||
function cacheableProto(genfun, arg) { | ||
var dispatchable = dispatchableObject(arg); | ||
var dispatchable = util.dispatchableObject(arg); | ||
if (Object.hasOwnProperty.call(dispatchable, _role2.default.roleKeyName)) { | ||
@@ -340,3 +338,3 @@ for (var j = 0; j < dispatchable[_role2.default.roleKeyName].length; j++) { | ||
args.forEach(function (arg, index) { | ||
getPrecedenceList(dispatchableObject(arg)).forEach(function (obj, hierarchyPosition) { | ||
getPrecedenceList(util.dispatchableObject(arg)).forEach(function (obj, hierarchyPosition) { | ||
findAndRankRoles(obj, hierarchyPosition, index); | ||
@@ -371,26 +369,2 @@ }); | ||
} | ||
/* | ||
* Returns a useful dispatch object for value using a process similar to | ||
* the ToObject operation specified in http://es5.github.com/#x9.9 | ||
*/ | ||
function dispatchableObject(value) { | ||
// To shut up jshint, which doesn't let me turn off this warning. | ||
var Bool = Boolean; | ||
var Num = Number; | ||
var Str = String; | ||
var Obj = Object; | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case 'object': | ||
return value; | ||
case 'boolean': | ||
return new Bool(value); | ||
case 'number': | ||
return new Num(value); | ||
case 'string': | ||
return new Str(value); | ||
default: | ||
return new Obj(value); | ||
} | ||
} | ||
module.exports = exports['default']; |
@@ -49,2 +49,3 @@ 'use strict'; | ||
object = Object.hasOwnProperty.call(tmpSelector, i) ? tmpSelector[i] : Object.prototype; | ||
object = util.dispatchableObject(object); | ||
if (typeof object === 'function' && !object.genfun) { | ||
@@ -51,0 +52,0 @@ object = object.prototype; |
@@ -6,3 +6,7 @@ 'use strict'; | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
exports.isObjectProto = isObjectProto; | ||
exports.dispatchableObject = dispatchableObject; | ||
/* | ||
@@ -23,2 +27,41 @@ * XXX HACK Firefox gives weird errors where the global | ||
return !hasDefineProperty || Object.hasOwnProperty.call(obj, prototestKeyName); | ||
} | ||
var _null = {}; | ||
var _undefined = {}; | ||
var Bool = Boolean; | ||
var Num = Number; | ||
var Str = String; | ||
var boolCache = { | ||
true: new Bool(true), | ||
false: new Bool(false) | ||
}; | ||
var numCache = {}; | ||
var strCache = {}; | ||
/* | ||
* Returns a useful dispatch object for value using a process similar to | ||
* the ToObject operation specified in http://es5.github.com/#x9.9 | ||
*/ | ||
function dispatchableObject(value) { | ||
// To shut up jshint, which doesn't let me turn off this warning. | ||
var Obj = Object; | ||
if (value === null) { | ||
return _null; | ||
} | ||
if (value === undefined) { | ||
return _undefined; | ||
} | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case 'object': | ||
return value; | ||
case 'boolean': | ||
return boolCache[value]; | ||
case 'number': | ||
return numCache[value] || (numCache[value] = new Num(value)); | ||
case 'string': | ||
return strCache[value] || (strCache[value] = new Str(value)); | ||
default: | ||
return new Obj(value); | ||
} | ||
} |
@@ -25,3 +25,3 @@ { | ||
"main": "lib/genfun.js", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"license": "CC0-1.0", | ||
@@ -41,7 +41,10 @@ "files": [ | ||
"scripts": { | ||
"preversion": "npm t", | ||
"postversion": "npm publish && git push --follow-tags", | ||
"build": "babel --presets es2015 --plugins add-module-exports src --out-dir lib", | ||
"prepublish": "npm run build", | ||
"test": "standard src/*.js && npm run build && nyc -- mocha --reporter spec" | ||
"pretest": "standard src/*.js", | ||
"test": "npm run build && nyc -- mocha --reporter spec" | ||
}, | ||
"dependencies": {} | ||
} |
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
25360
484