1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-03 02:37:21 +02:00

Fix NPM package documentation

This commit is contained in:
Raymond Hill 2021-12-04 12:40:43 -05:00
parent 82f31e7863
commit b98836ab8e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -123,34 +123,34 @@ import HNTrieContainer from '@gorhill/ubo-core/js/hntrie.js';
const trieContainer = new HNTrieContainer();
const aTrie = trieContainer.createOne();
aTrie.add('example.org');
aTrie.add('example.com');
trieContainer.add(aTrie, 'example.org');
trieContainer.add(aTrie, 'example.com');
const anotherTrie = trieContainer.createOne();
anotherTrie.add('foo.invalid');
anotherTrie.add('bar.invalid');
trieContainer.add(anotherTrie, 'foo.invalid');
trieContainer.add(anotherTrie, 'bar.invalid');
// matches() return the position at which the match starts, or -1 when
// there is no match.
// Matches: return 4
console.log("aTrie.matches('www.example.org')", aTrie.matches('www.example.org'));
console.log("trieContainer.matches(aTrie, 'www.example.org')", trieContainer.matches(aTrie, 'www.example.org'));
// Does not match: return -1
console.log("aTrie.matches('www.foo.invalid')", aTrie.matches('www.foo.invalid'));
console.log("trieContainer.matches(aTrie, 'www.foo.invalid')", trieContainer.matches(aTrie, 'www.foo.invalid'));
// Does not match: return -1
console.log("anotherTrie.matches('www.example.org')", anotherTrie.matches('www.example.org'));
console.log("trieContainer.matches(anotherTrie, 'www.example.org')", trieContainer.matches(anotherTrie, 'www.example.org'));
// Matches: return 0
console.log("anotherTrie.matches('foo.invalid')", anotherTrie.matches('foo.invalid'));
console.log("trieContainer.matches(anotherTrie, 'foo.invalid')", trieContainer.matches(anotherTrie, 'foo.invalid'));
```
The `reset()` method must be used to remove all the tries from a trie container,
you can't remove a single trie from the container.
```js
hntrieContainer.reset();
trieContainer.reset();
```
When you reset a trie container, you can't use the reference to prior instances