-
|
Thanks for creating this project! I'm banishing I'm interested in learning how to build an extension to micromark, but the code is a bit difficult to navigate due to the absence of type annotations. I'm patching some of the types as I go, but I ran into a conceptual roadblock with the use of Consider this code from function tokenizeNoteEnd(effects, ok, nok) {
// what type is `this`?
var self = this
return start
function start(code) {
var index = self.events.length
var hasStart
// Find an opening.
while (index--) {
if (self.events[index][1].type === 'inlineNoteStart') {
hasStart = true
break
}
}
// istanbul ignore next - Hooks.
if (code !== 93 || !hasStart) {
return nok(code)
}
effects.enter('inlineNoteEnd')
effects.enter('inlineNoteEndMarker')
effects.consume(code)
effects.exit('inlineNoteEndMarker')
effects.exit('inlineNoteEnd')
return ok
}
}I did a search of the Edit: Based on usage, I suspect Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Typically But, in JavaScript |
Beta Was this translation helpful? Give feedback.
Typically
thisrefers to aTokenizer.But, in JavaScript
thisis “just” an extra (somewhat magic) parameter. In TypeScript it’s more tied to classes.micromark is quite complex;
thiswill mean different things in different places