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.8.1 to 1.9.0

31

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

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

isArray = require("./util/isArray");
isArray = require("util-ex/lib/is/type/array");
isFunction = require("./util/isFunction");
isFunction = require("util-ex/lib/is/type/function");
isUndefined = require("./util/isUndefined");
isUndefined = require("util-ex/lib/is/type/undefined");
defineProperty = require("util-ex/lib/defineProperty");
OBJECT_STATES = {

@@ -35,13 +37,11 @@ initing: 1,

AbstractObject.prototype.__defineGetter__("Class", function() {
return this.__proto__.constructor;
});
AbstractObject.prototype.__defineGetter__("objectState", function() {
var vState;
vState = this._objectState_;
if (vState == null) {
return "destroyed";
} else {
return OBJECT_STATES_STR[vState];
defineProperty(AbstractObject.prototype, "objectState", null, {
get: function() {
var vState;
vState = this._objectState_;
if (vState == null) {
return "destroyed";
} else {
return OBJECT_STATES_STR[vState];
}
}

@@ -105,2 +105,3 @@ });

function AbstractObject() {
defineProperty(this, '_objectState_', null);
this.changeObjectState(OBJECT_STATES.initing);

@@ -107,0 +108,0 @@ this.setMaxListeners(Infinity);

(function() {
var AbstractObject, RefObject, inherits;
var AbstractObject, RefObject, defineProperty, inherits;

@@ -8,2 +8,4 @@ AbstractObject = require("./Object");

defineProperty = require("util-ex/lib/defineProperty");
module.exports = RefObject = (function() {

@@ -15,3 +17,3 @@ function RefObject() {}

RefObject.prototype.initialize = function() {
this.RefCount = 0;
defineProperty(this, 'RefCount', 0);
if (this.init) {

@@ -18,0 +20,0 @@ console.error("init method is deprecated, pls use initialize instead");

@@ -1,16 +0,2 @@

var isObject = require('./isObject');
module.exports = function (origin) {
for (var i=1; i < arguments.length; i++) {
var add = arguments[i];
// Don't do anything if add isn't an object
if (!add || !isObject(add)) continue;
var keys = Object.keys(add);
var j = keys.length;
while (j--) {
origin[keys[j]] = add[keys[j]];
}
}
return origin;
}
module.exports = require('util-ex/lib/_extend');

@@ -1,77 +0,1 @@

var isArguments = require('./isArguments');
var arraySlice = Array.prototype.slice;
/*
@desc inject the function
@param aOrgFunc the original function to be injected.
@param aBeforeExec this is called before the execution of the aOrgFunc.
you must return the arguments(new Arguments(arguments))
if you wanna modify the arguments value of the aOrgFunc.
it will stop the execution of the aOrgFunc if you return
a value not an Arguments object nor a undefined value
@param aAtferExec this is called after the execution of the aOrgFunc.
you must add a result argument at the last argument of the
aAtferExec function if you wanna get the result value of the aOrgFunc.
you must add a isDenied argument following the result argument if you
wanna know whether the aOrgFunc is executed.
you must return the result if you wanna modify the result value of the aOrgFunc .
@Usage Obj.prototype.Method = inject(Obj.prototype.Method, aFunctionBeforeExec[, aFunctionAtferExec]);
@version 1.1
@author Aimingoo&Riceball
@history
V1.0 -- first released.
V1.1 --
Supports to denie the aOrgFunc execution in aBeforeExec.
Supports around in the aAtferExec, the aAtferExec be always executed even though
denie the aOrgFunc execution in aBeforeExec.
+ isDenied argument to the aAtferExec function. notice the aAtferExec whether
the aOrgFunc is executed
eg:
var doTest = function (a) {return a};
function beforeTest(a) {
alert('before exec: a='+a);
a += 3;
return arguments;
};
function afterTest(a, result, isDenied) {
alert('after exec: a='+a+';result='+result+';isDenied='+isDenied);
return result+5;
};
doTest = inject(doTest, beforeTest, afterTest);
alert (doTest(2));
the result should be 10.
*/
module.exports = function ( aOrgFunc, aBeforeExec, aAtferExec ) {
return function() {
var Result, isDenied=false, args=arraySlice.call(arguments);
if (typeof(aBeforeExec) === 'function') {
//the result
// * a return value instead of original function.
// * an arguments pass to original function.
// * whether deny the original function.
// * return the arguments to allow execution
// * return undefined to allow execution
Result = aBeforeExec.apply(this, args);
if (isArguments(Result)) {
args = arraySlice.call(Result)
}
else if (isDenied = Result !== undefined)
args.push(Result)
}
!isDenied && args.push(aOrgFunc.apply(this, args)); //if (!isDenied) args.push(aOrgFunc.apply(this, args));
if (typeof(aAtferExec) === 'function') {
Result = aAtferExec.apply(this, args.concat(isDenied));
}
else
Result = undefined;
return (Result !== undefined ? Result : args.pop());
}
}
module.exports = require('util-ex/lib/inject')

@@ -1,7 +0,1 @@

var argsClass = '[object Arguments]';
module.exports = function isArguments(value) {
return value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == argsClass || false;
}
module.exports = require('util-ex/lib/is/type/arguments');

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

module.exports = Array.isArray
module.exports = require('util-ex/lib/is/type/array')

@@ -1,4 +0,1 @@

module.exports = function(arg) {
return typeof arg === 'boolean';
}
module.exports = require('util-ex/lib/is/type/boolean');

@@ -1,8 +0,1 @@

var isObject = require('./isObject');
var objectToString = require('./objectToString');
var dateClass = '[object Date]';
module.exports = function(d) {
return isObject(d) && objectToString(d) === dateClass;
}
module.exports = require('util-ex/lib/is/type/date');

@@ -1,62 +0,1 @@

var isEmptyFunction = require('./isEmptyFunction');
var isFunction = require('./isFunction');
var isArguments = require('./isArguments');
var hasOwnProperty = Object.prototype.hasOwnProperty;
var getOwnPropertyNames = Object.getOwnPropertyNames; //>=ECMAScript5 only
var argsClass = '[object Arguments]',
arrayClass = '[object Array]',
boolClass = '[object Boolean]',
dateClass = '[object Date]',
errorClass = '[object Error]',
funcClass = '[object Function]',
numberClass = '[object Number]',
objectClass = '[object Object]',
regexpClass = '[object RegExp]',
stringClass = '[object String]';
var support = {};
(function() {
var ctor = function() { this.x = 1; },
object = { '0': 1, 'length': 1 },
props = [];
ctor.prototype = { 'valueOf': 1, 'y': 1 };
for (var key in new ctor) { props.push(key); }
for (key in arguments) { }
/**
* Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9).
*
* @memberOf _.support
* @type boolean
*/
support.argsClass = toString.call(arguments) == argsClass;
}(1));
module.exports = function(value) {
var result = true;
if (!value) {
return result;
}
var className = toString.call(value),
length = value.length;
if ((className == arrayClass || className == stringClass ||
(support.argsClass ? className == argsClass : isArguments(value))) ||
(className == objectClass && typeof length == 'number' && isFunction(value.splice))) {
return !length;
}
if (className == funcClass) {
return isEmptyFunction(value)
}
if (getOwnPropertyNames(value).length > 0) return false;
/*
for (var key in value) {
if (hasOwnProperty.call(value, key)) return false;
}
*/
return result;
}
module.exports = require('util-ex/lib/is/empty');

@@ -1,4 +0,1 @@

module.exports = function(aFunc) {
var result = /^function\s*\S*\s*\(.*\)\s*{[\s;]*}$/.test(aFunc.toString());
return result;
}
module.exports = require('util-ex/lib/is/empty-function');

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

module.exports = function isFunction(arg) {
return typeof arg === 'function';
}
module.exports = require('util-ex/lib/is/type/function');

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

module.exports = function(arg) {
return arg == null;
}
module.exports = require('util-ex/lib/is/type/null-or-undefined');

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

module.exports = function(arg) {
return typeof arg === 'number';
}
module.exports = require('util-ex/lib/is/type/number');

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

module.exports = function isObject(arg) {
return arg != null && typeof arg === 'object';
}
module.exports = require('util-ex/lib/is/type/object');

@@ -1,8 +0,1 @@

var isObject = require('./isObject');
var objectToString = require('./objectToString');
var regexpClass = '[object RegExp]';
module.exports = function(v) {
return isObject(v) && objectToString(v) === regexpClass;
}
module.exports = require('util-ex/lib/is/type/regexp');

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

module.exports = function(arg) {
return typeof arg === 'string';
}
module.exports = require('util-ex/lib/is/type/string');

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

module.exports = function(arg) {
return arg === void 0;
}
module.exports = require('util-ex/lib/is/type/undefined');
{
"name": "abstract-object",
"version": "1.8.1",
"version": "1.9.0",
"description": "AbstractObject with Object State Events Support, RefObject with RefCount and AddRef/Release Support.",

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

"dependencies": {
"inherits-ex": "~1.0.2"
"inherits-ex": "~1.0.5",
"util-ex": "~0.2.3"
},

@@ -39,3 +40,3 @@ "devDependencies": {

"mocha": "~2.0.1",
"pre-commit": "0.0.11",
"pre-commit": "~1.0.1",
"sinon": "~1.12.2",

@@ -42,0 +43,0 @@ "sinon-chai": "~2.6.0",

@@ -1,2 +0,2 @@

# 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)
### 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)

@@ -201,2 +201,4 @@ AbstractObject with Object State Events Supports and `free` method provides.

# Enhanced Inheritance Functions
Moved to [inherits-ex](https://github.com/snowyu/inherits-ex.js).

@@ -1,16 +0,2 @@

var isObject = require('./isObject');
module.exports = function (origin) {
for (var i=1; i < arguments.length; i++) {
var add = arguments[i];
// Don't do anything if add isn't an object
if (!add || !isObject(add)) continue;
var keys = Object.keys(add);
var j = keys.length;
while (j--) {
origin[keys[j]] = add[keys[j]];
}
}
return origin;
}
module.exports = require('util-ex/lib/_extend');

@@ -1,77 +0,1 @@

var isArguments = require('./isArguments');
var arraySlice = Array.prototype.slice;
/*
@desc inject the function
@param aOrgFunc the original function to be injected.
@param aBeforeExec this is called before the execution of the aOrgFunc.
you must return the arguments(new Arguments(arguments))
if you wanna modify the arguments value of the aOrgFunc.
it will stop the execution of the aOrgFunc if you return
a value not an Arguments object nor a undefined value
@param aAtferExec this is called after the execution of the aOrgFunc.
you must add a result argument at the last argument of the
aAtferExec function if you wanna get the result value of the aOrgFunc.
you must add a isDenied argument following the result argument if you
wanna know whether the aOrgFunc is executed.
you must return the result if you wanna modify the result value of the aOrgFunc .
@Usage Obj.prototype.Method = inject(Obj.prototype.Method, aFunctionBeforeExec[, aFunctionAtferExec]);
@version 1.1
@author Aimingoo&Riceball
@history
V1.0 -- first released.
V1.1 --
Supports to denie the aOrgFunc execution in aBeforeExec.
Supports around in the aAtferExec, the aAtferExec be always executed even though
denie the aOrgFunc execution in aBeforeExec.
+ isDenied argument to the aAtferExec function. notice the aAtferExec whether
the aOrgFunc is executed
eg:
var doTest = function (a) {return a};
function beforeTest(a) {
alert('before exec: a='+a);
a += 3;
return arguments;
};
function afterTest(a, result, isDenied) {
alert('after exec: a='+a+';result='+result+';isDenied='+isDenied);
return result+5;
};
doTest = inject(doTest, beforeTest, afterTest);
alert (doTest(2));
the result should be 10.
*/
module.exports = function ( aOrgFunc, aBeforeExec, aAtferExec ) {
return function() {
var Result, isDenied=false, args=arraySlice.call(arguments);
if (typeof(aBeforeExec) === 'function') {
//the result
// * a return value instead of original function.
// * an arguments pass to original function.
// * whether deny the original function.
// * return the arguments to allow execution
// * return undefined to allow execution
Result = aBeforeExec.apply(this, args);
if (isArguments(Result)) {
args = arraySlice.call(Result)
}
else if (isDenied = Result !== undefined)
args.push(Result)
}
!isDenied && args.push(aOrgFunc.apply(this, args)); //if (!isDenied) args.push(aOrgFunc.apply(this, args));
if (typeof(aAtferExec) === 'function') {
Result = aAtferExec.apply(this, args.concat(isDenied));
}
else
Result = undefined;
return (Result !== undefined ? Result : args.pop());
}
}
module.exports = require('util-ex/lib/inject')

@@ -1,7 +0,1 @@

var argsClass = '[object Arguments]';
module.exports = function isArguments(value) {
return value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == argsClass || false;
}
module.exports = require('util-ex/lib/is/type/arguments');

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

module.exports = Array.isArray
module.exports = require('util-ex/lib/is/type/array')

@@ -1,4 +0,1 @@

module.exports = function(arg) {
return typeof arg === 'boolean';
}
module.exports = require('util-ex/lib/is/type/boolean');

@@ -1,8 +0,1 @@

var isObject = require('./isObject');
var objectToString = require('./objectToString');
var dateClass = '[object Date]';
module.exports = function(d) {
return isObject(d) && objectToString(d) === dateClass;
}
module.exports = require('util-ex/lib/is/type/date');

@@ -1,62 +0,1 @@

var isEmptyFunction = require('./isEmptyFunction');
var isFunction = require('./isFunction');
var isArguments = require('./isArguments');
var hasOwnProperty = Object.prototype.hasOwnProperty;
var getOwnPropertyNames = Object.getOwnPropertyNames; //>=ECMAScript5 only
var argsClass = '[object Arguments]',
arrayClass = '[object Array]',
boolClass = '[object Boolean]',
dateClass = '[object Date]',
errorClass = '[object Error]',
funcClass = '[object Function]',
numberClass = '[object Number]',
objectClass = '[object Object]',
regexpClass = '[object RegExp]',
stringClass = '[object String]';
var support = {};
(function() {
var ctor = function() { this.x = 1; },
object = { '0': 1, 'length': 1 },
props = [];
ctor.prototype = { 'valueOf': 1, 'y': 1 };
for (var key in new ctor) { props.push(key); }
for (key in arguments) { }
/**
* Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9).
*
* @memberOf _.support
* @type boolean
*/
support.argsClass = toString.call(arguments) == argsClass;
}(1));
module.exports = function(value) {
var result = true;
if (!value) {
return result;
}
var className = toString.call(value),
length = value.length;
if ((className == arrayClass || className == stringClass ||
(support.argsClass ? className == argsClass : isArguments(value))) ||
(className == objectClass && typeof length == 'number' && isFunction(value.splice))) {
return !length;
}
if (className == funcClass) {
return isEmptyFunction(value)
}
if (getOwnPropertyNames(value).length > 0) return false;
/*
for (var key in value) {
if (hasOwnProperty.call(value, key)) return false;
}
*/
return result;
}
module.exports = require('util-ex/lib/is/empty');

@@ -1,4 +0,1 @@

module.exports = function(aFunc) {
var result = /^function\s*\S*\s*\(.*\)\s*{[\s;]*}$/.test(aFunc.toString());
return result;
}
module.exports = require('util-ex/lib/is/empty-function');

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

module.exports = function isFunction(arg) {
return typeof arg === 'function';
}
module.exports = require('util-ex/lib/is/type/function');

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

module.exports = function(arg) {
return arg == null;
}
module.exports = require('util-ex/lib/is/type/null-or-undefined');

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

module.exports = function(arg) {
return typeof arg === 'number';
}
module.exports = require('util-ex/lib/is/type/number');

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

module.exports = function isObject(arg) {
return arg != null && typeof arg === 'object';
}
module.exports = require('util-ex/lib/is/type/object');

@@ -1,8 +0,1 @@

var isObject = require('./isObject');
var objectToString = require('./objectToString');
var regexpClass = '[object RegExp]';
module.exports = function(v) {
return isObject(v) && objectToString(v) === regexpClass;
}
module.exports = require('util-ex/lib/is/type/regexp');

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

module.exports = function(arg) {
return typeof arg === 'string';
}
module.exports = require('util-ex/lib/is/type/string');

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

module.exports = function(arg) {
return arg === void 0;
}
module.exports = require('util-ex/lib/is/type/undefined');

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