1.0.3 • Published 6 years ago

@fabiospampinato/lockable v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago