Home Reference Source
import Library from 'remote-lib/lib/Library.js'
public class | source

Library

Extends:

ReferenceContextAssignableContextContext → Library

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(value: *): Reference

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

Copy from other context it's references and values

public

delete(reference: Reference): boolean

Remove the given reference from this context.

public

exists(value: *): boolean

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 assign method.

public

get(reference: Reference): * | undefined

Get the reference value on this context or it's parents.

public

has(reference: Reference): boolean

Check if this context or it's parents has the given reference.

public

Check if this context only (and not the parents) has the given reference.

public

lookup(value: *): Reference | undefined

Get the reference of the given value in this context or one of it's parents. Return undefined if the value not exists.

public

own(value: *): boolean

Check if this context only (excluding the parents) has the given value.

public

release(value: *): boolean

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
From class Context
public static

isReferable(value: *): boolean

Check if the given value is unique per this environment.

public

clear()

public

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#constructor

Params:

NameTypeAttributeDescription
context object

The library context

opts object
  • optional

Context & RemoteSession options

opts.env EnvContext
  • optional

An alternative environment context (Default: es6-unstable)

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:

NameTypeAttributeDescription
stream Stream

a duplex stream to other peer remote-library

Return:

void

See: