1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- const NodeUtils = {
- elements: [ 'x', 'y', 'z', 'w' ],
- addShortcuts: function () {
- function applyShortcut( proxy, property, subProperty ) {
- if ( subProperty ) {
- return {
- get: function () {
- return this[ proxy ][ property ][ subProperty ];
- },
- set: function ( val ) {
- this[ proxy ][ property ][ subProperty ] = val;
- }
- };
- } else {
- return {
- get: function () {
- return this[ proxy ][ property ];
- },
- set: function ( val ) {
- this[ proxy ][ property ] = val;
- }
- };
- }
- }
- return function addShortcuts( proto, proxy, list ) {
- const shortcuts = {};
- for ( let i = 0; i < list.length; ++ i ) {
- const data = list[ i ].split( '.' ),
- property = data[ 0 ],
- subProperty = data[ 1 ];
- shortcuts[ property ] = applyShortcut( proxy, property, subProperty );
- }
- Object.defineProperties( proto, shortcuts );
- };
- }()
- };
- export { NodeUtils };
|