get-property-names.js 444 B

123456789101112131415161718
  1. 'use strict';
  2. var uniq = require('../array/#/uniq')
  3. , value = require('./valid-value')
  4. , push = Array.prototype.push
  5. , getOwnPropertyNames = Object.getOwnPropertyNames
  6. , getPrototypeOf = Object.getPrototypeOf;
  7. module.exports = function (obj) {
  8. var keys;
  9. obj = Object(value(obj));
  10. keys = getOwnPropertyNames(obj);
  11. while ((obj = getPrototypeOf(obj))) {
  12. push.apply(keys, getOwnPropertyNames(obj));
  13. }
  14. return uniq.call(keys);
  15. };