Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

forwardit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forwardit

Forwarding marker and installer

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

forwardit

Forwarding marker and installer.

Installation

npm i forwardit

Usage

Basic usage in JavaScript:

const { forward, installForwards, uninstallForwards } = require('forwardit');

class Data {
  @forward
  value = 0;

  @forward
  inc() {
    this.value++;
  }
}

const data = new Data();
const broker = {};

installForwards(broker, data);
console.log(broker.value, data.value); // 0, 0

broker.inc();
console.log(broker.value, data.value); // 1, 1

data.inc();
console.log(broker.value, data.value); // 2, 2

uninstallForwards(broker, data);
console.log(broker.value, data.value); // undefined, 2

For TypeScript, we need to argument broker's type information to avoid compiler errors and make code completion working correctly:

// declare Broker as usual
class Broker {
  // Broker's own properties
}

// argument Broker with selected properties from Data
interface Broker extends Pick<Data, 'value' | 'inc'> {}

// create instances, install forwards...

// now code completion works for "value" and "inc", no more compiler errors
broker.value;
broker.inc;

Keywords

forward

FAQs

Package last updated on 13 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts