How to use anser - 10 common examples

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 moxystudio / webpack-isomorphic-dev-middleware / lib / renderErrorMiddleware.js View on Github external
function createHtmlDocument(message) {
    const body = anser.ansiToHtml(anser.escapeForHtml(message), { use_classes: true }); // eslint-disable-line camelcase

    // CSS styles based on https://github.com/glenjamin/webpack-hot-middleware/blob/master/client-overlay.js#L5 with some slight changes
    return `

    
        
        <title>webpack-isomorphic-dev-middleware error</title>
        <style>
        body {
            background: #262626;
            color: #e6e6e6;
            line-height: 1.2;
            font-family: Menlo, Consolas, monospace;
            font-size: 13px;
            white-space: pre;
            margin: 10px;</style>
github gitlabhq / gitlabhq / app / assets / javascripts / pipelines / components / pipeline_details.vue View on Github external
.then((resp) => {
                  const log = Anser.ansiToHtml(resp.bodyText, {use_classes: true});
                  const linkedLog = Anser.linkify(log);

                  this.store.storeLog(linkedLog.split('\n'));
                })
            })
github facebook / create-react-app / packages / react-error-overlay / src / utils / generateAnsiHTML.js View on Github external
function generateAnsiHTML(txt: string, theme: Theme): string {
  const arr = new Anser().ansiToJson(entities.encode(txt), {
    use_classes: true,
  });

  let result = '';
  let open = false;
  for (let index = 0; index &lt; arr.length; ++index) {
    const c = arr[index];
    const content = c.content,
      fg = c.fg;

    const contentParts = content.split('\n');
    for (let _index = 0; _index &lt; contentParts.length; ++_index) {
      if (!open) {
        result += '<span data-ansi-line="true">';
        open = true;
      }</span>
github WebCloud / react-error-guard / src / utils / generateAnsiHTML.js View on Github external
function generateAnsiHTML(txt) {
  var arr = new Anser().ansiToJson(entities.encode(txt), {
    use_classes: true,
  });

  var result = '';
  var open = false;
  for (var index = 0; index &lt; arr.length; ++index) {
    var c = arr[index];
    var content = c.content,
      fg = c.fg;

    var contentParts = content.split('\n');
    for (var _index = 0; _index &lt; contentParts.length; ++_index) {
      if (!open) {
        result += '<span data-ansi-line="true">';
        open = true;
      }</span>
github Timer / stack-frame / packages / ansi-html-themed / src / index.js View on Github external
function generateAnsiHtml(text: string, colors: Object = {}) {
  colors = Object.assign({}, defaultColors, colors);
  const arr = new Anser().ansiToJson(text, {
    use_classes: true,
  });

  let result = '';
  let open = false;
  for (let index = 0; index &lt; arr.length; ++index) {
    const c = arr[index];
    const { content, fg } = c;
    const contentParts = content.split('\n');
    for (let _index = 0; _index &lt; contentParts.length; ++_index) {
      if (!open) {
        result += '<span data-ansi-line="true">';
        open = true;
      }
      const part = contentParts[_index].replace('\r', '');
      const color = fg == null</span>
github reduxjs / redux-devtools / packages / redux-devtools-trace-monitor / src / react-error-overlay / utils / generateAnsiHTML.js View on Github external
function generateAnsiHTML(txt: string): string {
  var arr = new Anser().ansiToJson(entities.encode(txt), {
    use_classes: true
  });

  var result = '';
  var open = false;
  for (var index = 0; index &lt; arr.length; ++index) {
    var c = arr[index];
    var content = c.content,
      fg = c.fg;

    var contentParts = content.split('\n');
    for (var _index = 0; _index &lt; contentParts.length; ++_index) {
      if (!open) {
        result += '<span data-ansi-line="true">';
        open = true;
      }</span>

anser

A low level parser for ANSI sequences.

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis