Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants