1.1.2 • Published 4 years ago

examine-instance v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

examine-instance

Greenkeeper badge

Build Status

examine-instance inspects an object and its prototype and catalogues the properties and methods. Categorises methods as private if they are prefixed or suffixed by an underscore, otherwise marks as public.

Installation

npm install examine-instance -S

Usage

import examine from "examine-instance";

class MyClass {

  constructor() {
    this._property1 = "";
    this._isGood = true;
  }

  get isGood() { return this._isGood; }
  get property1() { return this._property1; }
  set property1(value) { this._property1 = value; }

  method1(value) {
    return value;
  }

  method2_(value) {
    return value;
  }
}

const instance = new MyClass();
const result = examine(instance);

/*
{
  methods: [ 'method1', 'method2_' ],
  privateMethods: [ 'method2_' ],
  publicMethods: [ 'method1' ],
  attributes: [ '_property1', '_isGood' ],
  readOnly: [ 'isGood' ],
  readWrite: [ 'property1' ],
  writeOnly: []
}

*/
1.1.2

4 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago