ramda / repl

The Ramda REPL
34 stars 15 forks source link

Support NaN undefined Infinity in console.log output #65

Closed briancodes closed 4 years ago

briancodes commented 5 years ago

Currently the console.log in the Ramda Repl displays undefined as null in arrays, and doesn't display object properties that have a value of undefined. The global properties NaN and Infinity are also displayed as null in arrays and objects.

This has caught me out a few times - so I thought I'd have a go at putting in a fix! Will close #49

Example of problem from the Repl

console.log(
  [null, undefined, NaN, Infinity, -Infinity], 
  { a: null, b:undefined, c:NaN, d:Infinity, e:-Infinity}
)  
[null,null,null,null,null]
{"a":null,"c":null,"d":null,"e":null}

I added a replacer function to the JSON.stringify method of logger.js - which covers common properties that JSON.stringify doesn't support. Updated the tests, and all passing (although two unrelated tests intermittently fail - this this is being addressed in PR #57 I think)

image

CrossEye commented 5 years ago

:herb:

LGTM. Anyone else, @ramda/ramda-docs? @ramda/core?

CrossEye commented 4 years ago

@briancodes: I'm sorry this one was allowed to languish. There hasn't been a lot of work on Ramda lately. I will try to rectify this over the next few months, and although GitHub won't let me reopen this because the repo was deleted, I will try to look at the commits soon. I think this makes sense.