Giter VIP home page Giter VIP logo

Comments (9)

moroshko avatar moroshko commented on May 23, 2024 1

Go ahead! I'll be happy to accept a PR.

from autosuggest-trie.

Gelio avatar Gelio commented on May 23, 2024 1

I just wanted to say that I'm actually content with how it went. It's my first open source contribution, at least a mental one, No problem, I also noticed that when implementing this, that it probably does too much, as you said. It's a valid point. I will continue to use my workaround in the app.

Thank you for being a considerate project maintainer! It was a pleasure

from autosuggest-trie.

moroshko avatar moroshko commented on May 23, 2024

@Gelio Thanks a lot for a properly submitted issue!

Your suggestion makes sense, but I'm curious to know what stops you from doing something like this?

if (query.trim() === '') {
  items = allItems;
} else {
  items = trie.getMatches(query);
}

from autosuggest-trie.

Gelio avatar Gelio commented on May 23, 2024

@moroshko thank you for your time! Actually, that's the workaround I have been using for now. I just thought it would be a good enhancement to this library, as people who use it for similar purposes as me would have it already implemented as a handy declarative option, instead of that workaround.

If you decide it isn't needed I will accept it and hold no grudge. I just mean to help

from autosuggest-trie.

moroshko avatar moroshko commented on May 23, 2024

@Gelio How about this:

createTrie(items, textKey, { blankQueryMatches: allItems })

?

Note that the API changed a bit in v2.0. I'd appreciate your feedback on the new API.

from autosuggest-trie.

Gelio avatar Gelio commented on May 23, 2024

from autosuggest-trie.

Gelio avatar Gelio commented on May 23, 2024

@moroshko I've seen the new API, looks solid, extensibility is nicely included now. I believe what you proposed with that blankQueryMatches option also is valid. Are you going to implement this yourself, or may I add this (along with necessary tests) and make a pull request?

This would be my first open source contribution, so if you would give me the opportunity I would be grateful :) no worries, I understand if you want to do it yourself

from autosuggest-trie.

Gelio avatar Gelio commented on May 23, 2024

I'm wondering if we should slice the array if a limit is specified when using a blank query. The same goes for sorting the array - do we sort it when using a blank query?

To my mind, it should return all the items specified when creating a trie, however, they should be sorted. Therefore it can sort the items at the beginning if the comparator function is provided.

from autosuggest-trie.

moroshko avatar moroshko commented on May 23, 2024

Hmm.. Now I feel that blankQueryMatches only introduces an unnecessary complexity to the surface area of this library, without adding much value in return.

It doesn't make sense to me to limit the blank query matches. Same with sorting. I think this logic should live outside of this library.

When I think more about this, I feel like this:

if (query.trim() === '') {
  items = allItems; // you can slice or limit here, it's totally up to you!
} else {
  items = trie.getMatches(query);
}

is actually the right way to use autosuggest-trie (not a workaround).

The purpose of this library is to get matches based on a query. If you don't have a query (i.e. the query is blank) you shouldn't be trying to get matches. That's my mental model. I hope it makes sense.

I'll have to pass on this one. Sorry if I wasted your time. Somehow, I hope it was a positive experience anyway.

I just want to thank you again for taking the time to raise the issue, propose and implement a solution, and having a positive attitude. Please don't let this experience to stop you from contributing to Open Source in the future.

from autosuggest-trie.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.