I’m trying to group functions together in javascript, though I have some difficulty understanding how to keep track of the groups. In the below example, my question is: How does: “some.get(‘anotherContent’)” knows that it’s queried under alias “anotherSomeSome” and not “anotherSome” – What I mean is, how to keep the track of the different aliases in this model? Below is what I have tried, but I find it quiet complex and hard to keep track of the aliases:
class someClass {
alias(callback) {
callback();
return this;
}
get(content) {
return 'some' + content;
}
}
const some = new someClass();
some.alias('some', () => {
some.alias('anotherSome', () => {
some.get('content')
})
some.get('contents')
some.alias('anotherSomeSome', () {
some.get('anotherContent')
})
})