UNPKG

ts-aspect

Version:

Simplistic library for Aspect Oriented Programming in TypeScript

23 lines (22 loc) 895 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPointcutMethods = void 0; function getPointcutMethods(target, pointcut) { const unique_method_names = new Set(); let current_target = target; while (current_target !== null && current_target !== undefined) { const next_target = Object.getPrototypeOf(current_target); if (next_target === null || next_target === undefined) { break; } Object.getOwnPropertyNames(current_target) .filter(item => typeof current_target[item] === 'function' && item !== 'constructor') .filter(item => item.match(pointcut)) .forEach(item => { unique_method_names.add(item); }); current_target = next_target; } return [...unique_method_names.values()]; } exports.getPointcutMethods = getPointcutMethods;