npm.io
38.4.1 • Published 1 year ago

@js-dot/frame

Licence
ISC
Version
38.4.1
Deps
0
Size
126 kB
Vulns
0
Weekly
0

@js-dot/frame

Name Version Downloads
@js-dot/frame

Makes Framework

Submodules

  • @js-dot/frame/template

rely

rely is dependency injection like inject as commonly in other module. Makes easy singleton patterns without change original source as simply explain.

class Foo {}

const a = rely(Foo);
const b = rely(Foo);

console.assert(a === b, 'a and b is not a same instance');

relyify and relify are compound word of rely + -ify, mean to make something available to rely function.

class Foo {}
class Bar {}

// make Foo `rely-ify` as Bar
relyify({token: Foo, class: Bar});

const a = rely(Foo);
const b = rely(Bar);

console.assert(a === b, 'a and b is not a same instance')

Use relyify to rely anything.

relyify({
    token: 'foo',
    value: 1,
    // this option makes token 'foo' as available to re-rely-ify
    override: true
});

// Returns 1
let foo = rely('foo');

relyify({
    token: 'foo',
    value: 2
});

// Returns 2
foo = rely('foo');