Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Re-optimize alphabet for Brotli (only chars unused by gzip backrefs) #310

Merged
merged 2 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions non-secure/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// This alphabet uses `A-Za-z0-9_-` symbols.
// The order of characters is optimized for better gzip compression
// The order of characters is optimized for better gzip and brotli compression.
// References to the same file (works both for gzip and brotli):
// `'use`, `andom`, and `rict'`
// References to the brotli default dictionary:
// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
let urlAlphabet =
'useandom-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_bfghjklpqvwxyzrict'
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'

let customAlphabet = (alphabet, size) => {
return () => {
Expand Down
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,52 @@
"import": "{ customAlphabet }",
"path": "async/index.js",
"limit": "163 B"
},
{
"name": "nanoid (brotli)",
"brotli": true,
"import": "{ nanoid }",
"limit": "104 B"
},
{
"name": "customAlphabet (brotli)",
"brotli": true,
"import": "{ customAlphabet }",
"limit": "143 B"
},
{
"name": "urlAlphabet (brotli)",
"brotli": true,
"import": "{ urlAlphabet }",
"limit": "31 B"
},
{
"name": "non-secure nanoid (brotli)",
"brotli": true,
"import": "{ nanoid }",
"path": "non-secure/index.js",
"limit": "72 B"
},
{
"name": "non-secure customAlphabet (brotli)",
"brotli": true,
"import": "{ customAlphabet }",
"path": "non-secure/index.js",
"limit": "32 B"
},
{
"name": "async nanoid (brotli)",
"brotli": true,
"import": "{ nanoid }",
"path": "async/index.js",
"limit": "111 B"
},
{
"name": "async customAlphabet (brotli)",
"brotli": true,
"import": "{ customAlphabet }",
"path": "async/index.js",
"limit": "130 B"
}
],
"eslintConfig": {
Expand Down
5 changes: 3 additions & 2 deletions url-alphabet/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This alphabet uses `A-Za-z0-9_-` symbols.
// The order of characters is optimized for better gzip compression
// The order of characters is optimized for better gzip and brotli compression.
// Same as in non-secure/index.js
let urlAlphabet =
'use-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abdfghjklmnopqvwxyzrict'
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'

module.exports = { urlAlphabet }