Skip to content

Instantly share code, notes, and snippets.

@Luftare
Last active September 20, 2019 05:48
Show Gist options
  • Save Luftare/04fe10b576332f56ebd1a26d49632ac9 to your computer and use it in GitHub Desktop.
Save Luftare/04fe10b576332f56ebd1a26d49632ac9 to your computer and use it in GitHub Desktop.
class DotComment {
constructor() {
this.comment = '';
const lowerCaseAlphabets = 'abcdefghiklmnopqrstvxyzåäö'.split('');
const specialCharacters = '_'.split('');
const upperCaseAlphabets = lowerCaseAlphabets.map(char =>
char.toUpperCase()
);
const characters = [
...lowerCaseAlphabets,
...upperCaseAlphabets,
...specialCharacters,
];
characters.forEach(letter => {
Object.defineProperty(this, letter, {
get() {
const decodedLetter = letter === '_' ? ' ' : letter;
this.comment += decodedLetter;
return this;
},
});
});
}
qst() {
this.comment += '?';
return this;
}
exl() {
this.comment += '!';
return this;
}
log() {
console.log(this.comment);
}
}
new DotComment().T.h.i.s._.i.s._.a._.l.i.t.t.l.e._.s.i.l.l.y.exl().log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment