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

TS declarations / RemoveEmptyLines / InsertFinalNewLine / TrimLines #32

Closed
wants to merge 8 commits into from
Closed

Conversation

scripthunter7
Copy link
Member

@scripthunter7 scripthunter7 commented Jun 2, 2022

TS declarations

  • TS declarations for the Hostlist Compiler.
    • Example usage (hostlist.ts):
      import HostlistCompiler, { IConfiguration as HostlistCompilerConfiguration } from '@adguard/hostlist-compiler';
      import { writeFileSync } from 'fs';
      
      (async () => {
          // Configuration
          const config: HostlistCompilerConfiguration = {
              name: 'hufilter DNS filter',
              description: 'Simplified hufilter version specifically to be better compatible with DNS-level ad blocking.',
              homepage: 'https://github.com/hufilter/hufilter/wiki',
              license: 'https://github.com/hufilter/hufilter/blob/master/LICENSE',
              sources: [
                  {
                      type: 'adblock',
                      source: 'https://raw.githubusercontent.com/hufilter/hufilter/master/hufilter-adguard.txt',
                      transformations: ['RemoveComments', 'Validate', 'Deduplicate'],
                  },
              ],
              transformations: ['RemoveEmptyLines', 'InsertFinalNewLine'],
          };
      
          // Compiled filter list
          const result = await HostlistCompiler(config);
      
          // Write it to file
          writeFileSync('hufilter-dns.txt', result.join('\n'));
      })();
    • VSCode suggestions:
      • Possible values:
        Code_iPT6sLEOMt
      • Basic JSDoc:
        Code_V0ByDzPk2E

RemoveEmptyLines

This is a very simple transformation that removes empty lines. Related to #30 and #12

Example:

Original list:

rule1

rule2


rule3

Here's what we will have after applying this transformation:

rule1
rule2
rule3

InsertFinalNewLine

This is a very simple transformation that inserts a final new line.

Example:

Original list:

rule1
rule2
rule3

Here's what we will have after applying this transformation:

rule1
rule2
rule3

RemoveEmptyLines transformation has no effect on this new line because it precedes this transformation in the execution queue.

TrimLines

This is a very simple transformation that removes leading and trailing spaces/tabs. Related to #12

Example:

Original list:

rule1
   rule2
rule3
		rule4

Here's what we will have after applying this transformation:

rule1
rule2
rule3
rule4

@scripthunter7 scripthunter7 changed the title TS declarations TS declarations / Skip empty lines / Insert final new line Jun 2, 2022
@scripthunter7 scripthunter7 changed the title TS declarations / Skip empty lines / Insert final new line TS declarations / RemoveEmptyLines / InsertFinalNewLine Jun 2, 2022
@scripthunter7 scripthunter7 changed the title TS declarations / RemoveEmptyLines / InsertFinalNewLine TS declarations / RemoveEmptyLines / InsertFinalNewLine / TrimLines Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant