js-base64 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": [ "es2015" ]
3
+ }
package/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: node_js
2
2
  node_js:
3
3
  - "node"
4
- - "iojs"
4
+
5
+
package/README.md CHANGED
@@ -18,6 +18,12 @@ Yet another Base64 transcoder
18
18
  var Base64 = require('js-base64').Base64;
19
19
  ```
20
20
 
21
+ ## es6+
22
+
23
+ ```javascript
24
+ import { Base64 } from 'js-base64';
25
+ ```
26
+
21
27
  ### npm
22
28
 
23
29
  ```javascript
@@ -63,6 +69,18 @@ TypeScript 2.0 type definition was added to the [DefinitelyTyped repository](htt
63
69
  $ npm install --save @types/js-base64
64
70
  ```
65
71
 
72
+ ## `.decode()` vs `.atob` (and `.encode()` vs `btoa()`)
73
+
74
+ Suppose you have:
75
+
76
+ ```
77
+ var pngBase64 =
78
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
79
+ ```
80
+
81
+ Which is a Base64-encoded 1x1 transparent PNG, **DO NOT USE** `Base64.decode(pngBase64)`.  Use `Base64.atob(pngBase64)` instead.  `Base64.decode()` decodes to UTF-8 string while `Base64.atob()` decodes to bytes, which is compatible to browser built-in `atob()` (Which is absent in node.js).  The same rule applies to the opposite direction.
82
+
83
+
66
84
  ## SEE ALSO
67
85
 
68
86
  + http://en.wikipedia.org/wiki/Base64
package/base64.js CHANGED
@@ -7,12 +7,19 @@
7
7
  * References:
8
8
  * http://en.wikipedia.org/wiki/Base64
9
9
  */
10
-
11
- (function(global) {
10
+ ;(function (global, factory) {
11
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(global) :
12
+ typeof define === 'function' && define.amd ? define(factory) :
13
+ global.moment = factory(global)
14
+ }(( typeof self !== 'undefined' ? self
15
+ : typeof window !== 'undefined' ? window
16
+ : typeof global !== 'undefined' ? global
17
+ : this
18
+ ), function(global) {
12
19
  'use strict';
13
20
  // existing version for noConflict()
14
21
  var _Base64 = global.Base64;
15
- var version = "2.2.1";
22
+ var version = "2.4.0";
16
23
  // if node.js, we use Buffer
17
24
  var buffer;
18
25
  if (typeof module !== 'undefined' && module.exports) {
@@ -72,7 +79,7 @@
72
79
  return b.replace(/[\s\S]{1,3}/g, cb_encode);
73
80
  };
74
81
  var _encode = buffer ?
75
- buffer.from ? function (u) {
82
+ buffer.from && buffer.from !== Uint8Array.from ? function (u) {
76
83
  return (u.constructor === buffer.constructor ? u : buffer.from(u))
77
84
  .toString('base64')
78
85
  }
@@ -143,7 +150,7 @@
143
150
  return a.replace(/[\s\S]{1,4}/g, cb_decode);
144
151
  };
145
152
  var _decode = buffer ?
146
- buffer.from ? function(a) {
153
+ buffer.from && buffer.from !== Uint8Array.from ? function(a) {
147
154
  return (a.constructor === buffer.constructor
148
155
  ? a : buffer.from(a, 'base64')).toString();
149
156
  }
@@ -197,5 +204,21 @@
197
204
  }));
198
205
  };
199
206
  }
207
+ //
208
+ // export Base64 to the namespace
209
+ //
210
+ if (global['Meteor']) { // Meteor.js
211
+ Base64 = global.Base64;
212
+ }
213
+ // module.exports and AMD are mutually exclusive.
214
+ // module.exports has precedence.
215
+ if (typeof module !== 'undefined' && module.exports) {
216
+ module.exports.Base64 = global.Base64;
217
+ }
218
+ else if (typeof define === 'function' && define.amd) {
219
+ // AMD. Register as an anonymous module.
220
+ define([], function(){ return global.Base64 });
221
+ }
200
222
  // that's it!
201
- })(this);
223
+ return {Base64: global.Base64}
224
+ }));
package/base64.js.bak ADDED
@@ -0,0 +1,224 @@
1
+ /*
2
+ * $Id: base64.js,v 2.15 2014/04/05 12:58:57 dankogai Exp dankogai $
3
+ *
4
+ * Licensed under the BSD 3-Clause License.
5
+ * http://opensource.org/licenses/BSD-3-Clause
6
+ *
7
+ * References:
8
+ * http://en.wikipedia.org/wiki/Base64
9
+ */
10
+ ;(function (global, factory) {
11
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(global) :
12
+ typeof define === 'function' && define.amd ? define(factory) :
13
+ global.moment = factory(global)
14
+ }(( typeof self !== 'undefined' ? self
15
+ : typeof window !== 'undefined' ? window
16
+ : typeof global !== 'undefined' ? global
17
+ : this
18
+ ), function(global) {
19
+ 'use strict';
20
+ // existing version for noConflict()
21
+ var _Base64 = global.Base64;
22
+ var version = "2.3.2";
23
+ // if node.js, we use Buffer
24
+ var buffer;
25
+ if (typeof module !== 'undefined' && module.exports) {
26
+ try {
27
+ buffer = require('buffer').Buffer;
28
+ } catch (err) {}
29
+ }
30
+ // constants
31
+ var b64chars
32
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
33
+ var b64tab = function(bin) {
34
+ var t = {};
35
+ for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
36
+ return t;
37
+ }(b64chars);
38
+ var fromCharCode = String.fromCharCode;
39
+ // encoder stuff
40
+ var cb_utob = function(c) {
41
+ if (c.length < 2) {
42
+ var cc = c.charCodeAt(0);
43
+ return cc < 0x80 ? c
44
+ : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
45
+ + fromCharCode(0x80 | (cc & 0x3f)))
46
+ : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
47
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
48
+ + fromCharCode(0x80 | ( cc & 0x3f)));
49
+ } else {
50
+ var cc = 0x10000
51
+ + (c.charCodeAt(0) - 0xD800) * 0x400
52
+ + (c.charCodeAt(1) - 0xDC00);
53
+ return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
54
+ + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
55
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
56
+ + fromCharCode(0x80 | ( cc & 0x3f)));
57
+ }
58
+ };
59
+ var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
60
+ var utob = function(u) {
61
+ return u.replace(re_utob, cb_utob);
62
+ };
63
+ var cb_encode = function(ccc) {
64
+ var padlen = [0, 2, 1][ccc.length % 3],
65
+ ord = ccc.charCodeAt(0) << 16
66
+ | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
67
+ | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
68
+ chars = [
69
+ b64chars.charAt( ord >>> 18),
70
+ b64chars.charAt((ord >>> 12) & 63),
71
+ padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
72
+ padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
73
+ ];
74
+ return chars.join('');
75
+ };
76
+ var btoa = global.btoa ? function(b) {
77
+ return global.btoa(b);
78
+ } : function(b) {
79
+ return b.replace(/[\s\S]{1,3}/g, cb_encode);
80
+ };
81
+ var _encode = buffer ?
82
+ buffer.from && buffer.from !== Uint8Array.from ? function (u) {
83
+ return (u.constructor === buffer.constructor ? u : buffer.from(u))
84
+ .toString('base64')
85
+ }
86
+ : function (u) {
87
+ return (u.constructor === buffer.constructor ? u : new buffer(u))
88
+ .toString('base64')
89
+ }
90
+ : function (u) { return btoa(utob(u)) }
91
+ ;
92
+ var encode = function(u, urisafe) {
93
+ return !urisafe
94
+ ? _encode(String(u))
95
+ : _encode(String(u)).replace(/[+\/]/g, function(m0) {
96
+ return m0 == '+' ? '-' : '_';
97
+ }).replace(/=/g, '');
98
+ };
99
+ var encodeURI = function(u) { return encode(u, true) };
100
+ // decoder stuff
101
+ var re_btou = new RegExp([
102
+ '[\xC0-\xDF][\x80-\xBF]',
103
+ '[\xE0-\xEF][\x80-\xBF]{2}',
104
+ '[\xF0-\xF7][\x80-\xBF]{3}'
105
+ ].join('|'), 'g');
106
+ var cb_btou = function(cccc) {
107
+ switch(cccc.length) {
108
+ case 4:
109
+ var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
110
+ | ((0x3f & cccc.charCodeAt(1)) << 12)
111
+ | ((0x3f & cccc.charCodeAt(2)) << 6)
112
+ | (0x3f & cccc.charCodeAt(3)),
113
+ offset = cp - 0x10000;
114
+ return (fromCharCode((offset >>> 10) + 0xD800)
115
+ + fromCharCode((offset & 0x3FF) + 0xDC00));
116
+ case 3:
117
+ return fromCharCode(
118
+ ((0x0f & cccc.charCodeAt(0)) << 12)
119
+ | ((0x3f & cccc.charCodeAt(1)) << 6)
120
+ | (0x3f & cccc.charCodeAt(2))
121
+ );
122
+ default:
123
+ return fromCharCode(
124
+ ((0x1f & cccc.charCodeAt(0)) << 6)
125
+ | (0x3f & cccc.charCodeAt(1))
126
+ );
127
+ }
128
+ };
129
+ var btou = function(b) {
130
+ return b.replace(re_btou, cb_btou);
131
+ };
132
+ var cb_decode = function(cccc) {
133
+ var len = cccc.length,
134
+ padlen = len % 4,
135
+ n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
136
+ | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
137
+ | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
138
+ | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
139
+ chars = [
140
+ fromCharCode( n >>> 16),
141
+ fromCharCode((n >>> 8) & 0xff),
142
+ fromCharCode( n & 0xff)
143
+ ];
144
+ chars.length -= [0, 0, 2, 1][padlen];
145
+ return chars.join('');
146
+ };
147
+ var atob = global.atob ? function(a) {
148
+ return global.atob(a);
149
+ } : function(a){
150
+ return a.replace(/[\s\S]{1,4}/g, cb_decode);
151
+ };
152
+ var _decode = buffer ?
153
+ buffer.from && buffer.from !== Uint8Array.from ? function(a) {
154
+ return (a.constructor === buffer.constructor
155
+ ? a : buffer.from(a, 'base64')).toString();
156
+ }
157
+ : function(a) {
158
+ return (a.constructor === buffer.constructor
159
+ ? a : new buffer(a, 'base64')).toString();
160
+ }
161
+ : function(a) { return btou(atob(a)) };
162
+ var decode = function(a){
163
+ return _decode(
164
+ String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
165
+ .replace(/[^A-Za-z0-9\+\/]/g, '')
166
+ );
167
+ };
168
+ var noConflict = function() {
169
+ var Base64 = global.Base64;
170
+ global.Base64 = _Base64;
171
+ return Base64;
172
+ };
173
+ // export Base64
174
+ global.Base64 = {
175
+ VERSION: version,
176
+ atob: atob,
177
+ btoa: btoa,
178
+ fromBase64: decode,
179
+ toBase64: encode,
180
+ utob: utob,
181
+ encode: encode,
182
+ encodeURI: encodeURI,
183
+ btou: btou,
184
+ decode: decode,
185
+ noConflict: noConflict
186
+ };
187
+ // if ES5 is available, make Base64.extendString() available
188
+ if (typeof Object.defineProperty === 'function') {
189
+ var noEnum = function(v){
190
+ return {value:v,enumerable:false,writable:true,configurable:true};
191
+ };
192
+ global.Base64.extendString = function () {
193
+ Object.defineProperty(
194
+ String.prototype, 'fromBase64', noEnum(function () {
195
+ return decode(this)
196
+ }));
197
+ Object.defineProperty(
198
+ String.prototype, 'toBase64', noEnum(function (urisafe) {
199
+ return encode(this, urisafe)
200
+ }));
201
+ Object.defineProperty(
202
+ String.prototype, 'toBase64URI', noEnum(function () {
203
+ return encode(this, true)
204
+ }));
205
+ };
206
+ }
207
+ //
208
+ // export Base64 to the namespace
209
+ //
210
+ if (global['Meteor']) { // Meteor.js
211
+ Base64 = global.Base64;
212
+ }
213
+ // module.exports and AMD are mutually exclusive.
214
+ // module.exports has precedence.
215
+ if (typeof module !== 'undefined' && module.exports) {
216
+ module.exports.Base64 = global.Base64;
217
+ }
218
+ else if (typeof define === 'function' && define.amd) {
219
+ // AMD. Register as an anonymous module.
220
+ define([], function(){ return global.Base64 });
221
+ }
222
+ // that's it!
223
+ return {Base64: global.Base64}
224
+ }));
package/base64.min.js CHANGED
@@ -1 +1 @@
1
- (function(global){"use strict";var _Base64=global.Base64;var version="2.2.1";var buffer;if(typeof module!=="undefined"&&module.exports){try{buffer=require("buffer").Buffer}catch(err){}}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64tab=function(bin){var t={};for(var i=0,l=bin.length;i<l;i++)t[bin.charAt(i)]=i;return t}(b64chars);var fromCharCode=String.fromCharCode;var cb_utob=function(c){if(c.length<2){var cc=c.charCodeAt(0);return cc<128?c:cc<2048?fromCharCode(192|cc>>>6)+fromCharCode(128|cc&63):fromCharCode(224|cc>>>12&15)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}else{var cc=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return fromCharCode(240|cc>>>18&7)+fromCharCode(128|cc>>>12&63)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}};var re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;var utob=function(u){return u.replace(re_utob,cb_utob)};var cb_encode=function(ccc){var padlen=[0,2,1][ccc.length%3],ord=ccc.charCodeAt(0)<<16|(ccc.length>1?ccc.charCodeAt(1):0)<<8|(ccc.length>2?ccc.charCodeAt(2):0),chars=[b64chars.charAt(ord>>>18),b64chars.charAt(ord>>>12&63),padlen>=2?"=":b64chars.charAt(ord>>>6&63),padlen>=1?"=":b64chars.charAt(ord&63)];return chars.join("")};var btoa=global.btoa?function(b){return global.btoa(b)}:function(b){return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=buffer?buffer.from?function(u){return(u.constructor===buffer.constructor?u:buffer.from(u)).toString("base64")}:function(u){return(u.constructor===buffer.constructor?u:new buffer(u)).toString("base64")}:function(u){return btoa(utob(u))};var encode=function(u,urisafe){return!urisafe?_encode(String(u)):_encode(String(u)).replace(/[+\/]/g,function(m0){return m0=="+"?"-":"_"}).replace(/=/g,"")};var encodeURI=function(u){return encode(u,true)};var re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g");var cb_btou=function(cccc){switch(cccc.length){case 4:var cp=(7&cccc.charCodeAt(0))<<18|(63&cccc.charCodeAt(1))<<12|(63&cccc.charCodeAt(2))<<6|63&cccc.charCodeAt(3),offset=cp-65536;return fromCharCode((offset>>>10)+55296)+fromCharCode((offset&1023)+56320);case 3:return fromCharCode((15&cccc.charCodeAt(0))<<12|(63&cccc.charCodeAt(1))<<6|63&cccc.charCodeAt(2));default:return fromCharCode((31&cccc.charCodeAt(0))<<6|63&cccc.charCodeAt(1))}};var btou=function(b){return b.replace(re_btou,cb_btou)};var cb_decode=function(cccc){var len=cccc.length,padlen=len%4,n=(len>0?b64tab[cccc.charAt(0)]<<18:0)|(len>1?b64tab[cccc.charAt(1)]<<12:0)|(len>2?b64tab[cccc.charAt(2)]<<6:0)|(len>3?b64tab[cccc.charAt(3)]:0),chars=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(n&255)];chars.length-=[0,0,2,1][padlen];return chars.join("")};var atob=global.atob?function(a){return global.atob(a)}:function(a){return a.replace(/[\s\S]{1,4}/g,cb_decode)};var _decode=buffer?buffer.from?function(a){return(a.constructor===buffer.constructor?a:buffer.from(a,"base64")).toString()}:function(a){return(a.constructor===buffer.constructor?a:new buffer(a,"base64")).toString()}:function(a){return btou(atob(a))};var decode=function(a){return _decode(String(a).replace(/[-_]/g,function(m0){return m0=="-"?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))};var noConflict=function(){var Base64=global.Base64;global.Base64=_Base64;return Base64};global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict};if(typeof Object.defineProperty==="function"){var noEnum=function(v){return{value:v,enumerable:false,writable:true,configurable:true}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)}));Object.defineProperty(String.prototype,"toBase64",noEnum(function(urisafe){return encode(this,urisafe)}));Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,true)}))}}})(this);
1
+ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(global):typeof define==="function"&&define.amd?define(factory):global.moment=factory(global)})(typeof self!=="undefined"?self:typeof window!=="undefined"?window:typeof global!=="undefined"?global:this,function(global){"use strict";var _Base64=global.Base64;var version="2.4.0";var buffer;if(typeof module!=="undefined"&&module.exports){try{buffer=require("buffer").Buffer}catch(err){}}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64tab=function(bin){var t={};for(var i=0,l=bin.length;i<l;i++)t[bin.charAt(i)]=i;return t}(b64chars);var fromCharCode=String.fromCharCode;var cb_utob=function(c){if(c.length<2){var cc=c.charCodeAt(0);return cc<128?c:cc<2048?fromCharCode(192|cc>>>6)+fromCharCode(128|cc&63):fromCharCode(224|cc>>>12&15)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}else{var cc=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return fromCharCode(240|cc>>>18&7)+fromCharCode(128|cc>>>12&63)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}};var re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;var utob=function(u){return u.replace(re_utob,cb_utob)};var cb_encode=function(ccc){var padlen=[0,2,1][ccc.length%3],ord=ccc.charCodeAt(0)<<16|(ccc.length>1?ccc.charCodeAt(1):0)<<8|(ccc.length>2?ccc.charCodeAt(2):0),chars=[b64chars.charAt(ord>>>18),b64chars.charAt(ord>>>12&63),padlen>=2?"=":b64chars.charAt(ord>>>6&63),padlen>=1?"=":b64chars.charAt(ord&63)];return chars.join("")};var btoa=global.btoa?function(b){return global.btoa(b)}:function(b){return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(u){return(u.constructor===buffer.constructor?u:buffer.from(u)).toString("base64")}:function(u){return(u.constructor===buffer.constructor?u:new buffer(u)).toString("base64")}:function(u){return btoa(utob(u))};var encode=function(u,urisafe){return!urisafe?_encode(String(u)):_encode(String(u)).replace(/[+\/]/g,function(m0){return m0=="+"?"-":"_"}).replace(/=/g,"")};var encodeURI=function(u){return encode(u,true)};var re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g");var cb_btou=function(cccc){switch(cccc.length){case 4:var cp=(7&cccc.charCodeAt(0))<<18|(63&cccc.charCodeAt(1))<<12|(63&cccc.charCodeAt(2))<<6|63&cccc.charCodeAt(3),offset=cp-65536;return fromCharCode((offset>>>10)+55296)+fromCharCode((offset&1023)+56320);case 3:return fromCharCode((15&cccc.charCodeAt(0))<<12|(63&cccc.charCodeAt(1))<<6|63&cccc.charCodeAt(2));default:return fromCharCode((31&cccc.charCodeAt(0))<<6|63&cccc.charCodeAt(1))}};var btou=function(b){return b.replace(re_btou,cb_btou)};var cb_decode=function(cccc){var len=cccc.length,padlen=len%4,n=(len>0?b64tab[cccc.charAt(0)]<<18:0)|(len>1?b64tab[cccc.charAt(1)]<<12:0)|(len>2?b64tab[cccc.charAt(2)]<<6:0)|(len>3?b64tab[cccc.charAt(3)]:0),chars=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(n&255)];chars.length-=[0,0,2,1][padlen];return chars.join("")};var atob=global.atob?function(a){return global.atob(a)}:function(a){return a.replace(/[\s\S]{1,4}/g,cb_decode)};var _decode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(a){return(a.constructor===buffer.constructor?a:buffer.from(a,"base64")).toString()}:function(a){return(a.constructor===buffer.constructor?a:new buffer(a,"base64")).toString()}:function(a){return btou(atob(a))};var decode=function(a){return _decode(String(a).replace(/[-_]/g,function(m0){return m0=="-"?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))};var noConflict=function(){var Base64=global.Base64;global.Base64=_Base64;return Base64};global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict};if(typeof Object.defineProperty==="function"){var noEnum=function(v){return{value:v,enumerable:false,writable:true,configurable:true}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)}));Object.defineProperty(String.prototype,"toBase64",noEnum(function(urisafe){return encode(this,urisafe)}));Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,true)}))}}if(global["Meteor"]){Base64=global.Base64}if(typeof module!=="undefined"&&module.exports){module.exports.Base64=global.Base64}else if(typeof define==="function"&&define.amd){define([],function(){return global.Base64})}return{Base64:global.Base64}});
@@ -0,0 +1 @@
1
+ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(global):typeof define==="function"&&define.amd?define(factory):global.moment=factory(global)}((typeof self!=="undefined"?self:typeof window!=="undefined"?window:typeof global!=="undefined"?global:this),function(global){var _Base64=global.Base64;var version="2.3.2";var buffer;if(typeof module!=="undefined"&&module.exports){try{buffer=require("buffer").Buffer}catch(err){}}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64tab=function(bin){var t={};for(var i=0,l=bin.length;i<l;i++){t[bin.charAt(i)]=i}return t}(b64chars);var fromCharCode=String.fromCharCode;var cb_utob=function(c){if(c.length<2){var cc=c.charCodeAt(0);return cc<128?c:cc<2048?(fromCharCode(192|(cc>>>6))+fromCharCode(128|(cc&63))):(fromCharCode(224|((cc>>>12)&15))+fromCharCode(128|((cc>>>6)&63))+fromCharCode(128|(cc&63)))}else{var cc=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return(fromCharCode(240|((cc>>>18)&7))+fromCharCode(128|((cc>>>12)&63))+fromCharCode(128|((cc>>>6)&63))+fromCharCode(128|(cc&63)))}};var re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;var utob=function(u){return u.replace(re_utob,cb_utob)};var cb_encode=function(ccc){var padlen=[0,2,1][ccc.length%3],ord=ccc.charCodeAt(0)<<16|((ccc.length>1?ccc.charCodeAt(1):0)<<8)|((ccc.length>2?ccc.charCodeAt(2):0)),chars=[b64chars.charAt(ord>>>18),b64chars.charAt((ord>>>12)&63),padlen>=2?"=":b64chars.charAt((ord>>>6)&63),padlen>=1?"=":b64chars.charAt(ord&63)];return chars.join("")};var btoa=global.btoa?function(b){return global.btoa(b)}:function(b){return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(u){return(u.constructor===buffer.constructor?u:buffer.from(u)).toString("base64")}:function(u){return(u.constructor===buffer.constructor?u:new buffer(u)).toString("base64")}:function(u){return btoa(utob(u))};var encode=function(u,urisafe){return !urisafe?_encode(String(u)):_encode(String(u)).replace(/[+\/]/g,function(m0){return m0=="+"?"-":"_"}).replace(/=/g,"")};var encodeURI=function(u){return encode(u,true)};var re_btou=new RegExp(["[\xC0-\xDF][\x80-\xBF]","[\xE0-\xEF][\x80-\xBF]{2}","[\xF0-\xF7][\x80-\xBF]{3}"].join("|"),"g");var cb_btou=function(cccc){switch(cccc.length){case 4:var cp=((7&cccc.charCodeAt(0))<<18)|((63&cccc.charCodeAt(1))<<12)|((63&cccc.charCodeAt(2))<<6)|(63&cccc.charCodeAt(3)),offset=cp-65536;return(fromCharCode((offset>>>10)+55296)+fromCharCode((offset&1023)+56320));case 3:return fromCharCode(((15&cccc.charCodeAt(0))<<12)|((63&cccc.charCodeAt(1))<<6)|(63&cccc.charCodeAt(2)));default:return fromCharCode(((31&cccc.charCodeAt(0))<<6)|(63&cccc.charCodeAt(1)))}};var btou=function(b){return b.replace(re_btou,cb_btou)};var cb_decode=function(cccc){var len=cccc.length,padlen=len%4,n=(len>0?b64tab[cccc.charAt(0)]<<18:0)|(len>1?b64tab[cccc.charAt(1)]<<12:0)|(len>2?b64tab[cccc.charAt(2)]<<6:0)|(len>3?b64tab[cccc.charAt(3)]:0),chars=[fromCharCode(n>>>16),fromCharCode((n>>>8)&255),fromCharCode(n&255)];chars.length-=[0,0,2,1][padlen];return chars.join("")};var atob=global.atob?function(a){return global.atob(a)}:function(a){return a.replace(/[\s\S]{1,4}/g,cb_decode)};var _decode=buffer?buffer.from&&buffer.from!==Uint8Array.from?function(a){return(a.constructor===buffer.constructor?a:buffer.from(a,"base64")).toString()}:function(a){return(a.constructor===buffer.constructor?a:new buffer(a,"base64")).toString()}:function(a){return btou(atob(a))};var decode=function(a){return _decode(String(a).replace(/[-_]/g,function(m0){return m0=="-"?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))};var noConflict=function(){var Base64=global.Base64;global.Base64=_Base64;return Base64};global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict};if(typeof Object.defineProperty==="function"){var noEnum=function(v){return{value:v,enumerable:false,writable:true,configurable:true}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)}));Object.defineProperty(String.prototype,"toBase64",noEnum(function(urisafe){return encode(this,urisafe)}));Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,true)}))}}if(global["Meteor"]){Base64=global.Base64}if(typeof module!=="undefined"&&module.exports){module.exports.Base64=global.Base64}else{if(typeof define==="function"&&define.amd){define([],function(){return global.Base64})}}return{Base64:global.Base64}}));
package/base64_utf8 CHANGED
@@ -1,11 +1,22 @@
1
- (function(global) {
1
+ ;(function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(global) :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ global.moment = factory(global)
5
+ }(( typeof self !== 'undefined' ? self
6
+ : typeof window !== 'undefined' ? window
7
+ : typeof global !== 'undefined' ? global
8
+ : this
9
+ ), function(global) {
2
10
  'use strict';
3
- if (global.Base64) return;
4
- var version = "2.1.1";
11
+ // existing version for noConflict()
12
+ var _Base64 = global.Base64;
13
+ var version = "2.4.0";
5
14
  // if node.js, we use Buffer
6
15
  var buffer;
7
16
  if (typeof module !== 'undefined' && module.exports) {
8
- buffer = require('buffer').Buffer;
17
+ try {
18
+ buffer = require('buffer').Buffer;
19
+ } catch (err) {}
9
20
  }
10
21
  // constants
11
22
  var b64chars
@@ -53,17 +64,26 @@
53
64
  ];
54
65
  return chars.join('');
55
66
  };
56
- var btoa = global.btoa || function(b) {
67
+ var btoa = global.btoa ? function(b) {
68
+ return global.btoa(b);
69
+ } : function(b) {
57
70
  return b.replace(/[\s\S]{1,3}/g, cb_encode);
58
71
  };
59
- var _encode = buffer
60
- ? function (u) { return _utf8_encode((new buffer(u)).toString('base64')) }
61
- : function (u) { return _utf8_encode(btoa(utob(u))) }
72
+ var _encode = buffer ?
73
+ buffer.from && buffer.from !== Uint8Array.from ? function (u) {
74
+ return (u.constructor === buffer.constructor ? u : buffer.from(u))
75
+ .toString('base64')
76
+ }
77
+ : function (u) {
78
+ return (u.constructor === buffer.constructor ? u : new buffer(u))
79
+ .toString('base64')
80
+ }
81
+ : function (u) { return btoa(utob(u)) }
62
82
  ;
63
83
  var encode = function(u, urisafe) {
64
- return !urisafe
65
- ? _encode(u)
66
- : _encode(u).replace(/[+\/]/g, function(m0) {
84
+ return !urisafe
85
+ ? _encode(String(u))
86
+ : _encode(String(u)).replace(/[+\/]/g, function(m0) {
67
87
  return m0 == '+' ? '-' : '_';
68
88
  }).replace(/=/g, '');
69
89
  };
@@ -97,60 +117,6 @@
97
117
  );
98
118
  }
99
119
  };
100
- var _utf8_encode = function ( string ) {
101
- string = string.replace(/\r\n/g,"\n");
102
- var utftext = "";
103
-
104
- for (var n = 0; n < string.length; n++) {
105
-
106
- var c = string.charCodeAt(n);
107
-
108
- if (c < 128) {
109
- utftext += String.fromCharCode(c);
110
- }
111
- else if((c > 127) && (c < 2048)) {
112
- utftext += String.fromCharCode((c >> 6) | 192);
113
- utftext += String.fromCharCode((c & 63) | 128);
114
- }
115
- else {
116
- utftext += String.fromCharCode((c >> 12) | 224);
117
- utftext += String.fromCharCode(((c >> 6) & 63) | 128);
118
- utftext += String.fromCharCode((c & 63) | 128);
119
- }
120
-
121
- }
122
-
123
- return utftext;
124
- };
125
- var _utf8_decode = function (utftext) {
126
- var string = "";
127
- var i = 0;
128
- var c = c1 = c2 = 0;
129
-
130
- while ( i < utftext.length ) {
131
-
132
- c = utftext.charCodeAt(i);
133
-
134
- if (c < 128) {
135
- string += String.fromCharCode(c);
136
- i++;
137
- }
138
- else if((c > 191) && (c < 224)) {
139
- c2 = utftext.charCodeAt(i+1);
140
- string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
141
- i += 2;
142
- }
143
- else {
144
- c2 = utftext.charCodeAt(i+1);
145
- c3 = utftext.charCodeAt(i+2);
146
- string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
147
- i += 3;
148
- }
149
-
150
- }
151
-
152
- return string;
153
- };
154
120
  var btou = function(b) {
155
121
  return b.replace(re_btou, cb_btou);
156
122
  };
@@ -169,19 +135,32 @@
169
135
  chars.length -= [0, 0, 2, 1][padlen];
170
136
  return chars.join('');
171
137
  };
172
- var atob = global.atob || function(a){
138
+ var atob = global.atob ? function(a) {
139
+ return global.atob(a);
140
+ } : function(a){
173
141
  return a.replace(/[\s\S]{1,4}/g, cb_decode);
174
142
  };
175
- var _decode = buffer
176
- ? function(a) { return (new buffer(a, 'base64')).toString() }
177
- : function(a) { return btou(atob(a)) };
143
+ var _decode = buffer ?
144
+ buffer.from && buffer.from !== Uint8Array.from ? function(a) {
145
+ return (a.constructor === buffer.constructor
146
+ ? a : buffer.from(a, 'base64')).toString();
147
+ }
148
+ : function(a) {
149
+ return (a.constructor === buffer.constructor
150
+ ? a : new buffer(a, 'base64')).toString();
151
+ }
152
+ : function(a) { return btou(atob(a)) };
178
153
  var decode = function(a){
179
- a = _utf8_decode( a );
180
154
  return _decode(
181
- a.replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
155
+ String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
182
156
  .replace(/[^A-Za-z0-9\+\/]/g, '')
183
157
  );
184
158
  };
159
+ var noConflict = function() {
160
+ var Base64 = global.Base64;
161
+ global.Base64 = _Base64;
162
+ return Base64;
163
+ };
185
164
  // export Base64
186
165
  global.Base64 = {
187
166
  VERSION: version,
@@ -193,7 +172,8 @@
193
172
  encode: encode,
194
173
  encodeURI: encodeURI,
195
174
  btou: btou,
196
- decode: decode
175
+ decode: decode,
176
+ noConflict: noConflict
197
177
  };
198
178
  // if ES5 is available, make Base64.extendString() available
199
179
  if (typeof Object.defineProperty === 'function') {
@@ -215,5 +195,21 @@
215
195
  }));
216
196
  };
217
197
  }
198
+ //
199
+ // export Base64 to the namespace
200
+ //
201
+ if (global['Meteor']) { // Meteor.js
202
+ Base64 = global.Base64;
203
+ }
204
+ // module.exports and AMD are mutually exclusive.
205
+ // module.exports has precedence.
206
+ if (typeof module !== 'undefined' && module.exports) {
207
+ module.exports.Base64 = global.Base64;
208
+ }
209
+ else if (typeof define === 'function' && define.amd) {
210
+ // AMD. Register as an anonymous module.
211
+ define([], function(){ return global.Base64 });
212
+ }
218
213
  // that's it!
219
- })(this);
214
+ return {Base64: global.Base64}
215
+ }));
@@ -0,0 +1,215 @@
1
+ ;(function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(global) :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ global.moment = factory(global)
5
+ }(( typeof self !== 'undefined' ? self
6
+ : typeof window !== 'undefined' ? window
7
+ : typeof global !== 'undefined' ? global
8
+ : this
9
+ ), function(global) {
10
+ 'use strict';
11
+ // existing version for noConflict()
12
+ var _Base64 = global.Base64;
13
+ var version = "2.3.2";
14
+ // if node.js, we use Buffer
15
+ var buffer;
16
+ if (typeof module !== 'undefined' && module.exports) {
17
+ try {
18
+ buffer = require('buffer').Buffer;
19
+ } catch (err) {}
20
+ }
21
+ // constants
22
+ var b64chars
23
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
24
+ var b64tab = function(bin) {
25
+ var t = {};
26
+ for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
27
+ return t;
28
+ }(b64chars);
29
+ var fromCharCode = String.fromCharCode;
30
+ // encoder stuff
31
+ var cb_utob = function(c) {
32
+ if (c.length < 2) {
33
+ var cc = c.charCodeAt(0);
34
+ return cc < 0x80 ? c
35
+ : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
36
+ + fromCharCode(0x80 | (cc & 0x3f)))
37
+ : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
38
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
39
+ + fromCharCode(0x80 | ( cc & 0x3f)));
40
+ } else {
41
+ var cc = 0x10000
42
+ + (c.charCodeAt(0) - 0xD800) * 0x400
43
+ + (c.charCodeAt(1) - 0xDC00);
44
+ return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
45
+ + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
46
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
47
+ + fromCharCode(0x80 | ( cc & 0x3f)));
48
+ }
49
+ };
50
+ var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
51
+ var utob = function(u) {
52
+ return u.replace(re_utob, cb_utob);
53
+ };
54
+ var cb_encode = function(ccc) {
55
+ var padlen = [0, 2, 1][ccc.length % 3],
56
+ ord = ccc.charCodeAt(0) << 16
57
+ | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
58
+ | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
59
+ chars = [
60
+ b64chars.charAt( ord >>> 18),
61
+ b64chars.charAt((ord >>> 12) & 63),
62
+ padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
63
+ padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
64
+ ];
65
+ return chars.join('');
66
+ };
67
+ var btoa = global.btoa ? function(b) {
68
+ return global.btoa(b);
69
+ } : function(b) {
70
+ return b.replace(/[\s\S]{1,3}/g, cb_encode);
71
+ };
72
+ var _encode = buffer ?
73
+ buffer.from && buffer.from !== Uint8Array.from ? function (u) {
74
+ return (u.constructor === buffer.constructor ? u : buffer.from(u))
75
+ .toString('base64')
76
+ }
77
+ : function (u) {
78
+ return (u.constructor === buffer.constructor ? u : new buffer(u))
79
+ .toString('base64')
80
+ }
81
+ : function (u) { return btoa(utob(u)) }
82
+ ;
83
+ var encode = function(u, urisafe) {
84
+ return !urisafe
85
+ ? _encode(String(u))
86
+ : _encode(String(u)).replace(/[+\/]/g, function(m0) {
87
+ return m0 == '+' ? '-' : '_';
88
+ }).replace(/=/g, '');
89
+ };
90
+ var encodeURI = function(u) { return encode(u, true) };
91
+ // decoder stuff
92
+ var re_btou = new RegExp([
93
+ '[\xC0-\xDF][\x80-\xBF]',
94
+ '[\xE0-\xEF][\x80-\xBF]{2}',
95
+ '[\xF0-\xF7][\x80-\xBF]{3}'
96
+ ].join('|'), 'g');
97
+ var cb_btou = function(cccc) {
98
+ switch(cccc.length) {
99
+ case 4:
100
+ var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
101
+ | ((0x3f & cccc.charCodeAt(1)) << 12)
102
+ | ((0x3f & cccc.charCodeAt(2)) << 6)
103
+ | (0x3f & cccc.charCodeAt(3)),
104
+ offset = cp - 0x10000;
105
+ return (fromCharCode((offset >>> 10) + 0xD800)
106
+ + fromCharCode((offset & 0x3FF) + 0xDC00));
107
+ case 3:
108
+ return fromCharCode(
109
+ ((0x0f & cccc.charCodeAt(0)) << 12)
110
+ | ((0x3f & cccc.charCodeAt(1)) << 6)
111
+ | (0x3f & cccc.charCodeAt(2))
112
+ );
113
+ default:
114
+ return fromCharCode(
115
+ ((0x1f & cccc.charCodeAt(0)) << 6)
116
+ | (0x3f & cccc.charCodeAt(1))
117
+ );
118
+ }
119
+ };
120
+ var btou = function(b) {
121
+ return b.replace(re_btou, cb_btou);
122
+ };
123
+ var cb_decode = function(cccc) {
124
+ var len = cccc.length,
125
+ padlen = len % 4,
126
+ n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
127
+ | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
128
+ | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
129
+ | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
130
+ chars = [
131
+ fromCharCode( n >>> 16),
132
+ fromCharCode((n >>> 8) & 0xff),
133
+ fromCharCode( n & 0xff)
134
+ ];
135
+ chars.length -= [0, 0, 2, 1][padlen];
136
+ return chars.join('');
137
+ };
138
+ var atob = global.atob ? function(a) {
139
+ return global.atob(a);
140
+ } : function(a){
141
+ return a.replace(/[\s\S]{1,4}/g, cb_decode);
142
+ };
143
+ var _decode = buffer ?
144
+ buffer.from && buffer.from !== Uint8Array.from ? function(a) {
145
+ return (a.constructor === buffer.constructor
146
+ ? a : buffer.from(a, 'base64')).toString();
147
+ }
148
+ : function(a) {
149
+ return (a.constructor === buffer.constructor
150
+ ? a : new buffer(a, 'base64')).toString();
151
+ }
152
+ : function(a) { return btou(atob(a)) };
153
+ var decode = function(a){
154
+ return _decode(
155
+ String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
156
+ .replace(/[^A-Za-z0-9\+\/]/g, '')
157
+ );
158
+ };
159
+ var noConflict = function() {
160
+ var Base64 = global.Base64;
161
+ global.Base64 = _Base64;
162
+ return Base64;
163
+ };
164
+ // export Base64
165
+ global.Base64 = {
166
+ VERSION: version,
167
+ atob: atob,
168
+ btoa: btoa,
169
+ fromBase64: decode,
170
+ toBase64: encode,
171
+ utob: utob,
172
+ encode: encode,
173
+ encodeURI: encodeURI,
174
+ btou: btou,
175
+ decode: decode,
176
+ noConflict: noConflict
177
+ };
178
+ // if ES5 is available, make Base64.extendString() available
179
+ if (typeof Object.defineProperty === 'function') {
180
+ var noEnum = function(v){
181
+ return {value:v,enumerable:false,writable:true,configurable:true};
182
+ };
183
+ global.Base64.extendString = function () {
184
+ Object.defineProperty(
185
+ String.prototype, 'fromBase64', noEnum(function () {
186
+ return decode(this)
187
+ }));
188
+ Object.defineProperty(
189
+ String.prototype, 'toBase64', noEnum(function (urisafe) {
190
+ return encode(this, urisafe)
191
+ }));
192
+ Object.defineProperty(
193
+ String.prototype, 'toBase64URI', noEnum(function () {
194
+ return encode(this, true)
195
+ }));
196
+ };
197
+ }
198
+ //
199
+ // export Base64 to the namespace
200
+ //
201
+ if (global['Meteor']) { // Meteor.js
202
+ Base64 = global.Base64;
203
+ }
204
+ // module.exports and AMD are mutually exclusive.
205
+ // module.exports has precedence.
206
+ if (typeof module !== 'undefined' && module.exports) {
207
+ module.exports.Base64 = global.Base64;
208
+ }
209
+ else if (typeof define === 'function' && define.amd) {
210
+ // AMD. Register as an anonymous module.
211
+ define([], function(){ return global.Base64 });
212
+ }
213
+ // that's it!
214
+ return {Base64: global.Base64}
215
+ }));
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "js-base64",
3
- "version": "2.2.1",
4
- "license": "BSD 3-Clause",
3
+ "version": "2.4.0",
4
+ "license": "BSD-3-Clause",
5
5
  "main": [
6
6
  "./base64.js"
7
7
  ],
package/bower.json.bak ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "js-base64",
3
+ "version": "2.3.2",
4
+ "license": "BSD-3-Clause",
5
+ "main": [
6
+ "./base64.js"
7
+ ],
8
+ "ignore": [
9
+ "old",
10
+ "test",
11
+ ".gitignore",
12
+ ".travis.yml",
13
+ "base64.html",
14
+ "package.json"
15
+ ],
16
+ "dependencies": {
17
+ }
18
+ }
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "js-base64",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "Yet another Base64 transcoder in pure-JS",
5
5
  "main": "base64.js",
6
6
  "directories": {
7
7
  "test": "test"
8
8
  },
9
9
  "scripts": {
10
- "test": "mocha"
10
+ "test": "mocha --compilers js:babel-register"
11
11
  },
12
12
  "devDependencies": {
13
+ "babel-preset-es2015": "^6.24.1",
14
+ "babel-register": "^6.26.0",
13
15
  "mocha": "*"
14
16
  },
15
17
  "repository": {
@@ -20,7 +22,7 @@
20
22
  "base64"
21
23
  ],
22
24
  "author": "Dan Kogai",
23
- "license": "BSD 3-Clause",
25
+ "license": "BSD-3-Clause",
24
26
  "readmeFilename": "README.md",
25
27
  "gitHead": "8bfa436f733bec60c95c720e1d720c28b43ae0b2"
26
28
  }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "js-base64",
3
+ "version": "2.3.2",
4
+ "description": "Yet another Base64 transcoder in pure-JS",
5
+ "main": "base64.js",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "scripts": {
10
+ "test": "mocha --compilers js:babel-register"
11
+ },
12
+ "devDependencies": {
13
+ "babel-preset-es2015": "^6.24.1",
14
+ "babel-register": "^6.26.0",
15
+ "mocha": "*"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git://github.com/dankogai/js-base64.git"
20
+ },
21
+ "keywords": [
22
+ "base64"
23
+ ],
24
+ "author": "Dan Kogai",
25
+ "license": "BSD-3-Clause",
26
+ "readmeFilename": "README.md",
27
+ "gitHead": "8bfa436f733bec60c95c720e1d720c28b43ae0b2"
28
+ }
package/test/dankogai.js CHANGED
@@ -4,11 +4,8 @@
4
4
  * use mocha to test me
5
5
  * http://visionmedia.github.com/mocha/
6
6
  */
7
- var assert, Base64;
8
- if (this['window'] !== this) {
9
- assert = require("assert");
10
- Base64 = require('../base64.js').Base64;
11
- }
7
+ var assert = assert || require("assert");
8
+ var Base64 = Base64 || require('../base64.js').Base64;
12
9
  var is = function (a, e, m) {
13
10
  return function () {
14
11
  assert.equal(a, e, m)
package/test/es5.js CHANGED
@@ -4,11 +4,8 @@
4
4
  * use mocha to test me
5
5
  * http://visionmedia.github.com/mocha/
6
6
  */
7
- var assert, Base64;
8
- if (this['window'] !== this) {
9
- assert = require("assert");
10
- Base64 = require('../base64.js').Base64;
11
- }
7
+ var assert = assert || require("assert");
8
+ var Base64 = Base64 || require('../base64.js').Base64;
12
9
  var is = function (a, e, m) {
13
10
  return function () {
14
11
  assert.equal(a, e, m)
package/test/es6.js ADDED
@@ -0,0 +1,25 @@
1
+ /*
2
+ * $Id: es6.js,v 0.1 2017/11/29 21:43:17 ufolux Exp ufolux $
3
+ *
4
+ * use mocha to test me
5
+ * http://visionmedia.github.com/mocha/
6
+ */
7
+ import {Base64} from '../base64'
8
+
9
+ var assert = assert || require("assert");
10
+ var is = function (a, e, m) {
11
+ return function () {
12
+ assert.equal(a, e, m)
13
+ }
14
+ };
15
+
16
+ if ('extendString' in Base64){
17
+ Base64.extendString();
18
+ describe('String', function () {
19
+ it('.toBase64', is('小飼弾'.toBase64(), '5bCP6aO85by+'));
20
+ it('.toBase64', is('小飼弾'.toBase64(true), '5bCP6aO85by-'));
21
+ it('.toBase64URI', is('小飼弾'.toBase64URI(), '5bCP6aO85by-'));
22
+ it('.fromBase64', is('5bCP6aO85by+'.fromBase64(), '小飼弾'));
23
+ it('.fromBase64', is('5bCP6aO85by-'.fromBase64(), '小飼弾'));
24
+ });
25
+ }
package/test/index.html CHANGED
@@ -13,7 +13,7 @@
13
13
  <script>
14
14
  mocha.setup('bdd');
15
15
  </script>
16
- <script src="../base64.js"></script>
16
+ <script src="../base64.min.js"></script>
17
17
  <script>
18
18
  var assert = function(expr, msg) {
19
19
  if (!expr) throw new Error(msg || 'failed');
package/test/large.js CHANGED
@@ -4,11 +4,8 @@
4
4
  * use mocha to test me
5
5
  * http://visionmedia.github.com/mocha/
6
6
  */
7
- var assert, Base64;
8
- if (this['window'] !== this) {
9
- assert = require("assert");
10
- Base64 = require('../base64.js').Base64;
11
- }
7
+ var assert = assert || require("assert");
8
+ var Base64 = Base64 || require('../base64.js').Base64;
12
9
  var is = function (a, e, m) {
13
10
  return function () {
14
11
  assert.equal(a, e, m)
package/test/yoshinoya.js CHANGED
@@ -2,11 +2,8 @@
2
2
  * use mocha to test me
3
3
  * http://visionmedia.github.com/mocha/
4
4
  */
5
- var assert, Base64;
6
- if (this['window'] !== this) {
7
- assert = require("assert");
8
- Base64 = require('../base64.js').Base64;
9
- }
5
+ var assert = assert || require("assert");
6
+ var Base64 = Base64 || require('../base64.js').Base64;
10
7
  var is = function (a, e, m) {
11
8
  return function () {
12
9
  assert.equal(a, e, m)
package/.npmignore DELETED
@@ -1,4 +0,0 @@
1
- *,v
2
- attic/**/*
3
- node_modules/**/*
4
- tmp/**/*
package/test/import.html DELETED
@@ -1,41 +0,0 @@
1
- <html>
2
- <head>
3
- <meta charset="utf-8">
4
- <title>Mocha Tests</title>
5
- <link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
6
- </head>
7
- <body>
8
- <div id="mocha"></div>
9
-
10
- <script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
11
- <script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
12
- <script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
13
- <script>
14
- mocha.setup('bdd');
15
- </script>
16
- <script type="module">
17
- import {Base64} from '../base64.js';
18
- </script>
19
- <script>
20
- var assert = function(expr, msg) {
21
- if (!expr) throw new Error(msg || 'failed');
22
- };
23
- assert.equal = function(a, b, msg) {
24
- if (a !== b) throw new Error(msg || ('failed : '+a+','+b));
25
- };
26
- </script>
27
- <script src="./dankogai.js"></script>
28
- <script src="./es5.js"></script>
29
- <script src="./large.js"></script>
30
- <script src="./yoshinoya.js"></script>
31
- <script>
32
- $(function() {
33
- mocha.run();
34
- });
35
- </script>
36
- </head>
37
- <body>
38
- $Id: index.html,v 0.3 2017/09/11 08:43:43 dankogai Exp dankogai $
39
- <div id="mocha"></div>
40
- </body>
41
- </html>