diff --git a/.prettierrc b/.prettierrc index 5787090..114615b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { "trailingComma": "none", "arrowParens": "always", - "printWidth": 80, + "printWidth": 70, "bracketSpacing": true, "jsxBracketSameLine": true, "tabWidth": 2, diff --git a/dist/index.js b/dist/index.js index c941a67..e6534e2 100755 --- a/dist/index.js +++ b/dist/index.js @@ -67,6 +67,12 @@ else if (freeModule) { var EDGE_DOT_RE = /^\.|\.$/g; var POS1 = '.$1'; var EMP = ''; + var getType = function (obj) { + return Object.prototype.toString + .call(obj) + .slice(8, -1) + .toLowerCase(); + }; var normalize = function (path) { return path .replace(INDEXES_PATH_RE, POS1) @@ -122,7 +128,12 @@ else if (freeModule) { var result; for (key in inObject) { if (hasOwn.call(inObject, key)) { - result = inCallback.call(inContext, key, inObject[key], inObject); + result = inCallback.call( + inContext, + key, + inObject[key], + inObject + ); if (result === nx.BREAKER) { break; } @@ -134,8 +145,13 @@ else if (freeModule) { var key, length; var iterator = function (inKey, inValue, inIsArray) { return ( - inCallback.call(inContext, inKey, inValue, inTarget, inIsArray) === - nx.BREAKER + inCallback.call( + inContext, + inKey, + inValue, + inTarget, + inIsArray + ) === nx.BREAKER ); }; @@ -252,13 +268,14 @@ else if (freeModule) { nx.createOverload = function () { var fnCacheMap = {}; - function overload() { var args = Array.prototype.slice.call(arguments); - var key = args.map((item) => typeof item).join(); + var key = args.map(getType).join(); var fn = fnCacheMap[key]; if (!fn) { - throw new Error('No matching function, parameter type: [' + key + ']'); + throw new Error( + 'No matching function, parameter type: [' + key + ']' + ); } return fn.apply(this, args); } diff --git a/dist/index.min.js b/dist/index.min.js index 946a652..72cb859 100755 --- a/dist/index.min.js +++ b/dist/index.min.js @@ -1 +1 @@ -!function(){var a,n,s,i,e,_,o,r,c,f,t="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,t=t||u||Function("return this")(),u="object"==typeof exports&&exports&&!exports.nodeType&&exports,p=u&&"object"==typeof module&&module&&!module.nodeType&&module,h=t.nx=t.nx||{BREAKER:{},NIL:{},VERSION:"1.1.11",DEBUG:!1,GLOBAL:t};function l(t){return t.replace(e,".$1").replace(_,a).replace(o,"")}function d(){}function y(t,e){this.type=t,this.meta=e,this.base=e.extends||h.RootClass,this.$base=this.base.prototype,this.__class_meta__={},this.__class__=null,this.__constructor__=null}"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.nx=h,define(function(){return h})):p?((p.exports=h).nx=h,u.nx=h):t.nx=h,a=".",n="undefined",s=Array.prototype,i=Object.prototype.hasOwnProperty,e=/\[(\w+)\]/g,_=/[.]+/g,o=/^\.|\.$/g,h.noop=function(){},h.stubTrue=function(){return!0},h.stubFalse=function(){return!1},h.stubValue=function(t){return t},h.stubPromise=function(t){return Promise.resolve(t)},h.error=function(t){throw new Error(t)},h.try=function(t,e){e=e||h.noop;try{t()}catch(t){e(t)}},h.forEach=function(t,e,_){for(var s=t.length,n=0;ntypeof t).join(),_=s[e];if(_)return _.apply(this,t);throw new Error("No matching function, parameter type: ["+e+"]")}return t.add=t=>{var e=t.args,t=t.fn,e=e.join();if("function"!=typeof t)throw new Error("The fn must be a function");s[e]=t},t},p={__class_id__:0,__type__:"nx.RootClass",__base__:Object,__meta__:{},__static__:!1,__statics__:{},__properties__:{},__methods__:{},__method_init__:h.noop,__static_init__:h.noop},u={base:function(){var t=this.base.caller;if(t&&(t=t.__base__))return t.apply(this,arguments)},parent:function(t){var e=void 0===this.__id__,_=h.slice(arguments,1),s=e?this.__base__:this.__base__.prototype,e=this["@"+t].__type__,n=["get","set"][_.length];switch(e){case"method":return s[t].apply(this,_);case"property":return s["@"+t][n].apply(this,_)}}},p.__methods__=d.prototype=h.mix({constructor:d,init:h.noop,destroy:h.noop,toString:function(){return"[Class@"+this.__type__+"]"}},u),h.mix(p.__statics__,u),h.mix(d,p),h.mix(d,p.__statics__),h.RootClass=d,h.defineProperty=function(t,e,_,s){var n,o,i,r="@"+e,c=_&&"object"==typeof _?_:{value:_},c="value"in c?(o=c.value,i="_"+e,n=function(){return i in this?this[i]:"function"==typeof o?o.call(this):o},function(t){this[i]=t}):(n=_.get||t[r]&&t[r].get||h.noop,_.set||t[r]&&t[r].set||h.noop);return r in t&&(n.__base__=t[r].get,c.__base__=t[r].set),r=t[r]={__meta__:_,__name__:e,__type__:"property",__static__:!!s,get:n,set:c,configurable:!0},Object.defineProperty(t,e,r),r},h.defineMethod=function(t,e,_,s){var n="@"+e;return t[e]=_,t[n]={__meta__:_,__name__:e,__type__:"method",__static__:!!s}},h.defineBombMethod=function(_,t,s,n){t.split(",").forEach(function(t,e){h.defineMethod(_,t,s.call(_,t,e),n)})},h.defineMembers=function(_,s,t,n){h.forIn(t,function(t,e){-1{var e=t.args,t=t.fn,e=e.join();if("function"!=typeof t)throw new Error("The fn must be a function");n[e]=t},t},p={__class_id__:0,__type__:"nx.RootClass",__base__:Object,__meta__:{},__static__:!1,__statics__:{},__properties__:{},__methods__:{},__method_init__:l.noop,__static_init__:l.noop},f={base:function(){var t=this.base.caller;if(t&&(t=t.__base__))return t.apply(this,arguments)},parent:function(t){var e=void 0===this.__id__,_=l.slice(arguments,1),n=e?this.__base__:this.__base__.prototype,e=this["@"+t].__type__,s=["get","set"][_.length];switch(e){case"method":return n[t].apply(this,_);case"property":return n["@"+t][s].apply(this,_)}}},p.__methods__=y.prototype=l.mix({constructor:y,init:l.noop,destroy:l.noop,toString:function(){return"[Class@"+this.__type__+"]"}},f),l.mix(p.__statics__,f),l.mix(y,p),l.mix(y,p.__statics__),l.RootClass=y,l.defineProperty=function(t,e,_,n){var s,o,i,r="@"+e,c=_&&"object"==typeof _?_:{value:_},c="value"in c?(o=c.value,i="_"+e,s=function(){return i in this?this[i]:"function"==typeof o?o.call(this):o},function(t){this[i]=t}):(s=_.get||t[r]&&t[r].get||l.noop,_.set||t[r]&&t[r].set||l.noop);return r in t&&(s.__base__=t[r].get,c.__base__=t[r].set),r=t[r]={__meta__:_,__name__:e,__type__:"property",__static__:!!n,get:s,set:c,configurable:!0},Object.defineProperty(t,e,r),r},l.defineMethod=function(t,e,_,n){var s="@"+e;return t[e]=_,t[s]={__meta__:_,__name__:e,__type__:"method",__static__:!!n}},l.defineBombMethod=function(_,t,n,s){t.split(",").forEach(function(t,e){l.defineMethod(_,t,n.call(_,t,e),s)})},l.defineMembers=function(_,n,t,s){l.forIn(t,function(t,e){-1 typeof item).join(); + var key = args.map(getType).join(); var fn = fnCacheMap[key]; if (!fn) { - throw new Error('No matching function, parameter type: [' + key + ']'); + throw new Error( + 'No matching function, parameter type: [' + key + ']' + ); } return fn.apply(this, args); }