0.6.0 • Published 2 years ago

url-state-machine v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

URL State Machine

Super fast specification compliant URL state machine for Node.js. For more information about the URL parsing state machine visit here.

Installation

npm i --save url-state-machine

Usage

const URLStateMachine = require('url-state-machine')
const state = new URLStateMachine('https://www.yagiz.co/implementing-node-js-url-parser-in-webassembly-with-rust')

console.log(state.url)
// {
//   scheme: 'https',
//   username: '',
//   password: '',
//   host: 'www.yagiz.co',
//   port: null,
//   path: [ 'implementing-node-js-url-parser-in-webassembly-with-rust' ],
//   query: null,
//   fragment: null
// }

Benchmarks

  • new URL("/path/to/something?hello=world", "https://www.google.com")
╔═══════════════════╤═════════╤══════════════════╤═══════════╤══════════════════════════╗
║ Slower tests      │ Samples │           Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
║ whatwg-url        │    1000 │  37994.48 op/sec │  ± 0.97 % │                          ║
║ url-state-machine │    9500 │ 257195.34 op/sec │  ± 0.99 % │ + 576.93 %               ║
╟───────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
║ Fastest test      │ Samples │           Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
║ URL               │   10000 │ 477303.34 op/sec │  ± 1.27 % │ + 85.58 %                ║
╚═══════════════════╧═════════╧══════════════════╧═══════════╧══════════════════════════╝
  • new URL("http://127.0.0.1")
╔═══════════════════╤═════════╤═══════════════════╤═══════════╤══════════════════════════╗
║ Slower tests      │ Samples │            Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ whatwg-url        │    5000 │   91747.56 op/sec │  ± 0.97 % │                          ║
║ url-state-machine │   10000 │  626208.74 op/sec │  ± 1.65 % │ + 582.53 %               ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ Fastest test      │ Samples │            Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ URL               │    2500 │ 1037903.40 op/sec │  ± 0.87 % │ + 65.74 %                ║
╚═══════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝
  • new URL("http://[1:0::]")
╔═══════════════════╤═════════╤═══════════════════╤═══════════╤══════════════════════════╗
║ Slower tests      │ Samples │            Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ whatwg-url        │    5500 │  196896.91 op/sec │  ± 0.97 % │                          ║
║ url-state-machine │   10000 │ 1321601.39 op/sec │  ± 2.76 % │ + 571.21 %               ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ Fastest test      │ Samples │            Result │ Tolerance │ Difference with previous ║
╟───────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ URL               │    8000 │ 1356561.74 op/sec │  ± 0.97 % │ + 2.65 %                 ║
╚═══════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝

Testing

Running

All tests are referenced and borrowed from web-platform-tests.

npm test

Code Coverage

Test Files  1 failed (1)
     Tests  1 failed | 732 passed (733)
      Time  633ms (in thread 64ms, 989.58%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files95.8895.189895.88
constants.js100100100100
encoding.js100100100100
index.js93.9993.0210093.99...4-775,800-801,921-922,926-927,1070-1071
parser.js99.5399.0510099.53283-284
platform.js100100100100
string.js100100100100
utf8.js84.3388.235084.3339-44,63-64,77-81

Conformance to specification

  • pathname
    • 1 failed | 732 passed (733)
  • search
    • 1 failed | 732 passed (733)
  • host
    • 733 passed (733)
  • password
    • 733 passed (733)
  • protocol
    • 733 passed (733)
  • username
    • 733 passed (733)
  • port
    • 733 passed (733)
  • fragment
    • 733 passed (733)
0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.5.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago