https://github.com/brianneisler/object-js
Object oriented JS library for ES6
https://github.com/brianneisler/object-js
Last synced: 3 months ago
JSON representation
Object oriented JS library for ES6
- Host: GitHub
- URL: https://github.com/brianneisler/object-js
- Owner: brianneisler
- License: mit
- Created: 2016-03-15T03:24:20.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-26T00:40:54.000Z (almost 9 years ago)
- Last Synced: 2025-02-11T17:58:15.193Z (4 months ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
object-js
=============Low level Object design for ES6
## Benefits
- easy hashCode and equals hooks for determining equality between two instances## Build Status
[](https://badge.fury.io/js/object-js)
[](https://travis-ci.org/brianneisler/object-js)
[](https://nodei.co/npm/object-js/)## Install
```js
npm install --save object-js
```## Usage
```js
import js, { Obj } from 'object-js';class Thing extends Obj {
constructor(prop) {
this.prop = prop;
}
equals(value) {
return js.doesExtend(value, Thing) && value.prop === this.prop;
}hashCode() {
if (!this._hashCode) {
this._hashCode = js.hash(this.prop);
}
return this._hashCode;
}
}const thing1 = new Thing('abc');
const thing2 = new Thing('abc');
const thing3 = new Thing('bcd');js.equals(thing1, thing2) // true
js.equals(thing2, thing3) // false```