Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: obj.hasOwnProperty is not a function at filterKeys #7

Open
qwabra opened this issue Jun 18, 2018 · 1 comment · May be fixed by #8
Open

TypeError: obj.hasOwnProperty is not a function at filterKeys #7

qwabra opened this issue Jun 18, 2018 · 1 comment · May be fixed by #8

Comments

@qwabra
Copy link

qwabra commented Jun 18, 2018

err in nodejs http.reques

const http = require("http");
const treeify = require('treeify');
let r = http.request({
    hostname: 'ya.ru'
}, (_r) => {
    let str = treeify.asTree(_r);
    console.log(str);
});
r.on('error', console.error);
r.write('');
r.end();

https://github.com/notatestuser/treeify/blob/master/treeify.js#L32

  let count = ((count = 0, timer = null) => () => {
    count++;
    clearTimeout(timer)
    timer = setTimeout(() => {
      console.log(`"if (!obj.hasOwnProperty)" counted:${count}`)
    }, 1e3);
  })()
  function filterKeys(obj, hideFunctions) {
    var keys = [];
    for (var branch in obj) {
      // always exclude anything in the object's prototype
      if (!obj.hasOwnProperty) count()
      if (!obj.hasOwnProperty || !obj.hasOwnProperty(branch)) {
        continue;
      }
      // ... and hide any keys mapped to functions if we've been told to
      if (hideFunctions && ((typeof obj[branch]) === "function")) {
        continue;
      }
      keys.push(branch);
    }
    return keys;
  }

result:
"if (!obj.hasOwnProperty)" counted:71

@notatestuser
Copy link
Owner

Pull requests welcome

huafu added a commit to huafu/treeify that referenced this issue Jul 9, 2018
@huafu huafu linked a pull request Jul 9, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants