Skip to main content

Box - API

Wraps a value into a box to pass it by reference.

Installation

npm is the default package manager for Node.js, and to where tscommon is published.
Your project is using npm if it has a package-lock.json file in its root folder.

Run the following command in your terminal:

terminal
npm install @tscommon/box

Usage

main.ts
import { Box } from '@tscommon/box';

function increment(counter: Box<number>): void {
counter.value++;
}

const counter = new Box(0);

increment(counter);

console.log(counter.value); // 1