mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 02:42:41 +01:00
Fix NPM package documentation
This commit is contained in:
parent
82f31e7863
commit
b98836ab8e
@ -123,34 +123,34 @@ import HNTrieContainer from '@gorhill/ubo-core/js/hntrie.js';
|
|||||||
const trieContainer = new HNTrieContainer();
|
const trieContainer = new HNTrieContainer();
|
||||||
|
|
||||||
const aTrie = trieContainer.createOne();
|
const aTrie = trieContainer.createOne();
|
||||||
aTrie.add('example.org');
|
trieContainer.add(aTrie, 'example.org');
|
||||||
aTrie.add('example.com');
|
trieContainer.add(aTrie, 'example.com');
|
||||||
|
|
||||||
const anotherTrie = trieContainer.createOne();
|
const anotherTrie = trieContainer.createOne();
|
||||||
anotherTrie.add('foo.invalid');
|
trieContainer.add(anotherTrie, 'foo.invalid');
|
||||||
anotherTrie.add('bar.invalid');
|
trieContainer.add(anotherTrie, 'bar.invalid');
|
||||||
|
|
||||||
// matches() return the position at which the match starts, or -1 when
|
// matches() return the position at which the match starts, or -1 when
|
||||||
// there is no match.
|
// there is no match.
|
||||||
|
|
||||||
// Matches: return 4
|
// 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
|
// 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
|
// 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
|
// 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,
|
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.
|
you can't remove a single trie from the container.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hntrieContainer.reset();
|
trieContainer.reset();
|
||||||
```
|
```
|
||||||
|
|
||||||
When you reset a trie container, you can't use the reference to prior instances
|
When you reset a trie container, you can't use the reference to prior instances
|
||||||
|
Loading…
Reference in New Issue
Block a user