npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pac-file-tester

v2.1.0

Published

Test PAC files for performance and results

Downloads

1,212

Readme

Pac File Tester

codecov buid status NPM

Tests a PAC file and returns its output.

Usage

As a CLI tool

npm install pac-file-tester -g
pac-file-tester -f http://your.site/proxy.pac -u http://www.google.com

# or with npx

npx pac-file-tester -f http://your.site/proxy.pac -u http://www.google.com

Options

  • -f --file, the url/path of the pac file to test.
  • -u --url, the url to test the pac file against.
  • -i --ip, the IP address to return from myIpAddress()
  • -c --compare, the url/path of another pac file to compare output & speed with. (Optional)
  • -d --dns, a manual DNS entry, e.g. dns.google.com|8.8.8.8

Pragmatically

npm install --save pac-file-tester

getFileContents(url: string): Promise<string>

Returns the contents of the given url, suppports http and file addresses.

const contents = await getFileContents('http://pac.example.com/proxy.pac')

testPacFile(file: string, url: string, options: Options)

Tests the PAC file for the given url.

Takes an optional options object with the following keys:

| Key | Default | Description | | :--------- | :---------------: | :-------------------------------------------------------------------------- | | ip | your current ip | The IP Address to return for myIpAddress() | | dnsEntries | {} | DNS Entries to supply to the context. e.g. {'www.example.com': '1.2.3.4'} |

Examples
Local file

Run a PAC file from disk for https://www.google.com.

const file = await getFileContents('file://./proxy.pac')

const result = await testPacFile(file, 'https://www.google.com')
Remote file with replaced IP

Run a PAC file from a web server for https://www.google.com whilst impersonating the IP address 192.168.2.10.

const file = await getFileContents('http://pac.example.com/proxy.pac')

const result = await testPacFile(file, 'https://www.google.com', {
  ip: '192.168.2.10'
})
Remote file with a custom DNS entry

Run a PAC file from a web server for https://www.google.com with a custom DNS entry for example.com that resolves to 127.0.0.1

const file = await getFileContents('http://pac.example.com/proxy.pac')

const result = await testPacFile(file, 'https://www.google.com', {
  dnsEntries: {'example.com': '127.0.0.1'}
})