mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-22 02:12:44 +01:00
Further fix npm documentation, minor code review
This commit is contained in:
parent
9233e6b7c6
commit
86aeae75df
@ -90,10 +90,20 @@ if ( snfe.matchRequest({
|
||||
}
|
||||
```
|
||||
|
||||
It is possible to pre-parse filter lists and save the intermediate results for
|
||||
later use -- useful to speed up the loading of filter lists. This will be
|
||||
documented eventually, but if you feel adventurous, you can look at the code
|
||||
and use this capability now if you figure out the details.
|
||||
Once all the filter lists are loaded into the static network filtering engine,
|
||||
you can serialize the content of the engine into a JS string:
|
||||
|
||||
```js
|
||||
const serializedData = await snfe.serialize();
|
||||
```
|
||||
|
||||
You can save and later use that JS string to fast-load the content of the
|
||||
static network filtering engine without having to parse and compile the lists:
|
||||
|
||||
```js
|
||||
const snfe = await StaticNetFilteringEngine.create();
|
||||
await snfe.deserialize(serializedData);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
@ -182,8 +182,7 @@ async function useLists(lists, options = {}) {
|
||||
// Populate filtering engine with resolved filter lists
|
||||
const promises = [];
|
||||
for ( const list of lists ) {
|
||||
const promise = list instanceof Promise ? list : Promise.resolve(list);
|
||||
promises.push(promise.then(list => consumeList(list)));
|
||||
promises.push(Promise.resolve(list).then(list => consumeList(list));
|
||||
}
|
||||
|
||||
useLists.promise = Promise.all(promises);
|
||||
@ -249,12 +248,12 @@ class StaticNetFilteringEngine {
|
||||
return compileList(...args);
|
||||
}
|
||||
|
||||
serialize() {
|
||||
async serialize() {
|
||||
const data = snfe.serialize();
|
||||
return s14e.serialize(data, { compress: true });
|
||||
}
|
||||
|
||||
deserialize(serialized) {
|
||||
async deserialize(serialized) {
|
||||
const data = s14e.deserialize(serialized);
|
||||
return snfe.unserialize(data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user