GithubHelp home page GithubHelp logo

Comments (3)

kapooostin avatar kapooostin commented on May 29, 2024

I'm not sure why you use console.log as a base object for this module. The docs do not suggest any use for that.
I changed console.log to {} here

const log = console.log;
and it fixed the issue.

from log-utils.

doowb avatar doowb commented on May 29, 2024

Hi @kapooostin thanks for the issue. I just ran into this too and will try to get a fix in place. Feel free to submit a PR with the fix if you'd like.

For some background... the ansi-colors package used to handle lazy loading differently and log-utils made use of that feature by extending it. During the refactor of log-utils, ansi-colors was updated to a version that does not require the same type of lazy loading.

Also, since the docs and tests all show passing the returned value from log to console.log, I think the update you're suggesting is a good one.

from log-utils.

kapooostin avatar kapooostin commented on May 29, 2024

Hi @doowb
To pass the tests I have to use an empty function instead of an object.
If I ignore the first test checking for the type of the module export, then this code passes:

'use strict';

const timestamp = require('time-stamp');
const colors = require('ansi-colors');

const log = {
  error: colors.red(colors.symbols.cross),
  info: colors.cyan(colors.symbols.info),
  success: colors.green(colors.symbols.check),
  warning: colors.yellow(colors.symbols.warning),
  timestamp: () => {
    return '[' + colors.gray(timestamp('HH:mm:ss')) + ']';
  },
  ok: str => {
    let ok = colors.green(colors.symbols.check);
    return str.replace(/^(\s*)(.*?)$/, (m, s, v) => {
      return s + ok + ' ' + v;
    });
  },
  heading: (...args) => {
    let str = args.filter(v => v !== void 0).map(String).join(' ');
    return colors.bold.underline(str);
  },
};

log.__proto__ = colors;
module.exports = log;

Though the tests do not check the actual values and output of defined functions. But they test for the things, not mentioned in docs or examples, for instance for log.symbols property.

After the change above there is no lazy loading for the first four properties, as far as I understand.

from log-utils.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.