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.2.2 to 1.3.0

29

lib/Object.js
(function() {
var AbstractObject, EventEmitter, OBJECT_STATES, OBJECT_STATES_STR, inherits, util;
var AbstractObject, EventEmitter, OBJECT_STATES, OBJECT_STATES_STR, inherits, isArray, isFunction, isUndefined, util;

@@ -10,2 +10,8 @@ EventEmitter = require("events").EventEmitter;

isArray = util.isArray;
isFunction = util.isFunction;
isUndefined = util.isUndefined;
OBJECT_STATES = {

@@ -85,2 +91,23 @@ initing: 1,

AbstractObject.prototype.dispatch = function(event, args, callback) {
if (isUndefined(callback) && isFunction(args)) {
callback = args;
args = [];
} else if (!isArray(args)) {
args = [args];
}
if (callback && callback.apply(this, args) !== false) {
return;
}
args.splice(0, 0, event);
return this.emit.apply(this, args);
};
AbstractObject.prototype.dispatchError = function(error, callback) {
if (callback && callback(error) !== false) {
return;
}
return this.emit('error', error);
};
AbstractObject.create = util.createObject;

@@ -87,0 +114,0 @@

14

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

@@ -22,4 +22,4 @@ "homepage": "https://github.com/snowyu/abstract-object",

"devDependencies": {
"chai": "^1.10.0",
"coffee-script": "^1.8.0",
"chai": "~1.10.0",
"coffee-script": "~1.8.0",
"connect-livereload": "*",

@@ -34,3 +34,3 @@ "grunt": "*",

"grunt-contrib-watch": "*",
"grunt-mocha-test": "^0.12.4",
"grunt-mocha-test": "~0.12.4",
"grunt-newer": "*",

@@ -41,6 +41,6 @@ "grunt-release": "*",

"grunt-usemin": "*",
"mocha": "^2.0.1",
"mocha": "~2.0.1",
"powerbuild": "*",
"sinon": "^1.11.1",
"sinon-chai": "^2.6.0",
"sinon": "~1.11.1",
"sinon-chai": "~2.6.0",
"source-map-support": "*"

@@ -47,0 +47,0 @@ },

@@ -12,9 +12,16 @@ # AbtractObject

* Methods:
* `create`(class): the `create` class method uses to create a new object instance(the util.createObject is the same function).
* class: the class constructor to create a new instance.
* ...: the left arguments will be passed into the class constructor.
* `init`: abstract initialization method after a new instance creating.
* the constructor's arguments should be passed into init method.
* `create`(class, ...): the `create` class method uses to create a new object instance(the util.createObject is the same function).
* `class`: the class constructor to create a new instance.
* `...`: the left arguments will be passed into the class constructor.
* `init(...)`: abstract initialization method after a new instance creating.
* `...`: the constructor's arguments should be passed into init method.
* `final`: abstract finalization method before the instance destroying.
* `free`: free the class instance.
* `dispatch`(event, args[, callback]): dispath an event or callback
* `event`: the event name
* `args`: the args are passed to event or callback
* `callback`: optional, it will not dispatch event if the callback is exists, unless the callback return false.
* `dispatchError`(error[, callback]):
* `error`: the error instance.
* `callback`: optional, it will not dispatch `'error'` event if the callback is exists, unless the callback return false.

@@ -21,0 +28,0 @@ * Events:

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