Socket
Socket
Sign inDemoInstall

core-object

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-object - npm Package Compare versions

Comparing version 2.0.6 to 2.1.0

79

core-object.js
'use strict';
var assignProperties = require('./lib/assign-properties');
var deprecation = require('./lib/deprecation');
const assignProperties = require('./lib/assign-properties');
const deprecation = require('./lib/deprecation');
function needsNew() {
throw new TypeError("Failed to construct: Please use the 'new' operator, this object constructor cannot be called as a function.");
}
function CoreObject(options) {
if (!(this instanceof CoreObject)) {
needsNew()
class CoreObject {
constructor() {
this.init.apply(this, arguments);
}
this.init(options);
}
CoreObject.prototype.init = function(options) {
if (options) {
for (var key in options) {
this[key] = options[key];
init(options) {
if (options) {
for (let key in options) {
this[key] = options[key];
}
}
}
};
CoreObject.extend = function(options) {
var constructor = this;
static extend(options) {
class Class extends this { }
function Class() {
var length = arguments.length;
if (options) {
if (shouldCallSuper(options.init)) {
if (length === 0) this.init();
else if (length === 1) this.init(arguments[0]);
else this.init.apply(this, arguments);
}
Class.__proto__ = CoreObject;
Class.prototype = Object.create(constructor.prototype);
if (options) {
if (shouldCallSuper(options.init)) {
if (hasArgs(options.init)) {
deprecation(
'Overriding init without calling this._super is deprecated. ' +
if (hasArgs(options.init)) {
deprecation(
'Overriding init without calling this._super is deprecated. ' +
'Please call this._super(), addon: `' + options.name + '`'
);
options.init = forceSuperWithoutApply(options.init);
} else {
);
options.init = forceSuperWithoutApply(options.init);
} else {
// this._super.init && is to make sure that the deprecation message
// works for people who are writing addons supporting before 2.6.
deprecation(
'Overriding init without calling this._super is deprecated. ' +
// this._super.init && is to make sure that the deprecation message
// works for people who are writing addons supporting before 2.6.
deprecation(
'Overriding init without calling this._super is deprecated. ' +
'Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `' + options.name + '`'
);
options.init = forceSuper(options.init);
);
options.init = forceSuper(options.init);
}
}
assignProperties(Class.prototype, options);
}
assignProperties(Class.prototype, options);
return Class;
}
}
return Class;
};
function hasArgs(fn) {

@@ -67,0 +50,0 @@ // Takes arguments, assume disruptive override

@@ -1,3 +0,5 @@

var deprecation = require('./deprecation');
'use strict';
const deprecation = require('./deprecation');
function setPrototypeOf(obj, proto) {

@@ -13,3 +15,3 @@ Object.setPrototypeOf ? Object.setPrototypeOf(obj, proto) : obj.__proto__ = proto;

return function superWrapper() {
var superFn;
let superFn;

@@ -31,5 +33,5 @@ if (superclass[name]) {

var previous = this._super;
const previous = this._super;
this._super = superFn;
var ret = fn.apply(this, arguments);
const ret = fn.apply(this, arguments);
this._super = previous;

@@ -40,7 +42,7 @@ return ret;

var sourceAvailable = (function() {
const sourceAvailable = (function() {
return this;
}).toString().indexOf('return this') > -1;
var hasSuper;
let hasSuper;
if (sourceAvailable) {

@@ -60,6 +62,6 @@ hasSuper = function(fn) {

function assignProperties(target, options) {
var value;
module.exports = function assignProperties(target, options) {
let value;
for (var key in options) {
for (let key in options) {
value = options[key];

@@ -73,4 +75,2 @@

}
}
module.exports = assignProperties;
};
'use strict';
var env = require('./env');
var chalk = require('chalk');
const env = require('./env');
module.exports = function deprecation(msg) {
var error = new Error();
var stack = error.stack.split(/\n/);
var source = stack[3];
let error = new Error();
let stack = error.stack.split(/\n/);
let source = stack[3];
console.warn(chalk.yellow('DEPRECATION: ' + msg + '\n' + source));
console.warn(require('chalk').yellow('DEPRECATION: ' + msg + '\n' + source));
};

@@ -0,1 +1,3 @@

'use strict';
module.exports = (

@@ -2,0 +4,0 @@ (typeof window !== 'undefined' && window) ||

{
"name": "core-object",
"version": "2.0.6",
"version": "2.1.0",
"description": "A lightweight implementation of OOP Class in JavaScript",

@@ -32,3 +32,2 @@ "main": "core-object.js",

"klass": "^1.4.0",
"microtime": "^2.1.1",
"mocha": "^3.0.0",

@@ -35,0 +34,0 @@ "traceur-runtime": "0.0.59",

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