chore: es6 base64 parser (#75)

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
This commit is contained in:
Grant Timmerman 2020-04-29 13:15:00 -07:00 committed by GitHub
parent 6c223e2c34
commit d042ef1dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -1,15 +1,16 @@
function Parser(decorator) {
this.decorator = decorator;
}
Parser.prototype.parse = function(payload) {
let toparse = payload;
if (this.decorator) {
toparse = this.decorator.parse(payload);
class Base64Parser {
constructor(decorator) {
this.decorator = decorator;
}
return Buffer.from(toparse, "base64").toString();
};
parse(payload) {
let payloadToParse = payload;
if (this.decorator) {
payloadToParse = this.decorator.parse(payload);
}
module.exports = Parser;
return Buffer.from(payloadToParse, "base64").toString();
}
}
module.exports = Base64Parser;