Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-object

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-object - npm Package Compare versions

Comparing version 1.6.5 to 1.7.0

24

lib/Object.js

@@ -80,5 +80,21 @@ (function() {

AbstractObject.prototype.init = function() {};
AbstractObject.prototype.initialize = function() {
if (isFunction(this.init)) {
console.error("init method is deprecated, pls use initialize instead");
if (!AbstractObject.prototype.init) {
AbstractObject.prototype.init = (function() {});
}
return this.init.apply(this, arguments);
}
};
AbstractObject.prototype.final = function() {};
AbstractObject.prototype.finalize = function() {
if (isFunction(this.final)) {
console.error("final method is deprecated, pls use finalize instead");
if (!AbstractObject.prototype.final) {
AbstractObject.prototype.final = (function() {});
}
return this.final.apply(this, arguments);
}
};

@@ -88,3 +104,3 @@ function AbstractObject() {

this.setMaxListeners(Infinity);
if (this.init.apply(this, arguments) !== true) {
if (this.initialize.apply(this, arguments) !== true) {
this.changeObjectState(OBJECT_STATES.inited);

@@ -96,3 +112,3 @@ }

this.changeObjectState(OBJECT_STATES.destroying);
this.final.apply(this, arguments);
this.finalize.apply(this, arguments);
this.changeObjectState(OBJECT_STATES.destroyed);

@@ -99,0 +115,0 @@ return this.removeAllListeners();

@@ -15,4 +15,11 @@ (function() {

RefObject.prototype.init = function() {
return this.RefCount = 0;
RefObject.prototype.initialize = function() {
this.RefCount = 0;
if (this.init) {
console.error("init method is deprecated, pls use initialize instead");
if (!RefObject.prototype.init) {
RefObject.prototype.init = (function() {});
}
return this.init.apply(this, arguments);
}
};

@@ -19,0 +26,0 @@

@@ -5,2 +5,3 @@ var inherits = require('./inherits');

module.exports = function(aObject, aClass) {
// ES6: Object.getPrototypeOf / Object.setPrototypeOf
var vOldProto = aObject.__proto__;

@@ -7,0 +8,0 @@ var result = false;

3

package.json
{
"name": "abstract-object",
"version": "1.6.5",
"version": "1.7.0",
"description": "AbstractObject with Object State Events Support, RefObject with RefCount and AddRef/Release Support.",

@@ -38,3 +38,2 @@ "homepage": "https://github.com/snowyu/abstract-object",

"mocha": "~2.0.1",
"powerbuild": "*",
"sinon": "~1.12.2",

@@ -41,0 +40,0 @@ "sinon-chai": "~2.6.0",

@@ -5,3 +5,3 @@ # AbtractObject [![Build Status](https://img.shields.io/travis/snowyu/abstract-object/master.png)](http://travis-ci.org/snowyu/abstract-object) [![npm](https://img.shields.io/npm/v/abstract-object.svg)](https://npmjs.org/package/abstract-object) [![downloads](https://img.shields.io/npm/dm/abstract-object.svg)](https://npmjs.org/package/abstract-object) [![license](https://img.shields.io/npm/l/abstract-object.svg)](https://npmjs.org/package/abstract-object)

The derived class should overwrite the `init`, `final` methods.
The derived class should overwrite the `initialize` and `finalize` methods.

@@ -15,5 +15,11 @@ * Methods:

* `arguments` *(array)*: the arguments will be passed into the class constructor.
* `init(...)`: abstract initialization method after a new instance creating.
* `initialize(...)`: abstract initialization method after a new instance creating.
* `...`: the constructor's arguments should be passed into initialize method.
* `finalize`(...): abstract finalization method before the instance destroying.
* `...`: the free(destroy)'s arguments should be passed into finalize method.
* `init(...)`: abstract initialization method after a new instance creating. (**deprecated**)
* init method is deprecated, pls use initialize method instead
* `...`: the constructor's arguments should be passed into init method.
* `final`(...): abstract finalization method before the instance destroying.
* `final`(...): abstract finalization method before the instance destroying. (**deprecated**)
* final method is deprecated, pls use finalize instead
* `...`: the free(destroy)'s arguments should be passed into final method.

@@ -29,10 +35,10 @@ * `free`(...): free the class instance.

* `callback`: optional, it will not dispatch `'error'` event if the callback is exists, unless the callback return false.
* `isIniting`(), `isInited`(),`isDestroying`(), `isDestroyed`() methods:
* to test object state methods
* `isIniting`(), `isInited`(),`isDestroying`(), `isDestroyed`() object state testing methods:
* to test object state
* Events:
* `'initing'`: emit before the init method
* `'inited'`: emit after the init method
* `'destroying'`: emit before the final method
* `'destroyed'`: emit after the final method
* `'initing'`: emit before the initialize method
* `'inited'`: emit after the initialize method
* `'destroying'`: emit before the finalize method
* `'destroyed'`: emit after the finalize method

@@ -61,3 +67,3 @@

inherits MyObject, RefObject
init: (@a,@b)->
initialize: (@a,@b)->
super()

@@ -76,3 +82,3 @@

super
init: (@a,@b)->
initialize: (@a,@b)->
# must call super method here for RefObject initialization:

@@ -104,5 +110,5 @@ super()

MyObject.prototype.init = function(a,b) {
MyObject.prototype.initialize = function(a,b) {
//super call
MyObject.__super__.init.call(this);
MyObject.__super__.initialize.call(this);
this.a = a

@@ -109,0 +115,0 @@ this.b = b

@@ -5,2 +5,3 @@ var inherits = require('./inherits');

module.exports = function(aObject, aClass) {
// ES6: Object.getPrototypeOf / Object.setPrototypeOf
var vOldProto = aObject.__proto__;

@@ -7,0 +8,0 @@ var result = false;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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