Sha256: e1305733c7beee7b3a86ba591d28e290d78c4eff1aed7e55de68bfccf0653e1f

Contents?: true

Size: 1.1 KB

Versions: 19

Compression:

Stored size: 1.1 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);
}
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

19 entries across 13 versions & 3 rubygems

Version Path
webruby-0.2.7 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.2.5 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.2.4 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.2.2 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.2.1 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.1.2 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.1.1 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
webruby-0.1.0 modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js
sprockets-browserify-0.2.0 node_modules/browserify/node_modules/umd/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
sprockets-browserify-0.2.0 node_modules/browserify/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js
sprockets-browserify-0.2.0 node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/inline-source-map/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.8.0 vendor/node_modules/browserify/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.8.0 vendor/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/inline-source-map/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.8.0 vendor/node_modules/browserify/node_modules/umd/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.7.0 vendor/node_modules/browserify/node_modules/umd/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.7.0 vendor/node_modules/browserify/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js
ruby-wisp-source-0.7.0 vendor/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/inline-source-map/node_modules/source-map/lib/source-map/base64.js
sprockets-browserify-0.1.2 node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js
sprockets-browserify-0.1.0 node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js