How to use the anser.ansiToText function in anser

To help you get started, we’ve selected a few anser 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 neo-one-suite / neo-one / packages / neo-one-editor / src / error / parseCompileError.ts View on Github external
export function parseCompileError(message: string): ErrorLocation | undefined {
  const lines: Array = message.split('\n');
  let fileName: string = '';
  let lineNumber: number = 0;
  let colNumber: number = 0;

  for (let i = 0; i < lines.length; i++) {
    const line: string = Anser.ansiToText(lines[i]).trim();
    if (!line) {
      continue;
    }

    if (!fileName && line.match(filePathRegex)) {
      fileName = line;
    }

    let k = 0;
    while (k < lineNumberRegexes.length) {
      const match: Array | null = line.match(lineNumberRegexes[k]);
      if (match) {
        lineNumber = parseInt(match[1], 10);
        // colNumber starts with 0 and hence add 1
        colNumber = parseInt(match[2], 10) + 1 || 1;
        break;
github reduxjs / redux-devtools / packages / redux-devtools-trace-monitor / src / react-error-overlay / utils / parseCompileError.js View on Github external
function parseCompileError(message: string): ?ErrorLocation {
  const lines: Array = message.split('\n');
  let fileName: string = '';
  let lineNumber: number = 0;
  let colNumber: number = 0;

  for (let i = 0; i < lines.length; i++) {
    const line: string = Anser.ansiToText(lines[i]).trim();
    if (!line) {
      continue;
    }

    if (!fileName && line.match(filePathRegex)) {
      fileName = line;
    }

    let k = 0;
    while (k < lineNumberRegexes.length) {
      const match: ?Array = line.match(lineNumberRegexes[k]);
      if (match) {
        lineNumber = parseInt(match[1], 10);
        // colNumber starts with 0 and hence add 1
        colNumber = parseInt(match[2], 10) + 1 || 1;
        break;
github facebook / create-react-app / packages / react-error-overlay / src / utils / parseCompileError.js View on Github external
function parseCompileError(message: string): ?ErrorLocation {
  const lines: Array = message.split('\n');
  let fileName: string = '';
  let lineNumber: number = 0;
  let colNumber: number = 0;

  for (let i = 0; i < lines.length; i++) {
    const line: string = Anser.ansiToText(lines[i]).trim();
    if (!line) {
      continue;
    }

    if (!fileName && line.match(filePathRegex)) {
      fileName = line;
    }

    let k = 0;
    while (k < lineNumberRegexes.length) {
      const match: ?Array = line.match(lineNumberRegexes[k]);
      if (match) {
        lineNumber = parseInt(match[1], 10);
        // colNumber starts with 0 and hence add 1
        colNumber = parseInt(match[2], 10) + 1 || 1;
        break;
github WebCloud / react-error-guard / src / utils / parseCompileError.js View on Github external
function parseCompileError(message) {
  const lines = message.split('\n');
  let fileName = '';
  let lineNumber = 0;
  let colNumber = 0;

  for (let i = 0; i < lines.length; i++) {
    const line = Anser.ansiToText(lines[i]).trim();
    if (!line) {
      continue;
    }

    if (!fileName && line.match(filePathRegex)) {
      fileName = line;
    }

    let k = 0;
    while (k < lineNumberRegexes.length) {
      const match = line.match(lineNumberRegexes[k]);
      if (match) {
        lineNumber = parseInt(match[1], 10);
        // colNumber starts with 0 and hence add 1
        colNumber = parseInt(match[2], 10) + 1 || 1;
        break;
github nteract / hydrogen / lib / components / output-area.js View on Github external
handleClick = () => {
    const kernel = this.props.store.kernel;
    if (!kernel || !kernel.outputStore) return;
    const output = kernel.outputStore.outputs[kernel.outputStore.index];
    const copyOutput = this.getOutputText(output);

    if (copyOutput) {
      atom.clipboard.write(Anser.ansiToText(copyOutput));
      atom.notifications.addSuccess("Copied to clipboard");
    } else {
      atom.notifications.addWarning("Nothing to copy");
    }
  };
github nteract / hydrogen / lib / services / provided / autocomplete.js View on Github external
kernel.inspect(replacedText, replacedText.length, ({ found, data }) => {
          if (!found || !data["text/plain"]) {
            resolve(null);
            return;
          }
          const description = ansiToText(data["text/plain"]);
          resolve({
            text,
            replacementPrefix,
            replacedText,
            iconHTML,
            type,
            description
          });
        });
      });

anser

A low level parser for ANSI sequences.

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis