@selfage/lazy_instance
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@seflage/lazy_instance

Install

npm install @selfage/lazy_instance

Overview

Written in TypeScript and compiled to ES6 with inline source map & source. See @selfage/tsconfig for full compiler options. Provides a simply class to only call the provided constructoion function once, when getting the instance.

Usage

import { LazyInstance } from '@selfage/lazy_instance';

class Foo {}

let lazyFoo = new LazyInstance(() => new Foo());
let foo = lazyFoo.get(); // Instantiates Foo
let foo2 = lazyFoo.get(); // Returns the same Foo
console.log(foo === foo2);

Package Sidebar

Install

npm i @selfage/lazy_instance

Weekly Downloads

166

Version

1.0.0

License

GPL-3.0-or-later

Unpacked Size

38.4 kB

Total Files

5

Last publish

Collaborators

  • teststaybaka