Created
April 29, 2017 19:03
-
-
Save wdiasvargas/0824832f372515c163cbee556bae31c2 to your computer and use it in GitHub Desktop.
proxy ES6 with babel
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
/** | |
* Created by William Dias on 29/04/17. | |
* www.williamdiasvargas.com.br | |
*/ | |
'use strict' | |
class Usuario { | |
constructor (login, senha) { | |
this.login = login; | |
this.senha = senha; | |
} | |
} | |
const proxy = new Proxy(usuario, { | |
get(alvo, propriedade) { | |
console.log(`${propriedade} foi solicitada`); | |
return alvo[propriedade]; | |
} | |
}); | |
console.log(proxy.login); | |
console.log(proxy.senha); | |
const usuario = new Usuario('SuperJS', '123'); | |
console.log(usuario.login); //SuperJS | |
console.log(usuario.senha);//123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
executo o babel-node e essa é uma parte da saida pelo terminal
var proxy = new Proxy(usuario, {
^
TypeError: Cannot create proxy with a non-object as target or handler