reference-context
v0.2.1
Published
Creates a virtual context that can hold values with given references.
Downloads
8
Maintainers
Readme
Reference-context
Creates a virtual context that can hold values with given references 💫.
Reference-context allows you to lookup values on the context, get the number of references or values currently on the context and even assign a new unique reference to a given value.
This library is the core context of the libraries remote-lib and remote-context.
Install
npm install reference-context
Usage
const ReferenceContext = require('reference-context');
class Foo {}
const foo = new Foo();
const parent = new ReferenceContext({ Object });
const referenceContext = new ReferenceContext({ foo }, parent);
parent.count; // 1
referenceContext.count; // 2
referenceContext.ownCount; // 1
referenceContext.has('Object'); // true
referenceContext.hasOwnReference('Object'); // false
referenceContext.hasOwnReference('foo'); // true
referenceContext.exists(Object); // true
referenceContext.own(Object); // false
referenceContext.get('Object'); // Object
referenceContext.get('foo'); // foo
referenceContext.lookup(Object); // "Object"
referenceContext.lookup(foo); // "foo"
API Reference
This module is a part of the remote-lib
library.
Here is the relevant documentation for this module:
© 2017 Moshe Simantov
Licensed under the Apache License, Version 2.0.