Giter Site home page Giter Site logo

rarkins / url-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anonrig/url-js

0.0 0.0 0.0 316 KB

Super fast spec-compliant URL state machine for Node.js

Home Page: https://www.npmjs.com/package/url-state-machine

License: MIT License

JavaScript 93.60% TypeScript 6.40%

url-js's Introduction

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 URL('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

Full domain with input and base
  • 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 %                ║
╚═══════════════════╧═════════╧══════════════════╧═══════════╧══════════════════════════╝
ipv4 address
  • 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 %                ║
╚═══════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝
ipv6 address
  • 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 % Lines Uncovered Line #s
All files 95.88 95.18 98 95.88
constants.js 100 100 100 100
encoding.js 100 100 100 100
index.js 93.99 93.02 100 93.99 ...4-775,800-801,921-922,926-927,1070-1071
parser.js 99.53 99.05 100 99.53 283-284
platform.js 100 100 100 100
string.js 100 100 100 100
utf8.js 84.33 88.23 50 84.33 39-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)

url-js's People

Contributors

anonrig avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.