npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brave-js/inscriber

v0.2.2

Published

Class with property dependencies

Downloads

8

Readme

@brave-js/inscriber

A Simple Javascript Class which is carved out with some features to offer the property bindings for the instances

NPM version gzip size

Installation

  • yarn add @brave-js/inscriber

Design

  • Inscriber a distinct javascript class

Inscriber Class

  • The scope of the API works only within the current object / instance of the class

  • Allows addition & deletion to property binding list

  • Property binding change event is delegated via the setters / getters

  • Allows deletion of computed property

  • Computed Property value is cached. The callback is never called unless the cache is reset

  • Last but not least, you can force enable / disable cache. Default is enable cache

compute

Enables the usage of computed property within the current object / instance of the class

Parameters

  • name name of the computed property

  • properties array of properties that exists in the current object

  • method callback function which to calculate the value of the computed property

Usage

import Inscriber from '@brave-js/inscriber';

// Create the `Person` Class extending the `Inscriber` Class
class Person extends Inscriber {
    constructor(obj) {
        super();
        this.firstName = obj.firstName;
        this.lastName = obj.lastName;
        return this;
    }
}

// Instantiate the `Person` Object
var person = new Person({
    firstName: 'John',
    lastName: 'Doe'
});

// Add Computed Property `fullName` to the person object
person.compute('fullName', ['firstName', 'lastName'], function() {
    return `${this.firstName} ${this.lastName}`;
});

// Access Computed Property `fullName` from the person object
person.fullName // => Prints `John Doe`

// Now any change to the properties `firstName` & `lastName` will be derived in `fullName`
person.firstName = 'Mr';
person.lastName = 'Rob';

person.fullName // => Prints `Mr Rob`

destruct

Destructs the computed property within the current object / instance of the class

Parameters

  • name name of the computed property

Usage

import Inscriber from '@brave-js/inscriber';

// Create the `Person` Class extending the `Inscriber` Class
class Person extends Inscriber {
    constructor(obj) {
        super();
        this.firstName = obj.firstName;
        this.lastName = obj.lastName;
        return this;
    }
}

// Instantiate the `Person` Object
var person = new Person({
    firstName: 'John',
    lastName: 'Doe'
});

// Add Computed Property `fullName` to the person object
person.compute('fullName', ['firstName', 'lastName'], function() {
    return `${this.firstName} ${this.lastName}`;
});

// Access Computed Property `fullName` from the person object
person.fullName // => Prints `John Doe`

// Destructing the Computed Property will retain the value but no longer linked to the bindings
person.destruct('fullName');

// Now any change to the properties `firstName` & `lastName` will not be derived in `fullName`
person.firstName = 'Mr';
person.lastName = 'Rob';

person.fullName // => Prints `John Doe`

set

Sets the value for the property in the XPATH within the current object / instance of the class

Parameters

  • xpath XPATH of the property

  • value value for the property

Usage

import Inscriber from '@brave-js/inscriber';
Inscriber.name = {};

Inscriber.set('name.firstName', 'Mr');
Inscriber.set('name.lastName', 'Rob');

get

Retrieve the value for the property in the XPATH within the current object / instance of the class

Parameters

  • xpath XPATH of the property

Usage

import Inscriber from '@brave-js/inscriber';
Inscriber.name = {firstName : 'John', lastName: 'Doe'};

Inscriber.get('name.firstName'); // Returns `John`
Inscriber.get('name.lastName'); // Returns `Doe`

toggle

Disables the cache for all computed property of the binding property. Will be useful to reset cache at any point of time.

Parameters

  • property name of the bindings

Usage

  • firstName, lastName, street, city are binding properties

reset

Enables the cache for the computed property. Will be useful to read the old value & new value after a change

Parameters

  • name name of the computed property

Usage

  • fullName, address are computed property for binding properties firstName, lastName, street, city