Git Product home page Git Product logo

class's Introduction

Class

This package provides some decorators to ensure the class member visibility at runtime.

How it works

When the JS run all decorators defined for your class will wrap the original methods to check its access rules, before pass the control back to the original method if the called method is private or protected, the wrapper goes check the context to determine if the current call is granted or not.

Usage

import * as Class from '@singleware/class';

@Class.Describe()
class Example extends Class.Null {
  @Class.Private()
  private privateProperty = '';

  @Class.Protected()
  @Class.Property()
  protected protectedProperty = '';

  @Class.Public()
  @Class.Property()
  public publicProperty = '';

  @Class.Private()
  private privateMethod(): void {}

  @Class.Protected()
  protected protectedMethod(): void {}

  @Class.Public()
  public publicMethod(): void {}
}

Decorators

Name Description
Describe Wraps the decorated class to ensure its rules at runtime.
Private Makes the decorated member as private, visible only by its class.
Protected Makes the decorated member as protected, visible on by its class and derived classes
Public Makes the decorated member as public, visible by every class.
Property Makes the decorates member as enumerable to use with loop statements like for...

Methods

Name Description
perform Performs the specified callback using the specified context rules.
resolve Resolves the given wrapped context to the original context.

Install

Using npm:

npm i @singleware/class

License

MIT © Silas B. Domingos

class's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.