@0x2e757/wrappers

TypeScript variable wrapper library, transpiled to ES2015 JavaScript

Latest version: 3.0.1 registry icon
Maintenance score
0
Safety score
0
Popularity score
0
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
3.0.1 0 0 0 0 0
3.0.0 0 0 0 0 0
2.2.6 0 0 0 0 0
2.2.5 0 0 0 0 0
2.2.4 0 0 0 0 0
2.2.3 0 0 0 0 0
2.2.2 0 0 0 0 0
2.2.1 0 0 0 0 0
2.2.0 0 0 0 0 0
2.1.0 0 0 0 0 0
2.0.0 0 0 0 0 0
1.2.1 0 0 0 0 0
1.2.0 0 0 0 0 0
1.1.0 0 0 0 0 0
1.0.1 0 0 0 0 0
1.0.0 0 0 0 0 0

Stability
Latest release:

3.0.1 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



Wrappers

TypeScript variable wrapper library, transpiled to ESNext JavaScript.

Install

npm i @0x2e757/wrappers

Usage

StaticWrapper

Simple wrapper that can be used as a value container. Has derived LocalStorageWrapper and SessionStorageWrapper implementation that read and save their values to corresponding storages.

Usage example:

import { StaticWrapper } from "@0x2e757/Wrappers";

const wNumber = new StaticWrapper(0);
wNumber.subscribe(console.log);

wNumber.value = 1;
wNumber.value = 2;
wNumber.value += 3;

Console output:

1
2
5

DynamicWrapper

Advanced wrapper which contains dynamically computed value (it can not be set manually). Values are being computed only before they are going to be used.

Usage example:

import { StaticWrapper, DynamicWrapper } from "@0x2e757/Wrappers";

const wUsername = new StaticWrapper("John");
const wBalance = new StaticWrapper(100);

const wAccountInfo = new DynamicWrapper(() => `${wUsername.value} has ${wBalance.value}$.`);
wAccountInfo.subscribe(console.log);

wBalance.value -= 50;

Console output:

John has 50$.

Generic Wrapper

Helper class that dynamically will return either StaticWrapper or DynamicWrapper, depending on value type (is function or not) passed to the constructor.

Usage example:

import { Wrapper } from "@0x2e757/Wrappers";

const staticWrapper = new Wrapper(0);
const dynamicWrapper = new Wrapper(() => staticWrapper.value * 2);
dynamicWrapper.subscribe(console.log);

staticWrapper.value = 5;

Console output:

10