🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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

to
2.1.4

10

lib/Error.js
(function() {
module.exports = require('abstract-error');
var e;
try {
module.exports = require('abstract-error');
} catch (_error) {
e = _error;
console.error("the AbstractError has moved to `abstract-error` package\nnpm install abstract-error first");
throw e;
}
}).call(this);
//# sourceMappingURL=Error.js.map

3

package.json
{
"name": "abstract-object",
"version": "2.1.3",
"version": "2.1.4",
"description": "AbstractObject with Object State Events Support",

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

"dependencies": {
"abstract-error": "^1.0.1",
"custom-ability": "~1.2.3",

@@ -23,0 +22,0 @@ "events-ex": "~1.1.0",

@@ -50,3 +50,14 @@ ### 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)

**Note**: the eventable ability must be after the stateable. like this:
```coffee
stateable = require 'abstract-object/ability'
eventable = require 'events-ex/ability'
class MyObject
stateable MyObject
eventable MyObject # MUST BE after stateable
```
# AbstractObject

@@ -178,85 +189,4 @@

Moved to [abstract-error](https://github.com/snowyu/abstract-error.js).
It has moved to [abstract-error](https://github.com/snowyu/abstract-error.js).
## AbstractError
All Errors are derived from the AbstractError.
* Members:
* message: the error message.
* code: the error code.
* Methods:
* ok()
* notFound()
* ....
* invalidFormat()
* Class Methods:
* AbstractError.isOk(err)
* AbstractError.isNotFound(err)
* ...
the error codes:
* AbstractError.Ok = 0
* AbstractError.NotFound = 1
* AbstractError.Corruption = 2
* AbstractError.NotSupported = 3
* AbstractError.InvalidArgument = 4
* AbstractError.IO = 5
* AbstractError.NotOpened = 6
* AbstractError.InvalidType = 7
* AbstractError.InvalidFormat = 8
## Other Error Classes:
* NotFoundError
* CorruptionError
* NotSupportedError/NotImplementedError
* InvalidArgumentError
* IOError
* NotOpenedError
* InvalidTypeError
* InvalidFormatError
## Extends the AbstractError
use the `createError` function can extend the AbstractError.
createError(typeName, errorCode[, parentErrorClass])
__arguments__
* typeName *(string)*: the error type name, the first character must be upper case.
* errorCode: *(number)*: the error code, it should be greater than 1000.
* parentErrorClass: *(class)*: the optional parent error class. defaults to AbstractError.
__return__
* the error class
### Usage
```js
var Errors = require("abstract-object/Error")
var AbstractError = Errors.AbstractError
var createError = Errors.createError
var AlreadyReadError = createError('AlreadyRead', 10000)
var err = new AlreadyReadError("already read over error.")
assert.ok(AbstractError.isAlreadyRead(err))
assert.ok(AlreadyReadError.isAlreadyRead(err))
assert.ok(err.alreadyRead())
assert.equal(err.message, "already read over error.")
assert.equal(err.code, 10000)
```
# Enhanced Inheritance Functions

@@ -263,0 +193,0 @@

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