Sha256: 0d1974a3a03081f1302bcea85e811d1a59f3e31b757dedcedbd75e2fb1c88560

Contents?: true

Size: 1.11 KB

Versions: 409

Compression:

Stored size: 1.11 KB

Contents

/* -*- Mode: js; js-indent-level: 2; -*- */
/*
 * Copyright 2011 Mozilla Foundation and contributors
 * Licensed under the New BSD license. See LICENSE or:
 * http://opensource.org/licenses/BSD-3-Clause
 */
if (typeof define !== 'function') {
    var define = require('amdefine')(module, require);
}
define(function (require, exports, module) {

  var charToIntMap = {};
  var intToCharMap = {};

  'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
    .split('')
    .forEach(function (ch, index) {
      charToIntMap[ch] = index;
      intToCharMap[index] = ch;
    });

  /**
   * Encode an integer in the range of 0 to 63 to a single base 64 digit.
   */
  exports.encode = function base64_encode(aNumber) {
    if (aNumber in intToCharMap) {
      return intToCharMap[aNumber];
    }
    throw new TypeError("Must be between 0 and 63: " + aNumber);
  };

  /**
   * Decode a single base 64 digit to an integer.
   */
  exports.decode = function base64_decode(aChar) {
    if (aChar in charToIntMap) {
      return charToIntMap[aChar];
    }
    throw new TypeError("Not a valid base 64 digit: " + aChar);
  };

});

Version data entries

409 entries across 196 versions & 22 rubygems

Version Path
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.3 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.2 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.1 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.0 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/source-map-support/node_modules/source-map/lib/source-map/base64.js