Git Product home page Git Product logo

adar's Introduction

adaR

R-CMD-check Codecov test coverage

adaR is a wrapper for ada-url, a WHATWG-compliant and fast URL parser written in modern C++ .

Installation

You can install the development version of adaR from GitHub with:

# install.packages("devtools")
devtools::install_github("schochastics/adaR")

Example

This is a basic example which shows all the returned components

library(adaR)
ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag")
#> $href
#> [1] "https://user_1:[email protected]:8080/api?q=1#frag"
#> 
#> $protocol
#> [1] "https:"
#> 
#> $username
#> [1] "user_1"
#> 
#> $password
#> [1] "password_1"
#> 
#> $host
#> [1] "example.org:8080"
#> 
#> $hostname
#> [1] "example.org"
#> 
#> $port
#> [1] "8080"
#> 
#> $pathname
#> [1] "/api"
#> 
#> $search
#> [1] "?q=1"
#> 
#> $hash
#> [1] "#frag"

It solves some problems of urltools with more complex urls.

urltools::url_parse("https://www.google.com/maps/place/Pennsylvania+Station/@40.7519848,-74.0015045,14.
   7z/data=!4m5!3m4!1s0x89c259ae15b2adcb:0x7955420634fd7eba!8m2!3d40.750568!4d-73.993519")
#>   scheme                            domain port
#> 1  https 40.7519848,-74.0015045,14.\n   7z <NA>
#>                                                                                 path
#> 1 data=!4m5!3m4!1s0x89c259ae15b2adcb:0x7955420634fd7eba!8m2!3d40.750568!4d-73.993519
#>   parameter fragment
#> 1      <NA>     <NA>

ada_url_parse("https://www.google.com/maps/place/Pennsylvania+Station/@40.7519848,-74.0015045,14.7z/data=!4m
   5!3m4!1s0x89c259ae15b2adcb:0x7955420634fd7eba!8m2!3d40.750568!4d-73.993519")
#> $href
#> [1] "https://www.google.com/maps/place/Pennsylvania+Station/@40.7519848,-74.0015045,14.7z/data=!4m%20%20%205!3m4!1s0x89c259ae15b2adcb:0x7955420634fd7eba!8m2!3d40.750568!4d-73.993519"
#> 
#> $protocol
#> [1] "https:"
#> 
#> $username
#> [1] ""
#> 
#> $password
#> [1] ""
#> 
#> $host
#> [1] "www.google.com"
#> 
#> $hostname
#> [1] "www.google.com"
#> 
#> $port
#> [1] ""
#> 
#> $pathname
#> [1] "/maps/place/Pennsylvania+Station/@40.7519848,-74.0015045,14.7z/data=!4m%20%20%205!3m4!1s0x89c259ae15b2adcb:0x7955420634fd7eba!8m2!3d40.750568!4d-73.993519"
#> 
#> $search
#> [1] ""
#> 
#> $hash
#> [1] ""

and it is fast!

bench::mark(
  ada = replicate(1000, ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag")),
  urltools = replicate(1000, urltools::url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag")),
  iterations = 1, check = FALSE
)
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> # A tibble: 2 ร— 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 ada          10.2ms   10.2ms     98.4     2.67MB      0  
#> 2 urltools    304.2ms  304.2ms      3.29    2.59MB     19.7

adar's People

Contributors

schochastics avatar

Watchers

 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.