diff --git a/src/vs/base/common/decorators.ts b/src/vs/base/common/decorators.ts index e7330957a461aab0615c17597cbf7eaf65d0fbc2..8b83c71bafa35edc5011fecab6bd3f735d126473 100644 --- a/src/vs/base/common/decorators.ts +++ b/src/vs/base/common/decorators.ts @@ -5,6 +5,27 @@ 'use strict'; +export function createDecorator(mapFn: (fn: Function) => Function): Function { + return (target: any, key: string, descriptor: any) => { + let fnKey: string = null; + let fn: Function = null; + + if (typeof descriptor.value === 'function') { + fnKey = 'value'; + fn = descriptor.value; + } else if (typeof descriptor.get === 'function') { + fnKey = 'get'; + fn = descriptor.get; + } + + if (!fn) { + throw new Error('not supported'); + } + + descriptor[fnKey] = mapFn(fn); + }; +} + export function memoize(target: any, key: string, descriptor: any) { let fnKey: string = null; let fn: Function = null;