How to use the @jupyterlab/coreutils.nbformat.isStream function in @jupyterlab/coreutils

To help you get started, we’ve selected a few @jupyterlab/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 / jupyterlab-data-explorer / jupyterlab / packages / outputarea / src / model.ts View on Github external
) {
      // In order to get a list change event, we add the previous
      // text to the current item and replace the previous item.
      // This also replaces the metadata of the last item.
      this._lastStream += value.text as string;
      this._lastStream = Private.removeOverwrittenChars(this._lastStream);
      value.text = this._lastStream;
      let item = this._createItem({ value, trusted });
      let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }

    if (nbformat.isStream(value)) {
      value.text = Private.removeOverwrittenChars(value.text as string);
    }

    // Create the new item.
    let item = this._createItem({ value, trusted });

    // Update the stream information.
    if (nbformat.isStream(value)) {
      this._lastStream = value.text as string;
      this._lastName = value.name;
    } else {
      this._lastStream = '';
    }

    // Add the item to our list and return the new length.
    return this.list.push(item);
github jupyterlab / jupyterlab-data-explorer / packages / outputarea / src / model.ts View on Github external
private _add(value: nbformat.IOutput): number {
    let trusted = this._trusted;

    // Normalize the value.
    Private.normalize(value);

    // Consolidate outputs if they are stream outputs of the same kind.
    if (
      nbformat.isStream(value) &&
      this._lastStream &&
      value.name === this._lastName
    ) {
      // In order to get a list change event, we add the previous
      // text to the current item and replace the previous item.
      // This also replaces the metadata of the last item.
      this._lastStream += value.text as string;
      this._lastStream = Private.removeOverwrittenChars(this._lastStream);
      value.text = this._lastStream;
      let item = this._createItem({ value, trusted });
      let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / outputarea / src / model.ts View on Github external
let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }

    if (nbformat.isStream(value)) {
      value.text = Private.removeOverwrittenChars(value.text as string);
    }

    // Create the new item.
    let item = this._createItem({ value, trusted });

    // Update the stream information.
    if (nbformat.isStream(value)) {
      this._lastStream = value.text as string;
      this._lastName = value.name;
    } else {
      this._lastStream = '';
    }

    // Add the item to our list and return the new length.
    return this.list.push(item);
  }
github jupyterlab / jupyterlab / packages / outputarea / src / model.ts View on Github external
let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }

    if (nbformat.isStream(value)) {
      this._removeOverwrittenChars(value);
    }

    // Create the new item.
    let item = this._createItem({ value, trusted });

    // Update the stream information.
    if (nbformat.isStream(value)) {
      this._lastStream = value.text as string;
      this._lastName = value.name;
    } else {
      this._lastStream = '';
    }

    // Add the item to our list and return the new length.
    return this.list.push(item);
  }
github jupyterlab / jupyterlab / packages / outputarea / src / model.ts View on Github external
value.name === this._lastName) {
      // In order to get a list change event, we add the previous
      // text to the current item and replace the previous item.
      // This also replaces the metadata of the last item.
      this._lastStream += value.text as string;
      value.text = this._lastStream;
      this._removeOverwrittenChars(value);
      let item = this._createItem({ value, trusted });
      let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }

    if (nbformat.isStream(value)) {
      this._removeOverwrittenChars(value);
    }

    // Create the new item.
    let item = this._createItem({ value, trusted });

    // Update the stream information.
    if (nbformat.isStream(value)) {
      this._lastStream = value.text as string;
      this._lastName = value.name;
    } else {
      this._lastStream = '';
    }

    // Add the item to our list and return the new length.
    return this.list.push(item);
github jupyterlab / jupyterlab / packages / outputarea / src / model.ts View on Github external
private _add(value: nbformat.IOutput): number {
    let trusted = this._trusted;

    // Normalize the value.
    this._normalize(value);

    // Consolidate outputs if they are stream outputs of the same kind.
    if (nbformat.isStream(value) && this._lastStream &&
        value.name === this._lastName) {
      // In order to get a list change event, we add the previous
      // text to the current item and replace the previous item.
      // This also replaces the metadata of the last item.
      this._lastStream += value.text as string;
      value.text = this._lastStream;
      this._removeOverwrittenChars(value);
      let item = this._createItem({ value, trusted });
      let index = this.length - 1;
      let prev = this.list.get(index);
      prev.dispose();
      this.list.set(index, item);
      return index;
    }

    if (nbformat.isStream(value)) {
github jupyterlab / jupyterlab / packages / outputarea / src / model.ts View on Github external
private _normalize(value: nbformat.IOutput): void {
    if (nbformat.isStream(value)) {
      if (Array.isArray(value.text)) {
        value.text = (value.text as string[]).join('\n');
      }
    }
  }
github jupyter / nbdime / packages / nbdime / src / diff / model / output.ts View on Github external
hasMimeType(mimetype: string): string | string[] | null {
    let outputs = this.base || this.remote!;
    if (nbformat.isStream(outputs) &&
        TEXT_MIMETYPES.indexOf(mimetype) !== -1) {
      return 'text';
    } else if (nbformat.isError(outputs)) {
      return 'traceback';
    } else if (nbformat.isExecuteResult(outputs) || nbformat.isDisplayData(outputs)) {
      let data = outputs.data;
      if (mimetype in data) {
        return ['data', mimetype];
      }
    }
    return null;
  }