From 63e55a1696b3de74ca1bca8997dfd8afbf6c0c3b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 5 Aug 2021 13:37:41 -0400 Subject: [PATCH] Expose ability to compile raw list into their intermeditate form For clients who may wish to persist the intermediate compiled form in order to be able to skip costly parsing operation when the list is fed to the static network filtering engine. --- platform/nodejs/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/nodejs/index.js b/platform/nodejs/index.js index c246eb744..4cb0011c2 100644 --- a/platform/nodejs/index.js +++ b/platform/nodejs/index.js @@ -133,6 +133,10 @@ function pslInit(raw) { return globals.publicSuffixList; } +function createCompiler(parser) { + return snfe.createCompiler(parser); +} + async function useCompiledLists(lists) { // Remove all filters reset(); @@ -169,7 +173,7 @@ async function useRawLists(lists, options = {}) { return snfe; } - const compiler = snfe.createCompiler(new StaticFilteringParser()); + const compiler = createCompiler(new StaticFilteringParser()); const consumeList = list => { const writer = new CompiledListWriter(); @@ -209,6 +213,7 @@ export { FilteringContext, enableWASM, pslInit, + createCompiler, useCompiledLists, useRawLists, };