Skip to content

String error property is set, making error in third party module #2

@zazabe

Description

@zazabe

String object has a strange behavior when rconsole is present:

$ node
> "toto".error
undefined
> require('rconsole')
> "toto".error
'\u001b[31mtoto\u001b[39m'

I'm using a module making a test on parsed error property, this module is broken because of this strange issue...

consider an API (Mailchimp in some cases) with response like that :

  • failed: {"error":"error message"}
  • successful: "value"
var data = JSON.parse(response);
// failed : data.error = "\u001b[31value\u001b[39m"
// successful : data.error = "error message"

if(data.error){...} //always true

I think the problem is to use https://github.com/Marak/colors.js, with String.prototype extension, but i suspect rconsole to do the same by setting error property on objects.

Is it smell not good or I miss something ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions