How to use @lumino/collections - 3 common examples

To help you get started, we’ve selected a few @lumino/collections examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / lumino / packages / datastore / src / datastore.ts View on Github external
static create(options: Datastore.IOptions): Datastore {
    let {schemas} = options;
    // Throws an error for invalid schemas:
    Private.validateSchemas(schemas);

    let context =  {
      inTransaction: false,
      transactionId: '',
      version: 0,
      storeId: options.id,
      change: {},
      patch: {},
    };

    let tables = new BPlusTree>(Private.recordCmp);
    if (options.restoreState) {
      // If passed state to restore, pass the intital state to recreate each
      // table
      let state = JSON.parse(options.restoreState);
      tables.assign(map(schemas, s => {
        return Table.recreate(s, context, state[s.id] || []);
      }));
    } else {
      // Otherwise, simply create a new, empty table
      tables.assign(map(schemas, s => {
        return Table.create(s, context);
      }));
    }

    return new Datastore(context, tables, options.adapter);
  }
github jupyterlab / lumino / packages / messaging / src / index.ts View on Github external
export
  function setExceptionHandler(handler: ExceptionHandler): ExceptionHandler {
    let old = exceptionHandler;
    exceptionHandler = handler;
    return old;
  }

  /**
   * A type alias for a posted message pair.
   */
  type PostedMessage = { handler: IMessageHandler | null, msg: Message | null };

  /**
   * The queue of posted message pairs.
   */
  const messageQueue = new LinkedList();

  /**
   * A mapping of handler to array of installed message hooks.
   */
  const messageHooks = new WeakMap>();

  /**
   * A set of message hook arrays which are pending cleanup.
   */
  const dirtySet = new Set>();

  /**
   * The message loop exception handler.
   */
  let exceptionHandler: ExceptionHandler = (err: Error) => {
    console.error(err);
github jupyterlab / lumino / packages / datastore / src / table.ts View on Github external
* Construct a new datastore table.
   *
   * @param schema - The schema for the table.
   *
   * @param context - The datastore context.
   */
  private constructor(schema: S, context: Datastore.Context, records?: IterableOrArrayLike>) {
    this.schema = schema;
    this._context = context;
    if (records) {
      this._records.assign(records);
    }
  }

  private _context: Datastore.Context;
  private _records = new BPlusTree>(Private.recordCmp);
}


/**
 * The namespace for the `Table` class statics.
 */
export
namespace Table {
  /**
   * A type alias for the table update type.
   */
  export
  type Update<s> = {
    readonly [recordId: string]: Record.Update<s>;
  };
</s></s>

@lumino/collections

Lumino Generic Collections

BSD-3-Clause
Latest version published 6 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages