Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
579 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /* -*- Mode: js; js-indent-level: 2; -*- */
|
---|
| 2 | /*
|
---|
| 3 | * Copyright 2011 Mozilla Foundation and contributors
|
---|
| 4 | * Licensed under the New BSD license. See LICENSE or:
|
---|
| 5 | * http://opensource.org/licenses/BSD-3-Clause
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
---|
| 12 | */
|
---|
| 13 | exports.encode = function(number) {
|
---|
| 14 | if (0 <= number && number < intToCharMap.length) {
|
---|
| 15 | return intToCharMap[number];
|
---|
| 16 | }
|
---|
| 17 | throw new TypeError("Must be between 0 and 63: " + number);
|
---|
| 18 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.