News for hackers. Stuff that matters.
Re:Inside Wade, a 1kb search library by kbr on Wednesday July 19, 2017 @01:42PM (#14806215)
Actually, it is supposed to be [1, 1]. The actual value of the element corresponds to the score it has, and the index of it refers to the index in the data.

I'll add a note in the article.

Re:Inside Wade, a 1kb search library by venning on Wednesday July 19, 2017 @01:45PM (#14806246)
I'm sorry, I'm still a bit confused. If it "refers to the index in the data", how is it referring to both "Hey" and "Hello"?

Running the following doesn't seem to work for me:

  var Wade = require('wade');
  var search = Wade(['Hey', 'Hello']);
  search('he'); // returns []
Re:Inside Wade, a 1kb search library by kbr on Wednesday July 19, 2017 @01:48PM (#14806273)
The article doesn't exactly simulate what Wade returns, but uses a simpler version. I added a note about it now.

    [1, 1]
The item at index 0 is 1. This means that the item in index 0 of the data ("Hey") has a score of 1. The item at index 1 is 1, meaning that the item at index 1 of the data ("Hello") has a score of 1.

Edit: Your example with Wade isn't working because it ignores the first item in the query ("he") as it is a stop word. Searching for "h" will return both.

Re:Inside Wade, a 1kb search library by venning on Wednesday July 19, 2017 @01:51PM (#14806314)
Okay, I gotcha with the [1, 1].

I'm still curious about using it. The GitHub example [1] works as described, but I can't get a result from the 'he' example. Is it saying no match was found by returning an empty array?

EDIT: Okay, saw your edit. Might be nice to use an example that's not a stopword. ;) Nice work on the library and the blog post.

[1] https://github.com/KingPixil/wade#usage

Re:Inside Wade, a 1kb search library by kbr on Wednesday July 19, 2017 @01:59PM (#14806397)
Cool, glad you understood. The library returns an array of results, and will return an empty array if there are none. Try searching for "h" or "hey" for an example.