antonmedv / fx

Terminal JSON viewer & processor
https://fx.wtf
MIT License
19.08k stars 438 forks source link

Strange output with docs example #133

Closed Datamance closed 2 years ago

Datamance commented 4 years ago

Hi there,

for this command presented in the docs: echo '[1,2,3]' | fx 'this.forEach(x => console.log(x))' 2>/dev/null | xargs echo

I end up getting this:

r { value: 1, type: LosslessNumber, isLosslessNumber: true } r { value: 2, type: LosslessNumber, isLosslessNumber: true } r { value: 3, type: LosslessNumber, isLosslessNumber: true }

I'm using node 13.11 and fish shell, doubt it matters though. What's this about?

antonmedv commented 4 years ago

Hi,

You are right. There is a bug in the documentation. fx uses lossless-json for parsing integers (for supporting integers bigger than 2**53, for example, int64). For outputting it as number losses number should be converted to number: console.log(+x)

antonmedv commented 2 years ago

I rewrote the entire fx in golang. So I belove this issue is no longer needed.