Skip to content

Commit

Permalink
continue cran release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Jan 13, 2024
1 parent 637cbba commit 8bf7759
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
13 changes: 9 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
Package: b64
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Title: Fast and Vectorized Base 64 Engine
Version: 0.1.0
Authors@R:
person("Josiah", "Parry", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9910-865X"))
Description: What the package does (one paragraph).
Description: Provides a fast, lightweight, and vectorized base 64 engine
to encode and decode character and raw vectors as well as files stored
on disk. Common base 64 alphabets are supported out of the box
including the standard, URL-safe, bcrypt, crypt, 'BinHex', and
IMAP-modified UTF-7 alphabets. Custom engines can be created to
support unique base 64 encoding and decoding needs.
License: MIT + file LICENSE
Encoding: UTF-8
Language: en
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Config/rextendr/version: 0.3.1.9000
SystemRequirements: Cargo (rustc package manager)
SystemRequirements: Cargo (Rust's package manager), rustc
Imports:
blob,
cli,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# b64 0.1.0

* Initial CRAN submission.
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# b64

<!-- badges: start -->

[![R-CMD-check](https://github.com/extendr/b64/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/extendr/b64/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of b64 is to provide a very fast and lightweight base64 encoder
and decoder and truly open sourced.
The goal of b64 is to provide a very fast, lightweight, and vectorized
base64 encoder and decoder.

## Installation

Expand Down Expand Up @@ -52,19 +54,19 @@ Both `encode()` and `decode()` are vectorized.
``` r
lorem <- unlist(lorem::ipsum(5, 1, 5))
lorem
#> [1] "Amet diam nascetur nisi ad pharetra ante?"
#> [2] "Sit massa eu morbi nostra mi."
#> [3] "Dolor erat dui eu faucibus."
#> [4] "Sit volutpat per ridiculus donec massa lacus duis?"
#> [5] "Elit tempus neque phasellus laoreet maecenas ad?"
#> [1] "Sit ligula senectus litora viverra consequat."
#> [2] "Consectetur vulputate vivamus sapien a ridiculus porta."
#> [3] "Ipsum orci cras posuere lacus."
#> [4] "Lorem nostra hendrerit nascetur vel duis consequat."
#> [5] "Adipiscing dui blandit vestibulum bibendum?"

encoded <- encode(lorem)
encoded
#> [1] "QW1ldCBkaWFtIG5hc2NldHVyIG5pc2kgYWQgcGhhcmV0cmEgYW50ZT8="
#> [2] "U2l0IG1hc3NhIGV1IG1vcmJpIG5vc3RyYSBtaS4="
#> [3] "RG9sb3IgZXJhdCBkdWkgZXUgZmF1Y2lidXMu"
#> [4] "U2l0IHZvbHV0cGF0IHBlciByaWRpY3VsdXMgZG9uZWMgbWFzc2EgbGFjdXMgZHVpcz8="
#> [5] "RWxpdCB0ZW1wdXMgbmVxdWUgcGhhc2VsbHVzIGxhb3JlZXQgbWFlY2VuYXMgYWQ/"
#> [1] "U2l0IGxpZ3VsYSBzZW5lY3R1cyBsaXRvcmEgdml2ZXJyYSBjb25zZXF1YXQu"
#> [2] "Q29uc2VjdGV0dXIgdnVscHV0YXRlIHZpdmFtdXMgc2FwaWVuIGEgcmlkaWN1bHVzIHBvcnRhLg=="
#> [3] "SXBzdW0gb3JjaSBjcmFzIHBvc3VlcmUgbGFjdXMu"
#> [4] "TG9yZW0gbm9zdHJhIGhlbmRyZXJpdCBuYXNjZXR1ciB2ZWwgZHVpcyBjb25zZXF1YXQu"
#> [5] "QWRpcGlzY2luZyBkdWkgYmxhbmRpdCB2ZXN0aWJ1bHVtIGJpYmVuZHVtPw=="
```

We can decode all of these using `decode()` as well. This will always
Expand All @@ -73,7 +75,7 @@ return a `blob` object.
``` r
decode(encoded)
#> <blob[5]>
#> [1] blob[41 B] blob[29 B] blob[27 B] blob[50 B] blob[48 B]
#> [1] blob[45 B] blob[55 B] blob[30 B] blob[51 B] blob[43 B]
```

## Encoding and decoding files
Expand All @@ -97,8 +99,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 b64 40.1ms 41.1ms 24.3 24MB 0
#> 2 base64enc 112.5ms 112.8ms 8.81 66.5MB 17.6
#> 1 b64 39.8ms 41.3ms 24.0 24MB 0
#> 2 base64enc 112.1ms 115.2ms 8.56 66.5MB 17.1
```

While the encoding is very impressive, better yet is the decoding
Expand All @@ -120,8 +122,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 b64 16.3ms 16.8ms 59.3 18MB 9.49
#> 2 base64enc 207.6ms 207.6ms 4.82 18MB 2.41
#> 1 b64 16.1ms 16.8ms 56.1 18MB 9.34
#> 2 base64enc 209.1ms 210.7ms 4.75 18MB 0
```

## Alternative engines
Expand Down Expand Up @@ -186,11 +188,3 @@ Compare this to the standard encoder:
encode(txt)
#> [1] "bG9yZW0gaXBzdW0gc2l0IGRvbG9yIGFtZXQ="
```

## TODO

- [ ] provide interface to create custom encoder and decoders
- custom alphabets
- padding
- url safe alphabets
- streaming encoding and decoding

0 comments on commit 8bf7759

Please sign in to comment.