MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / splitMultilineString

Function splitMultilineString

src/platform/common/utils.ts:241–260  ·  view source on GitHub ↗
(source: nbformat.MultilineString)

Source from the content-addressed store, hash-verified

239}
240
241export function splitMultilineString(source: nbformat.MultilineString): string[] {
242 // Make sure a multiline string is back the way Jupyter expects it
243 if (Array.isArray(source)) {
244 return source as string[];
245 }
246 const str = source.toString();
247 if (str.length > 0) {
248 // Each line should be a separate entry, but end with a \n if not last entry
249 const arr = str.split('\n');
250 return arr
251 .map((s, i) => {
252 if (i < arr.length - 1) {
253 return `${s}\n`;
254 }
255 return s;
256 })
257 .filter((s) => s.length > 0); // Skip last one if empty (it's the only one that could be length 0)
258 }
259 return [];
260}
261
262// Took this from jupyter/notebook
263// https://github.com/jupyter/notebook/blob/b8b66332e2023e83d2ee04f83d8814f567e01a4e/notebook/static/base/js/utils.js

Callers 5

translateCellErrorOutputFunction · 0.90
extractStrippedLinesMethod · 0.90
pruneCellFunction · 0.85

Calls 3

filterMethod · 0.80
mapMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected