JSPM

object-js

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q31819F
  • License MIT

Object oriented JS library for ES6

Package Exports

  • object-js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

object-js

Low level Object design for ES6

Benefits

  • easy hashCode and equals hooks for determining equality between two instances

Build Status

npm version
Build Status
NPM

Install

npm install --save object-js

Usage

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