inspectable

Make the output of a class instance in the console meaningful

Usage no npm install needed!

<script type="module">
  import inspectable from 'https://cdn.skypack.dev/inspectable';
</script>

README

NPM version Build Status NPM downloads

Inspectable - Make the output of a class instance in the console meaningful

📖 Documentation

Installation

Node.js 12.0.0 or newer is required

Yarn

Recommended

yarn add inspectable

NPM

npm i inspectable

Example usage

import { inspectable } from 'inspectable';

class APIRequest {
    public method = 'pay';

    private token = 'super-private';
}

const request = new APIRequest();

console.log(request);
// APIRequest { method: 'pay', token: 'super-private' }

inspectable(APIRequest, {
    serialize(instance) {
        return {
            method: instance.method
        };
    }
});

console.log(request);
// APIRequest {
//   method: 'pay'
// }

Decorators

import 'reflect-metadata';
import { Inspectable, Inspect } from 'inspectable';

@Inspectable({/* options */})
class APIRequest {
    @Inspect
    public method = 'pay';

    private token = 'super-private';
}

const request = new APIRequest();

console.log(request);
// APIRequest {
//   method: 'pay'
// }