ziishaned / dumper.js

A better and pretty variable inspector for your Node.js applications
MIT License
2.76k stars 75 forks source link

Decycle object before dump. Use safer hasOwnProperty. #5

Closed m-basov closed 6 years ago

m-basov commented 6 years ago

First of all thanks for the awesome util!

This PR tries to fix problems I encountered. I tried to dump mongo document and had two problems:

  1. On some objects there were no hasOwnProperty function. I replaced call with Object.prototype.hasOwnProperty which is at least a little bit safer;

  2. There was giant object with cyclic properties which could not be dumped because maximum call stack size exceeded. Solution for this is not ideal but it works. There is new dependency cycle and it is called for each object.

Also I've added 2 test cases to cover this fixes.

Let me know what you think!

codecov-io commented 6 years ago

Codecov Report

Merging #5 into master will increase coverage by 0.17%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
+ Coverage   93.24%   93.42%   +0.17%     
==========================================
  Files           1        1              
  Lines          74       76       +2     
  Branches       18       18              
==========================================
+ Hits           69       71       +2     
  Misses          5        5
Impacted Files Coverage Δ
src/dumper.js 93.42% <100%> (+0.17%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5150042...c74af73. Read the comment docs.