Created
April 3, 2016 14:43
-
-
Save silkentrance/21a7016933b0e7d7338f969ba928a457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { decorate } from './private/utils'; | |
// WIP: prototypical, might not be working at all, needs additional work! | |
function findSuperDesc(superklass, key) | |
{ | |
let result; | |
let supklass = superklass; | |
while (supklass.prototype) | |
{ | |
if (Object.hasOwnProperty(supklass, key)) | |
{ | |
result = supklass; | |
break; | |
} | |
supklass = Object.getPrototypeOf(supklass); | |
} | |
return result; | |
} | |
function handleDescriptor(target, key, descriptor) { | |
const superKlass = Object.getPrototypeOf(target); | |
const superDesc = findSUperDesc(superKlass, key); | |
return { | |
...superDesc, | |
value: descriptor.value, | |
initializer: descriptor.initializer, | |
get: descriptor.get || superDesc.get, | |
set: descriptor.set || superDesc.set | |
}; | |
} | |
export default function extendDescriptor(...args) { | |
return decorate(handleDescriptor, args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment