-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgetownpropertynames.js
34 lines (26 loc) · 1.02 KB
/
getownpropertynames.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Source: https://github.com/ExtendScript/extendscript-es5-shim/blob/master/Object/getOwnPropertyNames.js
if (!Object.getOwnPropertyNames) {
Object.getOwnPropertyNames = function(obj) {
if (Object(obj) !== obj) {
throw new TypeError('Object.getOwnPropertyNames can only be called on Objects.');
}
var result = [];
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
var properties = obj.reflect.properties;
var methods = obj.reflect.methods;
var all = methods.concat(properties);
for (var i = 0; i < all.length; i++) {
var prop = all[i].name;
if (hasOwnProperty.call(obj, prop) && !(propertyIsEnumerable.call(obj, prop))) {
result.push(prop);
}
};
return result;
};
}