Yomguithereal / mnemonist

Curated collection of data structures for the JavaScript/TypeScript language.
https://yomguithereal.github.io/mnemonist
MIT License
2.24k stars 92 forks source link

KDTree constructor not working as documented #192

Closed olastor closed 1 year ago

olastor commented 1 year ago

Using the example from the docs:

var data = [
  ['zero', [2, 3]],
  ['one', [5, 4]],
  ['two', [9, 6]],
  ['three', [4, 7]],
  ['four', [8, 1]],
  ['five', [7, 2]]
];

var tree = new KDTree(data, 2);

tree.dimensions

the typescript compiler fails, saying

TS2554: Expected 0 arguments, but got 2.
    88 |         ];
    89 |
  > 90 |         var tree = new KDTree(data, 2);
olastor commented 1 year ago

I think the docs should be changed to KDTree.from in the examples.

Yomguithereal commented 1 year ago

Hello @olastor. You are right the examples are wrong. Do you want to fix them by opening a PR on the gh-pages branch of this repo holding the docs?

olastor commented 1 year ago

@Yomguithereal I've opened https://github.com/Yomguithereal/mnemonist/pull/194

Yomguithereal commented 1 year ago

Thanks @olastor. I have merged your PR. The online docs should be updated shortly.