Library
Extends:
A local library that can be served.
Example:
import { Library } from 'remote-lib';
const library = new Library(context);
Constructor Summary
Public Constructor | ||
public |
constructor(context: object, opts: object) Create a local library with a given context. |
Method Summary
Public Methods | ||
public |
serve(stream: Stream): void Serve this library to other peer. |
Inherited Summary
From class ReferenceContext | ||
public static |
isValidReference(reference: *): boolean Check if the given reference is valid. |
|
public get |
The the number of values in this context including it's parents. |
|
public get |
The the number of values in this context (excluding the parents). |
|
public get |
The the number of keys in this context (excluding the parents). |
|
public get |
Get the parent context. |
|
public get |
The the number of keys in this context including it's parents. |
|
public |
Assign a new reference for the given value or return it's current reference. |
|
public |
clear(): void Clear and release all the values on this context. |
|
public |
Create a closure context for this context. |
|
public |
copyFrom(context: ReferenceContext | Map | Array | object): ReferenceContext Copy from other context it's references and values |
|
public |
Remove the given reference from this context. |
|
public |
Check if this context or one of it's parents has the given value. |
|
public |
forEach(callback: function, thisArg: *): ReferenceContext Iterate over the context own values. |
|
public |
Generate a reference for the |
|
public |
Get the reference value on this context or it's parents. |
|
public |
Check if this context or it's parents has the given reference. |
|
public |
hasOwnReference(reference: Reference): boolean Check if this context only (and not the parents) has the given reference. |
|
public |
Get the reference of the given value in this context or one of it's parents. Return undefined if the value not exists. |
|
public |
Check if this context only (excluding the parents) has the given value. |
|
public |
Release a value from this context and remove any reference for this value. |
|
public |
set(reference: Reference, value: *): ReferenceContext Set a reference for the given value. |
|
public |
Get the instance constructor name. |
From class AssignableContext | ||
public |
generateReference(): * |
From class Context | ||
public static |
isReferable(value: *): boolean Check if the given value is unique per this environment. |
|
public |
clear() |
|
public |
fetch(reference: Reference): LocalPromise Fetch a local reference and return a local promise. |
|
public |
release(value: *): * |
|
public |
remote(stream: Stream, opts: object): RemoteContext Get the remote context of this context. |
|
public |
resolve(value: *): LocalPromise Resolve a local value and return a local promise to that value. |
|
public |
set(reference: *, value: *): * |
Public Constructors
public constructor(context: object, opts: object) source
Create a local library with a given context.
Override:
Context#constructorParams:
Name | Type | Attribute | Description |
context | object | The library context |
|
opts | object |
|
Context & RemoteSession options |
opts.env | EnvContext |
|
An alternative environment context (Default: |
Public Methods
public serve(stream: Stream): void source
Serve this library to other peer. A single library can be served to multiple peers, each peer will get a separate copy of the library.
Params:
Name | Type | Attribute | Description |
stream | Stream | a duplex stream to other peer remote-library |
Return:
void |