Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Mar 22, 2014
0 parents commit b6f6917
Show file tree
Hide file tree
Showing 90 changed files with 28,644 additions and 0 deletions.
178 changes: 178 additions & 0 deletions 0.6.0/base64.js
@@ -0,0 +1,178 @@
/* Generated by Opal 0.6.0 */
(function($opal) {
var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, $module = $opal.module;

$opal.add_stubs([]);
return (function($base) {
var self = $module($base, 'Base64');

var def = self._proto, $scope = self._scope;


var charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
lookup = {};

for (var i = 0, length = charset.length; i < length; i++) {
lookup[charset.charAt(i)] = i;
}

function from(string) {
var buffer = [];

for (var i = 0, length = string.length; i < length; i++) {
var a, b, c, d;

a = lookup[string.charAt(i)];
b = lookup[string.charAt(++i)];

buffer.push((a << 2) | (b >> 4));

c = lookup[string.charAt(++i)];

if (c == 64) {
break;
}

buffer.push(((b & 15) << 4) | (c >> 2));

d = lookup[string.charAt(++i)];

if (d == 64) {
break;
}

buffer.push(((c & 3) << 6) | d);
}

return buffer;
}

function decode(string) {
var buffer = from(string),
result = [];

for (var i = 0, length = buffer.length; i < length; i++) {
if (buffer[i] < 128) {
result.push(String.fromCharCode(buffer[i]));
}
else if (buffer[i] > 191 && buffer[i] < 224) {
var a = (buffer[i] & 31) << 6,
b = buffer[++i] & 63;

result.push(String.fromCharCode(a | b));
}
else {
var a = (buffer[i] & 15) << 12,
b = (buffer[++i] & 63) << 6,
c = buffer[++i] & 63;

result.push(String.fromCharCode(a | b | c));
}
}

return result.join('');
}

function to(string) {
var buffer = [];

if (/^[\x00-\x7f]*$/.test(string)) {
for (var i = 0, length = string.length; i < length; i++) {
buffer.push(string.charCodeAt(i));
}
}
else {
for (var i = 0, length = string.length; i < length; i++) {
var ch = string.charCodeAt(i);

if (ch < 128) {
buffer.push(ch);
}
else if (ch < 2048) {
buffer.push((ch >> 6) | 192);
buffer.push((ch & 63) | 128);
}
else {
buffer.push((ch >> 12) | 224);
buffer.push(((ch >> 6) & 63) | 128);
buffer.push((ch & 63) | 128);
}
}
}

return buffer;
}

function encode(string) {
var buffer = to(string),
result = [];

for (var i = 0, length = buffer.length; i < length; i++) {
var a = buffer[i],
b = buffer[++i],
c = 0,
d = a >> 2,
e = ((a & 3) << 4) | (b >> 4),
f = 0,
g = 0;

if (isNaN(a)) {
f = g = 64;
}
else {
c = buffer[++i];
f = ((b & 15) << 2) | (c >> 6);
g = isNaN(c) ? 64 : c & 63;
}

result.push(charset.charAt(d));
result.push(charset.charAt(e));
result.push(charset.charAt(f));
result.push(charset.charAt(g));
}

return result.join('');
}


$opal.defs(self, '$decode64', function(string) {
var self = this;

return decode(string.replace(/\r?\n/g, ''));
});

$opal.defs(self, '$encode64', function(string) {
var self = this;

return encode(string).replace(/(.{60})/g, "$1\n");
});

$opal.defs(self, '$strict_decode64', function(string) {
var self = this;

return decode(string);
});

$opal.defs(self, '$strict_encode64', function(string) {
var self = this;

return encode(string);
});

$opal.defs(self, '$urlsafe_decode64', function(string) {
var self = this;

return decode(string.replace(/\-/g, '+').replace(/_/g, '/'));
});

$opal.defs(self, '$urlsafe_encode64', function(string) {
var self = this;

return encode(string).replace(/\+/g, '-').replace(/\//g, '_');
});

})(self)
})(Opal);

//# sourceMappingURL=/__opal_source_maps__/base64.js.map
;
1 change: 1 addition & 0 deletions 0.6.0/base64.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added 0.6.0/base64.min.js.gz
Binary file not shown.

0 comments on commit b6f6917

Please sign in to comment.