@fabiospampinato/lockable
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Lockable

A base class that implements lock/unlock-related functionalities.

Install

$ npm install --save @fabiospampinato/lockable

Usage

import Lockable from '@fabiospampinato/lockable';

class Safe extends Lockable {}

const safe = new Safe ();

safe.isLocked (); // false
safe.isLocked ( 'numpad' ); // false

safe.lock ();
safe.lock ( 'numpad' );

safe.isLocked (); // true
safe.isLocked ( 'numpad' ); // true

safe.unlock ();
safe.unlock ( 'numpad' );

safe.isLocked (); // false
safe.isLocked ( 'numpad' ); // false

API

new Lockable ()

Returns a new instance of Lockable.

.isLocked ( namespace?: string ): boolean

Returns a boolean indicating if a particular namespace is locked or not.

.lock ( namespace?: string ): this

.isLocked ( namespace ) will return true.

.unlock ( namespace?: string ): this

.isLocked ( namespace ) will return false.

License

MIT © Fabio Spampinato

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i @fabiospampinato/lockable

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    7.75 kB

    Total Files

    9

    Last publish

    Collaborators

    • fabiospampinato