How to use the @lumino/coreutils.JSONExt.emptyObject function in @lumino/coreutils

To help you get started, we’ve selected a few @lumino/coreutils 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 / commands / src / index.ts View on Github external
  execute(id: string, args: ReadonlyPartialJSONObject = JSONExt.emptyObject): Promise {
    // Reject if the command is not registered.
    let cmd = this._commands[id];
    if (!cmd) {
      return Promise.reject(new Error(`Command '${id}' not registered.`));
    }

    // Execute the command and reject if an exception is thrown.
    let value: any;
    try {
      value = cmd.execute.call(undefined, args);
    } catch (err) {
      value = Promise.reject(err);
    }

    // Create the return promise which resolves the result.
    let result = Promise.resolve(value);
github jupyterlab / jupyterlab / packages / apputils / src / commandlinker.ts View on Github external
private _evtClick(event: MouseEvent): void {
    let target = event.target as HTMLElement;
    while (target && target.parentElement) {
      if (target.hasAttribute(`data-${COMMAND_ATTR}`)) {
        event.preventDefault();
        let command = target.getAttribute(`data-${COMMAND_ATTR}`);
        if (!command) {
          return;
        }
        let argsValue = target.getAttribute(`data-${ARGS_ATTR}`);
        let args = JSONExt.emptyObject;
        if (argsValue) {
          args = JSON.parse(argsValue);
        }
        void this._commands.execute(command, args);
        return;
      }
      target = target.parentElement;
    }
  }
github jupyterlab / lumino / packages / commands / src / index.ts View on Github external
function createKeyBinding(options: CommandRegistry.IKeyBindingOptions): CommandRegistry.IKeyBinding {
    return {
      keys: CommandRegistry.normalizeKeys(options),
      selector: validateSelector(options),
      command: options.command,
      args: options.args || JSONExt.emptyObject
    };
  }
github jupyterlab / lumino / packages / widgets / src / menu.ts View on Github external
constructor(commands: CommandRegistry, options: Menu.IItemOptions) {
      this._commands = commands;
      this.type = options.type || 'command';
      this.command = options.command || '';
      this.args = options.args || JSONExt.emptyObject;
      this.submenu = options.submenu || null;
    }
github jupyterlab / lumino / packages / widgets / src / commandpalette.ts View on Github external
constructor(commands: CommandRegistry, options: CommandPalette.IItemOptions) {
      this._commands = commands;
      this.category = normalizeCategory(options.category);
      this.command = options.command;
      this.args = options.args || JSONExt.emptyObject;
      this.rank = options.rank !== undefined ? options.rank : Infinity;
    }
github jupyterlab / lumino / packages / commands / src / index.ts View on Github external
  mnemonic(id: string, args: ReadonlyPartialJSONObject = JSONExt.emptyObject): number {
    let cmd = this._commands[id];
    return cmd ? cmd.mnemonic.call(undefined, args) : -1;
  }