Skip to content

add() adds unintended duplicates? #47

@jsantos42

Description

@jsantos42

Steps To Reproduce

import TrieSearch from ".";

type MyType = {
  key1?: string;
  key2?: string;
};

const trie: TrieSearch<MyType> = new TrieSearch<MyType>("key1");

const keyValue1 = "valué with space";
const item1 = { key1: keyValue1 };

trie.add(item1);

console.dir(trie.root, { depth: null });

Actual Result

{
  v: {
    a: {
      l: {
        u: {
          'é': { value: [ { key1: 'valué with space' } ] },
          e: { value: [ { key1: 'valué with space' } ] }
        }
      }
    }
  },
  w: {
    i: {
      t: {
        h: {
          value: [
            { key1: 'valué with space' },    // this should not be duplicated
            { key1: 'valué with space' }
          ]
        }
      }
    }
  },
  s: {
    p: {
      a: {
        c: {
          e: {
            value: [
              { key1: 'valué with space' }, // neither should this
              { key1: 'valué with space' }
            ]
          }
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions