Closed jnovos closed 9 years ago
What is the index
argument that your function takes?
Do you need a method on the index to do that?
The index object already has the ability to be converted to JSON by just calling JSON.stringify(idx)
, where idx is the index object. I'd rather not have the index have a method that just wraps JSON.stringify
as I'm not sure it adds much value.
If you really do need this to be a method on the index object then consider writing a plugin, some details here - http://lunrjs.com/docs/#use
For this case it might look a little bit like this:
var indexJSONPlugin = function () {
this.indexJson = function (index) {
return JSON.stringify(index)
}
}
Then use your plugin like this:
idx.use(indexJSONPlugin)
Feel free to re-open if I've misunderstood your use case, or if you have any other questions.
Hi, I would like to add a new method into Index class. lunr.Index.prototype.indexJson = function (index) { return JSON.stringify(index) } I need this method to finish a extension for Middleman.
It's possible thank you