Completed
Push — master ( 734acd...e65e46 )
by Pieter Epeüs
13s queued 10s
created

dist/helpers.js   B

Complexity

Total Complexity 45
Complexity/F 1.36

Size

Lines of Code 1
Function Count 33

Duplication

Duplicated Lines 1
Ratio 100 %

Importance

Changes 0
Metric Value
wmc 45
eloc 1
mnd 12
bc 12
fnc 33
dl 1
loc 1
rs 8.8
bpm 0.3636
cpm 1.3636
noi 59
c 0
b 0
f 0

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complexity

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like dist/helpers.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
function t(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function r(r,n,e){return n&&t(r.prototype,n),e&&t(r,e),r}function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function e(t,r){return(e=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function o(t,r,n){return(o=i()?Reflect.construct:function(t,r,n){var i=[null];i.push.apply(i,r);var o=new(Function.bind.apply(t,i));return n&&e(o,n.prototype),o}).apply(null,arguments)}function u(t){var r="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,i)}function i(){return o(t,arguments,n(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),e(i,t)})(t)}var c=function(){function t(t,r){this.key=t,this.moveDirection="desc"===r?-1:1}var r=t.prototype;return r.order=function(t){return t.sort(this.compare.bind(this))},r.compare=function(t,r){var n=t[this.key],e=r[this.key];return"string"==typeof n&&(n=n.toUpperCase()),"string"==typeof e&&(e=e.toUpperCase()),n<e?-1*this.moveDirection:n>e?1*this.moveDirection:0},t.create=function(r,n,e){return new t(n,e).order(r)},t}();function f(t,r,n){return c.create(t,r,n)}function s(t){return"object"!=typeof t||t.length<1?null:t.reduce(function(t,r){return Math.min(t,r)})}function a(t){return"object"!=typeof t||t.length<1?null:t.reduce(function(t,r){return Math.max(t,r)})}var h=function(){function t(t,r){this.find=t,this.operator=r||null}var r=t.prototype;return r.check=function(t){return Array.isArray(this.find)?this.checkOperators(t,this.find.indexOf(t)<0):this.checkOperators(t,String(t)!==String(this.find))},r.checkOperators=function(t,r){var n=a(this.find),e=s(this.find),i=null!==n,o=null!==e;return r&&("!="===this.operator||"<>"===this.operator)||!r&&!this.operator||(t>n&&i||t>this.find)&&">"===this.operator||(t>=n&&i||t>=this.find)&&">="===this.operator||(t<e&&o||t<this.find)&&"<"===this.operator||(t<=e&&o||t<=this.find)&&"<="===this.operator},t.create=function(r,n,e,i){var o=new t(e,i);return r.filter(function(t){var r=t[n];return!!r&&(r=r.toString().split(",")).some(o.check.bind(o))})},t}();function p(t,r,n,e){return h.create(t,r,n,e)}function l(t,r){return t.map(function(t){var n={};return"object"==typeof r?(r.forEach(function(r){n[r]=t[r]}),n):t[r]})}function y(t,r,n){return t.filter(function(t){return n?r.reduce(function(r,n){return n.indexOf(t)>=0?r+1:r},0)===r.length:r.indexOf(t)>=0})}var d=function(){function t(t,r,n){this.currentArray=t,this.otherArray=r,this.total=n}return t.create=function(r,n,e){return new t(r,n,e).compare},r(t,[{key:"differenceArray",get:function(){var t=this;return this.currentArray.filter(function(r){return t.otherArray.indexOf(r)<0})}},{key:"differenceArrayB",get:function(){var t=this;return this.total?this.otherArray.filter(function(r){return t.currentArray.indexOf(r)<0}):[]}},{key:"compare",get:function(){return this.differenceArray.concat(this.differenceArrayB)}}]),t}();function g(t,r,n){return d.create(t,r,n)}function m(t){return t.filter(function(t,r,n){return n.indexOf(t)===r})}function v(t){return!Array.isArray(t)||t.length<1?null:t.reduce(function(t,r){return t+r},0)}function x(t){return!Array.isArray(t)||t.length<1?null:v(t)/t.length}function O(t){var r=t.length;return t[Math.floor(Math.random()*(r-0))+0]}function b(t,r,n){for(var e=r.split("."),i=t;e.length>0;){var o=e.shift();if(null==i||!Object.prototype.hasOwnProperty.call(i,o))return n;i=i[o]}return i}function k(t){return!Array.isArray(t)||t.length<1?null:t[0]}function A(t){return!Array.isArray(t)||t.length<1?null:t[t.length-1]}exports.Arr=function(t){var n,e;function i(){return t.apply(this,arguments)||this}e=t,(n=i).prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var o=i.prototype;return o.multisort=function(t,r){return f(this[0],t,r)},o.multifilter=function(t,r,n){return p(this[0],t,r,n)},o.multikey=function(t){return l(this[0],t)},o.intersect=function(t,r){return y(this[0],t,r)},o.diff=function(t,r){return g(this[0],t,r)},o.pushIfNotExists=function(t){return this.indexOf(t)<0&&this.push(t),this.length},o.pushMultiple=function(t){return this.push.apply(this,t),this.length},o.pushMultipleIfNotExists=function(t){var r=this;return t.forEach(function(t){r.pushIfNotExists(t)}),r.length},o.getByKey=function(t,r){return b(this[0],t,r)},r(i,[{key:"unique",get:function(){return m(this[0])}},{key:"max",get:function(){return a(this[0])}},{key:"min",get:function(){return s(this[0])}},{key:"random",get:function(){return O(this)}},{key:"summ",get:function(){return v(this[0])}},{key:"average",get:function(){return x(this[0])}},{key:"first",get:function(){return k(this[0])}},{key:"last",get:function(){return A(this[0])}}],[{key:Symbol.species,get:function(){return Array}}]),i}(u(Array)),exports.average=x,exports.diff=g,exports.first=k,exports.getByKey=b,exports.intersect=y,exports.last=A,exports.max=a,exports.min=s,exports.multifilter=p,exports.multikey=l,exports.multisort=f,exports.random=O,exports.summ=v,exports.unique=m;
2
//# sourceMappingURL=helpers.js.map
3