]> gerrit.simantics Code Review - simantics/district.git/blob - get-property-names.js
54a01e5047a392b3edaf3af7d28f123ea39d13e2
[simantics/district.git] / get-property-names.js
1 'use strict';
2
3 var uniq  = require('../array/#/uniq')
4   , value = require('./valid-value')
5
6   , push = Array.prototype.push
7   , getOwnPropertyNames = Object.getOwnPropertyNames
8   , getPrototypeOf = Object.getPrototypeOf;
9
10 module.exports = function (obj) {
11         var keys;
12         obj = Object(value(obj));
13         keys = getOwnPropertyNames(obj);
14         while ((obj = getPrototypeOf(obj))) {
15                 push.apply(keys, getOwnPropertyNames(obj));
16         }
17         return uniq.call(keys);
18 };