nightwatch
Version:
Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.
28 lines (23 loc) • 684 B
JavaScript
const reserved = [
'constructor',
'isPrototypeOf',
'propertyIsEnumerable',
'toString',
'valueOf',
'toLocaleString'
];
const isObjectPrototype = (item) => {
return item.constructor.name === 'Object' && Object.getPrototypeOf(item) === null;
};
module.exports = function(instance, additionalReserved = []) {
const result = new Set();
while (instance && !isObjectPrototype(instance)) {
Object.getOwnPropertyNames(instance).forEach(p => {
if ((typeof instance[p] == 'function') && !reserved.includes(p) && !additionalReserved.includes(p)) {
result.add(p);
}
});
instance = Object.getPrototypeOf(instance);
}
return [...result];
};