Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds more detailed info to Node wrapper response #30

Merged
merged 1 commit into from Jun 6, 2019
Merged

Conversation

@AndriusA
Copy link
Collaborator

AndriusA commented Jun 6, 2019

Check the updated README for usage example - both the client and the check call have an extra debug = true parameter:

  • the one in the client retains string representation of rules
  • the one in the check returns detailed information object rather than only true or false for a match
@AndriusA AndriusA requested a review from bbondy Jun 6, 2019
@AndriusA
Copy link
Collaborator Author

AndriusA commented Jun 6, 2019

Node repl output as an example of use:

> const AdBlockClient = require('adblock-rs');
>
> let rules = fs.readFileSync('./data/easylist.to/easylist/easylist.txt', { encoding: 'utf-8' }).split('\n');
>
> const client = new AdBlockClient.Engine(rules, true);
>
> const serializedArrayBuffer = client.serialize(); // Serialize the engine to an ArrayBuffer
>
> console.log("Matching:", client.check("http://example.com/-advertisement-icon.", "http://example.com/helloworld", "image", true))
Matching: {
  matched: true,
  explicit_cancel: false,
  redirect: null,
  exception: null,
  filter: '-advertisement-icon. <+> /icon_ad. <+> /icon_ads_ <+> /icon_advertising_'
}
> console.log("Matching:", client.check("https://github.githubassets.com/assets/frameworks-64831a3d.js", "https://github.com/AndriusA", "script", true))
Matching: {
  matched: false,
  explicit_cancel: false,
  redirect: null,
  exception: null,
  filter: null
}
> console.log("Matching:", client.check("http://example.com/-advertisement-icon.", "http://example.com/helloworld", "image"))
Matching: true
>
@bbondy
bbondy approved these changes Jun 6, 2019
@AndriusA AndriusA merged commit 4fcbff5 into master Jun 6, 2019
@AndriusA AndriusA deleted the node-debugging branch Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.