How to use the base62/lib/ascii.encode function in base62

To help you get started, we’ve selected a few base62 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenUserJS / OpenUserJS.org / controllers / scriptStorage.js View on Github external
if (!aScript) {
        aNext();
        return;
      }

      // HTTP/1.1 Caching
      aRes.set('Cache-Control', 'public, max-age=' + maxAge +
        ', no-cache, no-transform, must-revalidate');

      script = modelParser.parseScript(aScript);
      meta = script.meta; // NOTE: Watchpoint

      if (/\.json$/.test(aReq.params.scriptname)) {
        // Create a based representation of the hex sha512sum
        eTag = '"'  + Base62.encode(parseInt('0x' + aScript.hash, 16)) + ' .meta.json"';

        // If already client-side... HTTP/1.1 Caching
        if (aReq.get('if-none-match') === eTag) {
          aRes.status(304).send(); // Not Modified
          return;
        }

        // Okay to send .meta.json...
        aRes.set('Content-Type', 'application/json; charset=UTF-8');

        // HTTP/1.0 Caching
        aRes.set('Expires', moment(moment() + maxAge * 1000).utc()
          .format('ddd, DD MMM YYYY HH:mm:ss') + ' GMT');

        // HTTP/1.1 Caching
        aRes.set('Etag', eTag);
github ampproject / amphtml / build-system / babel-plugins / babel-plugin-transform-log-methods / index.js View on Github external
function getOrCreateMessageId(message) {
    if (message in messages) {
      return messages[message].id;
    }
    const id = base62ascii.encode(nextMessageId++); // [0-9a-zA-Z]
    messages[message] = {id, message};
    return id;
  }
github tahtaciburak / sourcebin / lib / utils.js View on Github external
exports.id2url = function(id){
    return base62.encode(id.toString());
}

base62

JavaScript Base62 encode/decoder

MIT
Latest version published 5 months ago

Package Health Score

86 / 100
Full package analysis