Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
) {
// 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);
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;
}
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);
}
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);
}
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);
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)) {
private _normalize(value: nbformat.IOutput): void {
if (nbformat.isStream(value)) {
if (Array.isArray(value.text)) {
value.text = (value.text as string[]).join('\n');
}
}
}
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;
}