| /*! (C) Andrea Giammarchi - MIT Style License */ | ||
| var Class=Class||function(e){"use strict";function N(e,t,n){for(var r,s=[],o=0;o<e.length;o++)r=D(e[o]),p.call(r,i)&&s.push(r[i]),C(r,t,n,!1,!1);return s}function C(e,t,n,r,i){for(var s,o=typeof e!="function",u=y(e),a=0;a<u.length;a++)s=u[a],(o||S.call(E,s)<0)&&M(s,i)&&(p.call(t,s)&&B("duplicated: "+s),P(n,t,s,g(e,s),r))}function k(e,t){var n=function(){};return e&&""+t!=""+n?function(){return t.apply(this,arguments)}:n}function L(e,t,n,r){var i=O(t,r);m(e,t,{enumerable:!1,configurable:i,writable:i,value:n})}function A(e){return e?(e<65||90<e)&&(e<97||122<e)&&e!==95:!0}function O(e,t){return t?!_(e):!0}function M(e,f){return e!==t&&e!==n&&e!==r&&e!==s&&e!==o&&e!==u&&e!==a&&(f||e!==i)}function _(e){for(var t,n=0;n<e.length;n++){t=e.charCodeAt(n);if((t<65||90<t)&&t!==95)return!1}return!0}function D(t){if(typeof t=="object")return t;t.length&&B((t.name||"Class")+" should not expect arguments");for(var n,r,i,s={init:t},o=t.prototype;o&&o!==e.prototype;o=w(o))for(n=0,i=y(o);n<i.length;n++)r=i[n],M(r,!1)&&!p.call(s,r)&&m(s,r,g(o,r));return s}function P(e,t,n,r,i){var s=p.call(r,"value"),o,u;if(i){if(p.call(t,n))return}else s?(u=r.value,typeof u=="function"&&x(u)&&(r.value=j(e,n,u,i))):(F(e,n,r,"get"),F(e,n,r,"set"));o=O(n,i),r.enumerable=!1,r.configurable=o,s&&(r.writable=o),m(t,n,r)}function H(e,t){for(var n,r,i=0;i<e.length;i++){n=e[i];for(r in n)p.call(n,r)&&!p.call(t,r)&&B(r+" is not implemented")}}function B(e){try{console.warn(e)}catch(t){}}function j(e,t,n,r){return function(){p.call(this,u)||L(this,u,null,r);var i=this[u],s=this[u]=e[t],o=n.apply(this,arguments);return this[u]=i,o}}function F(e,t,n,r,i){p.call(n,r)&&x(n[r])&&(n[r]=j(g(e,t),r,n[r],i))}var t="constructor",n="extends",r="implements",i="init",s="prototype",o="static",u="super",a="with",f="__proto__",l=["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],c={}[l[2]]||function(e){for(var t in this)if(e===t)return this.hasOwnProperty(e);return!1},h=!c.call({valueOf:0},l[5]),p=e[l[0]],d=e.create||function(e){var t=this instanceof d;return d[s]=t?v:e,t?this:new d},v=d[s],m=e.defineProperty,g=e.getOwnPropertyDescriptor,y=e.getOwnPropertyNames||function(e){var t=[],n,r;for(r in e)p.call(e,r)&&t.push(r);if(h)for(n=0;n<l.length;n++)r=l[n],p.call(e,r)&&t.push(r);return t},b=e.getPrototypeOf,w=b||function(e){return e[f]||null},E=y(function(){}),S=E.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},x=(""+function(){this["super"]()}).indexOf(u)<0?function(){return!0}:function(e){var t=""+e,n=t.indexOf(u);return n<0?!1:A(t.charCodeAt(n-1))&&A(t.charCodeAt(n+5))};try{m({},"{}",{})}catch(T){"__defineGetter__"in{}?(m=function(e,t,n){return p.call(n,"value")?e[t]=n.value:(p.call(n,"get")&&e.__defineGetter__(t,n.get),p.call(n,"set")&&e.__defineSetter__(t,n.set)),e},g=function(e,t){var n=e.__lookupGetter__(t),r=e.__lookupSetter__(t),i={};return n||r?(n&&(i.get=n),r&&(i.set=r)):i.value=e[t],i}):(m=function(e,t,n){return e[t]=n.value,e},g=function(e,t){return{value:e[t]}})}return function(e){var i=p.call(e,t),u=p.call(e,n),l=u&&e[n],c=u&&typeof l=="function",h=c?l[s]:l,v=i?e[t]:k(c,l),m=u&&i&&x(v),g=u?d(h):v[s],y,w;return m&&(v=j(h,t,v,!1)),p.call(e,a)&&(y=N([].concat(e[a]),g,h),w=y.length,w&&(v=function(e){return function(){var t=0;while(t<w)y[t++].call(this);return e.apply(this,arguments)}}(v),v[s]=g)),p.call(e,o)&&C(e[o],v,h,!0,!0),u&&(l!==h&&C(l,v,h,!0,!0),v[s]=g),g[t]!==v&&L(g,t,v,!1),C(e,g,h,!1,!0),p.call(e,r)&&H([].concat(e[r]),g),u&&!b&&L(g,f,h,!1),v}}(Object); | ||
| var Class=Class||function(e){"use strict";function O(e,t,n){for(var r,s=[],o=0;o<e.length;o++)r=U(e[o]),d.call(r,i)&&s.push(r[i]),D(r,t,n,!1,!1);return s}function M(e){for(var t,n,r,i=v(S(e)),s=x(e),o=0;o<s.length;o++)t=s[o],n=y(e,t),d.call(n,a)&&P(n,M),g(i,t,n);return i}function _(e,t){for(var n,r,i,s,o=x(e),u=0;u<o.length;u++)n=o[u],r=y(e,n),d.call(t,n)?d.call(r,a)&&(i=r[a],q(i)&&(r=y(t,n),d.call(r,a)&&(s=r[a],q(s)&&_(i,s)))):(d.call(r,a)&&P(r,M),g(t,n,r))}function D(e,t,n,r,i){for(var s,o=typeof e!="function",u=x(e),a=0;a<u.length;a++)s=u[a],(o||C.call(N,s)<0)&&I(s,i)&&(d.call(t,s)&&X("duplicated: "+s.toString()),z(n,t,s,y(e,s),r))}function P(e,t){var n=e[a];q(n)&&(e[a]=t(n))}function H(e,t){var n=function(){};return e&&""+t!=""+n?function(){return t.apply(this,arguments)}:n}function B(e,t,n,r){var i=F(t,r);g(e,t,{enumerable:!1,configurable:i,writable:i,value:n})}function j(e){return e?(e<65||90<e)&&(e<97||122<e)&&e!==95:!0}function F(e,t){return t?!R(e):!0}function I(e,a){return e!==t&&e!==n&&e!==r&&e!==s&&e!==o&&e!==u&&e!==f&&(a||e!==i)}function q(e){return e!=null&&typeof e=="object"}function R(e){for(var t,n=0;n<e.length;n++){t=e.charCodeAt(n);if((t<65||90<t)&&t!==95)return!1}return!0}function U(t){if(q(t))return t;var n,r,s,o,u;if(t.isClass){t.length&&X((t.name||"Class")+" should not expect arguments");for(o={init:t},u=t.prototype;u&&u!==e.prototype;u=S(u))for(n=0,s=x(u);n<s.length;n++)r=s[n],I(r,!1)&&!d.call(o,r)&&g(o,r,y(u,r))}else for(n=0,o={},u=t({}),s=x(u);n<s.length;n++)r=s[n],r!==i&&(~r.toString().indexOf("mixin:init")&&T(u[r])?o.init=u[r][0]:g(o,r,y(u,r)));return o}function z(e,n,r,i,s){var o=d.call(i,a),u,f;if(s){if(d.call(n,r)){e&&q(n[r])&&q(e[t][r])&&_(e[t][r],n[r]);return}o&&P(i,M)}else o?(f=i[a],typeof f=="function"&&L(f)&&(i[a]=V(e,r,f,s))):($(e,r,i,"get"),$(e,r,i,"set"));u=F(r,s),i.enumerable=!1,i.configurable=u,o&&(i.writable=u),g(n,r,i)}function W(e,t){for(var n,r,i=0;i<e.length;i++){n=e[i];for(r in n)d.call(n,r)&&!d.call(t,r)&&X(r.toString()+" is not implemented")}}function X(e){try{console.warn(e)}catch(t){}}function V(e,t,n,r){return function(){d.call(this,u)||B(this,u,null,r);var i=this[u],s=this[u]=e[t],o=n.apply(this,arguments);return this[u]=i,o}}function $(e,t,n,r,i){d.call(n,r)&&L(n[r])&&(n[r]=V(y(e,t),r,n[r],i))}var t="constructor",n="extends",r="implements",i="init",s="prototype",o="static",u="super",a="value",f="with",l="__proto__",c=["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],h={}[c[2]]||function(e){for(var t in this)if(e===t)return this.hasOwnProperty(e);return!1},p=!h.call({valueOf:0},c[5]),d=e[c[0]],v=e.create||function(e){var t=this instanceof v;return v[s]=t?m:e,t?this:new v},m=v[s],g=e.defineProperty,y=e.getOwnPropertyDescriptor,b=e.getOwnPropertyNames||function(e){var t=[],n,r;for(r in e)d.call(e,r)&&t.push(r);if(p)for(n=0;n<c.length;n++)r=c[n],d.call(e,r)&&t.push(r);return t},w=e.getOwnPropertySymbols||function(){return[]},E=e.getPrototypeOf,S=E||function(e){return e[l]||null},x=function(e){return b(e).concat(w(e))},T=Array.isArray||function(t){return e[s].toString.call(t)==="[object Array]"},N=b(function(){}).concat("arguments"),C=N.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},k={value:!0},L=(""+function(){this["super"]()}).indexOf(u)<0?function(){return!0}:function(e){var t=""+e,n=t.indexOf(u);return n<0?!1:j(t.charCodeAt(n-1))&&j(t.charCodeAt(n+5))};try{g({},"{}",{})}catch(A){"__defineGetter__"in{}?(g=function(e,t,n){return d.call(n,a)?e[t]=n[a]:(d.call(n,"get")&&e.__defineGetter__(t,n.get),d.call(n,"set")&&e.__defineSetter__(t,n.set)),e},y=function(e,t){var n=e.__lookupGetter__(t),r=e.__lookupSetter__(t),i={};return n||r?(n&&(i.get=n),r&&(i.set=r)):i[a]=e[t],i}):(g=function(e,t,n){return e[t]=n[a],e},y=function(e,t){return{value:e[t]}})}return function(e){var i=d.call(e,t),u=d.call(e,n),a=u&&e[n],c=u&&typeof a=="function",h=c?a[s]:a,p=i?e[t]:H(c,a),m=u&&i&&L(p),y=u?v(h):p[s],b,w;return m&&(p=V(h,t,p,!1)),d.call(e,f)&&(b=O([].concat(e[f]),y,h),w=b.length,w&&(p=function(e){return function(){var t=0;while(t<w)b[t++].call(this);return e.apply(this,arguments)}}(p),p[s]=y)),d.call(e,o)&&D(e[o],p,h,!0,!0),u&&(a!==h&&D(a,p,h,!0,!0),p[s]=y),y[t]!==p&&B(y,t,p,!1),D(e,y,h,!1,!0),d.call(e,r)&&W([].concat(e[r]),y),u&&!E&&B(y,l,h,!1),g(p,"isClass",k)}}(Object); |
+158
-28
@@ -37,2 +37,3 @@ /*! | ||
| SUPER = 'super', | ||
| VALUE = 'value', | ||
| WITH = 'with', | ||
@@ -105,2 +106,8 @@ | ||
| // basic ad-hoc private fallback for old browsers | ||
| // returns empty Array if nonexistent | ||
| gOPS = Object.getOwnPropertySymbols || function () { | ||
| return []; | ||
| }, | ||
| // needed to verify the existence | ||
@@ -114,5 +121,15 @@ getPrototypeOf = Object.getPrototypeOf, | ||
| // equivalent of Reflect.ownKeys | ||
| oK = function (o) { | ||
| return gOPN(o).concat(gOPS(o)); | ||
| }, | ||
| // used to filter mixin Symbol | ||
| isArray = Array.isArray || function (a) { | ||
| return Object[PROTOTYPE].toString.call(a) === '[object Array]'; | ||
| }, | ||
| // used to avoid setting `arguments` and other function properties | ||
| // when public static are copied over | ||
| nativeFunctionOPN = gOPN(function () {}), | ||
| nativeFunctionOPN = gOPN(function () {}).concat('arguments'), | ||
| indexOf = nativeFunctionOPN.indexOf || function (v) { | ||
@@ -123,2 +140,5 @@ for (var i = this.length; i-- && this[i] !== v;) {} | ||
| // used to flag classes | ||
| isClassDescriptor = {value: true}, | ||
| trustSuper = ('' + function () { | ||
@@ -157,4 +177,4 @@ // this test should never be minifier sensitive | ||
| defineProperty = function (object, name, descriptor) { | ||
| if (hOP.call(descriptor, 'value')) { | ||
| object[name] = descriptor.value; | ||
| if (hOP.call(descriptor, VALUE)) { | ||
| object[name] = descriptor[VALUE]; | ||
| } else { | ||
@@ -184,3 +204,3 @@ if (hOP.call(descriptor, 'get')) { | ||
| } else { | ||
| descriptor.value = object[key]; | ||
| descriptor[VALUE] = object[key]; | ||
| } | ||
@@ -191,3 +211,3 @@ return descriptor; | ||
| defineProperty = function (object, name, descriptor) { | ||
| object[name] = descriptor.value; | ||
| object[name] = descriptor[VALUE]; | ||
| return object; | ||
@@ -217,2 +237,62 @@ }; | ||
| // deep copy all properties of an object (static objects only) | ||
| function copyDeep(source) { | ||
| for (var | ||
| key, descriptor, value, | ||
| target = create(gPO(source)), | ||
| names = oK(source), | ||
| i = 0; i < names.length; i++ | ||
| ) { | ||
| key = names[i]; | ||
| descriptor = gOPD(source, key); | ||
| if (hOP.call(descriptor, VALUE)) { | ||
| copyValueIfObject(descriptor, copyDeep); | ||
| } | ||
| defineProperty(target, key, descriptor); | ||
| } | ||
| return target; | ||
| } | ||
| // given two objects, performs a deep copy | ||
| // per each property not present in the target | ||
| // otherwise merges, without overwriting, | ||
| // all properties within the object | ||
| function copyMerged(source, target) { | ||
| for (var | ||
| key, descriptor, value, tvalue, | ||
| names = oK(source), | ||
| i = 0; i < names.length; i++ | ||
| ) { | ||
| key = names[i]; | ||
| descriptor = gOPD(source, key); | ||
| // target already has this property | ||
| if (hOP.call(target, key)) { | ||
| // verify the descriptor can be merged | ||
| if (hOP.call(descriptor, VALUE)) { | ||
| value = descriptor[VALUE]; | ||
| // which means, verify it's an object | ||
| if (isObject(value)) { | ||
| // in such case, verify the target can be modified | ||
| descriptor = gOPD(target, key); | ||
| // meaning verify it's a data descriptor | ||
| if (hOP.call(descriptor, VALUE)) { | ||
| tvalue = descriptor[VALUE]; | ||
| // and it's actually an object | ||
| if (isObject(tvalue)) { | ||
| copyMerged(value, tvalue); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| // target has no property at all | ||
| if (hOP.call(descriptor, VALUE)) { | ||
| // copy deep if it's an object | ||
| copyValueIfObject(descriptor, copyDeep); | ||
| } | ||
| defineProperty(target, key, descriptor); | ||
| } | ||
| } | ||
| } | ||
| // configure source own properties in the target | ||
@@ -223,3 +303,3 @@ function copyOwn(source, target, inherits, publicStatic, allowInit) { | ||
| noFunctionCheck = typeof source !== 'function', | ||
| names = gOPN(source), | ||
| names = oK(source), | ||
| i = 0; i < names.length; i++ | ||
@@ -233,3 +313,3 @@ ) { | ||
| if (hOP.call(target, key)) { | ||
| warn('duplicated: ' + key); | ||
| warn('duplicated: ' + key.toString()); | ||
| } | ||
@@ -241,2 +321,11 @@ setProperty(inherits, target, key, gOPD(source, key), publicStatic); | ||
| // shortcut to copy objects into descriptor.value | ||
| function copyValueIfObject(where, how) { | ||
| var what = where[VALUE]; | ||
| if (isObject(what)) { | ||
| where[VALUE] = how(what); | ||
| } | ||
| } | ||
| // return the right constructor analyzing the parent. | ||
@@ -296,2 +385,8 @@ // if the parent is empty there is no need to call it. | ||
| // verifies a generic value is actually an object | ||
| function isObject(value) { | ||
| /*jshint eqnull: true */ | ||
| return value != null && typeof value === 'object'; | ||
| } | ||
| // verifies the entire string is upper case | ||
@@ -313,21 +408,45 @@ // and contains eventually an underscore | ||
| function transformMixin(trait) { | ||
| if (typeof trait === 'object') return trait; | ||
| if (trait.length) { | ||
| warn((trait.name || 'Class') + ' should not expect arguments'); | ||
| } | ||
| for (var | ||
| i, key, keys, | ||
| object = {init: trait}, | ||
| proto = trait.prototype; | ||
| proto && proto !== Object.prototype; | ||
| proto = gPO(proto) | ||
| ) { | ||
| for (i = 0, keys = gOPN(proto); i < keys.length; i++) { | ||
| key = keys[i]; | ||
| if (isNotASpecialKey(key, false) && !hOP.call(object, key)) { | ||
| defineProperty(object, key, gOPD(proto, key)); | ||
| if (isObject(trait)) return trait; | ||
| else { | ||
| var i, key, keys, object, proto; | ||
| if (trait.isClass) { | ||
| if (trait.length) { | ||
| warn((trait.name || 'Class') + ' should not expect arguments'); | ||
| } | ||
| for ( | ||
| object = {init: trait}, | ||
| proto = trait.prototype; | ||
| proto && proto !== Object.prototype; | ||
| proto = gPO(proto) | ||
| ) { | ||
| for (i = 0, keys = oK(proto); i < keys.length; i++) { | ||
| key = keys[i]; | ||
| if (isNotASpecialKey(key, false) && !hOP.call(object, key)) { | ||
| defineProperty(object, key, gOPD(proto, key)); | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| for ( | ||
| i = 0, | ||
| object = {}, | ||
| proto = trait({}), | ||
| keys = oK(proto); | ||
| i < keys.length; i++ | ||
| ) { | ||
| key = keys[i]; | ||
| if (key !== INIT) { | ||
| // if this key is the mixin one | ||
| if (~key.toString().indexOf('mixin:init') && isArray(proto[key])) { | ||
| // set the init simply as own method | ||
| object.init = proto[key][0]; | ||
| } else { | ||
| // simply assign the descriptor | ||
| defineProperty(object, key, gOPD(proto, key)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return object; | ||
| } | ||
| return object; | ||
| } | ||
@@ -340,3 +459,3 @@ | ||
| var | ||
| hasValue = hOP.call(descriptor, 'value'), | ||
| hasValue = hOP.call(descriptor, VALUE), | ||
| configurable, | ||
@@ -347,8 +466,19 @@ value | ||
| if (hOP.call(target, key)) { | ||
| // in case the value is not a static one | ||
| if ( | ||
| inherits && | ||
| isObject(target[key]) && | ||
| isObject(inherits[CONSTRUCTOR][key]) | ||
| ) { | ||
| copyMerged(inherits[CONSTRUCTOR][key], target[key]); | ||
| } | ||
| return; | ||
| } else if (hasValue) { | ||
| // in case it's an object perform a deep copy | ||
| copyValueIfObject(descriptor, copyDeep); | ||
| } | ||
| } else if (hasValue) { | ||
| value = descriptor.value; | ||
| value = descriptor[VALUE]; | ||
| if (typeof value === 'function' && trustSuper(value)) { | ||
| descriptor.value = wrap(inherits, key, value, publicStatic); | ||
| descriptor[VALUE] = wrap(inherits, key, value, publicStatic); | ||
| } | ||
@@ -379,3 +509,3 @@ } else { | ||
| if (hOP.call(current, key) && !hOP.call(target, key)) { | ||
| warn(key + ' is not implemented'); | ||
| warn(key.toString() + ' is not implemented'); | ||
| } | ||
@@ -485,3 +615,3 @@ } | ||
| } | ||
| return constructor; | ||
| return defineProperty(constructor, 'isClass', isClassDescriptor); | ||
| }; | ||
@@ -488,0 +618,0 @@ |
+6
-2
| { | ||
| "version": "1.2.3", | ||
| "version": "2.0.0", | ||
| "license": "MIT", | ||
@@ -36,4 +36,8 @@ "name": "es-class", | ||
| "devDependencies": { | ||
| "wru": ">= 0.0.0" | ||
| "wru": "*", | ||
| "tiny-cdn": "*", | ||
| "uglify-js": "1", | ||
| "jshint": "*", | ||
| "markdown": "*" | ||
| } | ||
| } |
+3
-5
@@ -1,7 +0,5 @@ | ||
| es-class | ||
| ======== | ||
| es-class [](http://travis-ci.org/WebReflection/es-class) | ||
| ================================= | ||
| [](http://travis-ci.org/WebReflection/es-class) | ||
| ### A future proof, backward compatible, JavaScript class utility. | ||
@@ -77,3 +75,3 @@ | ||
| * [super](https://github.com/WebReflection/es-class/blob/master/FEATURES.md#super) to shortcut super methods invocation | ||
| * [with](https://github.com/WebReflection/es-class/blob/master/FEATURES.md#with) to attach lightweight traits / mixins enabling composition behind optional initializers per each mixin | ||
| * [with](https://github.com/WebReflection/es-class/blob/master/FEATURES.md#with) to attach lightweight traits / mixins enabling composition behind optional initializers per each mixin. Compatible with [universal-mixin](https://github.com/WebReflection/universal-mixin/) since version `1.3.0` | ||
| * [static](https://github.com/WebReflection/es-class/blob/master/FEATURES.md#static) to define public static class constants, inherited if extended, without ever polluting the prototype | ||
@@ -80,0 +78,0 @@ * [implements](https://github.com/WebReflection/es-class/blob/master/FEATURES.md#implements) to perform light checks over expected implementations and warn eventually when something is missing |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
39725
14.32%557
27.75%0
-100%0
-100%5
400%201
-0.99%