Socket
Socket
Sign inDemoInstall

class-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-wrapper - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

17

dest/class-wrapper.amd.js
/**
* class-wrapper v2.2.0
* class-wrapper v2.2.1
* Copyright (c) 2016-2020 Valerii Zinchenko

@@ -285,10 +285,11 @@ * License: MIT http://valerii-zinchenko.gitlab.io/observer/blob/master/LICENSE.txt

const value = from[key];
if (value instanceof Function) {
if (force || !to.prototype[key]) {
to.prototype[key] = value;
}
continue;
}
switch (Object.prototype.toString.call(value)) {
// Store functions into "prototype"
case '[object Function]':
if (force || !to.prototype[key]) {
to.prototype[key] = value;
}
break;
// Clone objects and store the copies into "__defaults"

@@ -295,0 +296,0 @@ case '[object Object]':

/**
* class-wrapper v2.2.0
* class-wrapper v2.2.1
* Copyright (c) 2016-2020 Valerii Zinchenko

@@ -8,2 +8,2 @@ * License: MIT http://valerii-zinchenko.gitlab.io/observer/blob/master/LICENSE.txt

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self)["class-wrapper"]={})}(this,(function(exports){"use strict";function deepCopy(t,e){for(let o in e){const n=e[o];switch(Object.prototype.toString.call(n)){case"[object Object]":t[o]||(t[o]={}),deepCopy(t[o],n);break;default:t[o]=n}}return t}function deepExtend(t,e){for(let o in e){const n=e[o];if(Object.prototype.hasOwnProperty.call(t,o))"object"==typeof t[o]&&deepExtend(t[o],n);else switch(Object.prototype.toString.call(n)){case"[object Object]":t[o]={},deepExtend(t[o],n);break;case"[object Array]":t[o]=n.map(t=>t);break;default:t[o]=n}}return t}function doesImplements(t,e){for(let o in e)if(!(t[o]instanceof Function))return!1;return!0}var utils=Object.freeze({__proto__:null,deepCopy:deepCopy,deepExtend:deepExtend,doesImplements:doesImplements});function ClassBuilder(constructorTemplate,Parent,Constructor,props){if(props=arguments[arguments.length-1],Constructor=arguments[arguments.length-2],3!==arguments.length&&null!==Parent||(Parent=Object),arguments.length<3||"function"!=typeof constructorTemplate||null!==Constructor&&"function"!=typeof Constructor||"[object Object]"!==Object.prototype.toString.call(props))throw new TypeError("Incorrect input arguments. It should be: ClassBuilder(Function, [Function], Function | null, Object)");const name="string"==typeof props.__name?props.__name:"Class";let Class;delete props.__name,eval(`\nClass = class ${name} extends Parent {\n\t${constructorTemplate(Parent,Constructor)||""}\n};\n`),Class.prototype.__defaults={},Parent.prototype.__defaults&&encapsulate(Parent.prototype.__defaults,Class);var encapsulations=[];if(props.Encapsulate&&("[object Array]"===Object.prototype.toString.call(props.Encapsulate)?encapsulations=encapsulations.concat(props.Encapsulate):encapsulations.push(props.Encapsulate),delete props.Encapsulate),Object.setPrototypeOf(props,Parent.prototype),encapsulate(props,Class,!0),encapsulations.some(t=>{const e=Object.prototype.toString.call(t);return"[object Function]"!==e&&"[object Object]"!==e}))throw new TypeError("Some of the items for encapsulation are incorrect. An item can be: Object, Function, Class");return encapsulations.forEach(t=>{encapsulate(t,Class)}),props.Implements instanceof Array||(props.Implements=[props.Implements]),props.Implements.forEach(t=>{if(t instanceof Object)for(let e in t){t[e]instanceof Function&&!(Class.prototype[e]instanceof Function)&&(Class.prototype.__defaults[e],Class.prototype[e]=function(){throw new Error(`"${name}::${e}" is not implemented`)},console.warn(`Implementation of "${name}::${e}" is not found. This method will be treated as an abstract method and will throw an error by execution.`))}}),Class}function encapsulate(t,e,o=!1){"[object Function]"===Object.prototype.toString.call(t)&&(t=t.prototype);for(let n in t){const s=t[n];switch(Object.prototype.toString.call(s)){case"[object Function]":!o&&e.prototype[n]||(e.prototype[n]=s);break;case"[object Object]":"__defaults"===n?deepCopy(e.prototype.__defaults,s):(e.prototype.__defaults[n]||(e.prototype.__defaults[n]={}),deepCopy(e.prototype.__defaults[n],s));break;default:e.prototype.__defaults[n]=s}}}ClassBuilder.utils=utils;const baseClasses=[];var Class=ClassBuilder.bind(null,(function(t,e){const o=baseClasses.find(e=>t.prototype instanceof e);return o||-1!==baseClasses.indexOf(t)||baseClasses.push(t),!e&&o?"":`constructor() {\n\t\tsuper(...arguments);\n\t\t${o?"":"ClassBuilder.utils.deepExtend(this, this.constructor.prototype.__defaults);"}\n\t\t${e?"Constructor.call(this, ...arguments);":""}\n\t}`}));function Interface(t,e){return e?{...t,...e}:t}exports.Class=Class,exports.ClassBuilder=ClassBuilder,exports.Interface=Interface,exports.utils=utils,Object.defineProperty(exports,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self)["class-wrapper"]={})}(this,(function(exports){"use strict";function deepCopy(t,e){for(let o in e){const n=e[o];switch(Object.prototype.toString.call(n)){case"[object Object]":t[o]||(t[o]={}),deepCopy(t[o],n);break;default:t[o]=n}}return t}function deepExtend(t,e){for(let o in e){const n=e[o];if(Object.prototype.hasOwnProperty.call(t,o))"object"==typeof t[o]&&deepExtend(t[o],n);else switch(Object.prototype.toString.call(n)){case"[object Object]":t[o]={},deepExtend(t[o],n);break;case"[object Array]":t[o]=n.map(t=>t);break;default:t[o]=n}}return t}function doesImplements(t,e){for(let o in e)if(!(t[o]instanceof Function))return!1;return!0}var utils=Object.freeze({__proto__:null,deepCopy:deepCopy,deepExtend:deepExtend,doesImplements:doesImplements});function ClassBuilder(constructorTemplate,Parent,Constructor,props){if(props=arguments[arguments.length-1],Constructor=arguments[arguments.length-2],3!==arguments.length&&null!==Parent||(Parent=Object),arguments.length<3||"function"!=typeof constructorTemplate||null!==Constructor&&"function"!=typeof Constructor||"[object Object]"!==Object.prototype.toString.call(props))throw new TypeError("Incorrect input arguments. It should be: ClassBuilder(Function, [Function], Function | null, Object)");const name="string"==typeof props.__name?props.__name:"Class";let Class;delete props.__name,eval(`\nClass = class ${name} extends Parent {\n\t${constructorTemplate(Parent,Constructor)||""}\n};\n`),Class.prototype.__defaults={},Parent.prototype.__defaults&&encapsulate(Parent.prototype.__defaults,Class);var encapsulations=[];if(props.Encapsulate&&("[object Array]"===Object.prototype.toString.call(props.Encapsulate)?encapsulations=encapsulations.concat(props.Encapsulate):encapsulations.push(props.Encapsulate),delete props.Encapsulate),Object.setPrototypeOf(props,Parent.prototype),encapsulate(props,Class,!0),encapsulations.some(t=>{const e=Object.prototype.toString.call(t);return"[object Function]"!==e&&"[object Object]"!==e}))throw new TypeError("Some of the items for encapsulation are incorrect. An item can be: Object, Function, Class");return encapsulations.forEach(t=>{encapsulate(t,Class)}),props.Implements instanceof Array||(props.Implements=[props.Implements]),props.Implements.forEach(t=>{if(t instanceof Object)for(let e in t){t[e]instanceof Function&&!(Class.prototype[e]instanceof Function)&&(Class.prototype.__defaults[e],Class.prototype[e]=function(){throw new Error(`"${name}::${e}" is not implemented`)},console.warn(`Implementation of "${name}::${e}" is not found. This method will be treated as an abstract method and will throw an error by execution.`))}}),Class}function encapsulate(t,e,o=!1){"[object Function]"===Object.prototype.toString.call(t)&&(t=t.prototype);for(let n in t){const s=t[n];if(s instanceof Function)!o&&e.prototype[n]||(e.prototype[n]=s);else switch(Object.prototype.toString.call(s)){case"[object Object]":"__defaults"===n?deepCopy(e.prototype.__defaults,s):(e.prototype.__defaults[n]||(e.prototype.__defaults[n]={}),deepCopy(e.prototype.__defaults[n],s));break;default:e.prototype.__defaults[n]=s}}}ClassBuilder.utils=utils;const baseClasses=[];var Class=ClassBuilder.bind(null,(function(t,e){const o=baseClasses.find(e=>t.prototype instanceof e);return o||-1!==baseClasses.indexOf(t)||baseClasses.push(t),!e&&o?"":`constructor() {\n\t\tsuper(...arguments);\n\t\t${o?"":"ClassBuilder.utils.deepExtend(this, this.constructor.prototype.__defaults);"}\n\t\t${e?"Constructor.call(this, ...arguments);":""}\n\t}`}));function Interface(t,e){return e?{...t,...e}:t}exports.Class=Class,exports.ClassBuilder=ClassBuilder,exports.Interface=Interface,exports.utils=utils,Object.defineProperty(exports,"__esModule",{value:!0})}));
{
"name": "class-wrapper",
"version": "2.2.0",
"version": "2.2.1",
"description": "Set of wrappers to define a class like in C++ and few utility functions",

@@ -5,0 +5,0 @@ "main": "main.mjs",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc