diff --git a/async/index.js b/async/index.js index 72ee79b4..db04d9c0 100644 --- a/async/index.js +++ b/async/index.js @@ -1,4 +1,4 @@ -let { urlAlphabet } = require('..') +let { urlAlphabet } = require('../url-alphabet') let { random } = require('./random') let customAlphabet = (alphabet, size) => { diff --git a/index.browser.js b/index.browser.js index e9a45130..e9233f90 100644 --- a/index.browser.js +++ b/index.browser.js @@ -1,6 +1,8 @@ // This file replaces `index.js` in bundlers like webpack or Rollup, // according to `browser` config in `package.json`. +let { urlAlphabet } = require('./url-alphabet') + if (process.env.NODE_ENV !== 'production') { // All bundlers will remove this block in the production bundle. if ( @@ -28,11 +30,6 @@ if (process.env.NODE_ENV !== 'production') { } } -// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped -// optimize the gzip compression for this alphabet. -let urlAlphabet = - 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW' - let random = bytes => crypto.getRandomValues(new Uint8Array(bytes)) let customRandom = (alphabet, size, getRandom) => { diff --git a/index.js b/index.js index 057794fd..5d8165a2 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ let crypto = require('crypto') -let urlAlphabet = - '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' +let { urlAlphabet } = require('./url-alphabet') // We reuse buffers with the same size to avoid memory fragmentations // for better performance. diff --git a/url-alphabet/index.js b/url-alphabet/index.js new file mode 100644 index 00000000..8c9d70d8 --- /dev/null +++ b/url-alphabet/index.js @@ -0,0 +1,6 @@ +// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped +// optimize the gzip compression for this alphabet. +let urlAlphabet = + 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW' + +module.exports = { urlAlphabet }