js-base64 2.6.0 → 2.6.4
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/README.md +31 -6
- package/base64.js +39 -15
- package/base64.min.js +1 -0
- package/package.json +12 -5
- package/.attic/test-moment/dankogai.js +0 -44
- package/.attic/test-moment/es5.js +0 -24
- package/.attic/test-moment/es6.js +0 -25
- package/.attic/test-moment/index.html +0 -40
- package/.attic/test-moment/large.js +0 -25
- package/.attic/test-moment/moment.js +0 -4535
- package/.attic/test-moment/yoshinoya.js +0 -19
- package/1x1.png +0 -0
- package/base64.html +0 -47
- package/bower.json +0 -18
- package/package.js +0 -9
- package/test/atob.js +0 -46
- package/test/dankogai.js +0 -44
- package/test/es5.js +0 -24
- package/test/es6.js +0 -25
- package/test/index.html +0 -40
- package/test/large.js +0 -25
- package/test/yoshinoya.js +0 -19
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Yet another Base64 transcoder
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Install
|
|
8
10
|
|
|
9
11
|
```javascript
|
|
10
12
|
$ npm install --save js-base64
|
|
@@ -19,14 +21,26 @@ $ npm install --save babel-preset-env
|
|
|
19
21
|
Note `js-base64` itself is stand-alone so its `package.json` has no `dependencies`. However, it is also tested on ES6 environment so `"babel-preset-env": "^1.7.0"` is on `devDependencies`.
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
24
|
### In Browser
|
|
25
25
|
|
|
26
|
+
* Locally
|
|
27
|
+
|
|
26
28
|
```html
|
|
27
29
|
<script src="base64.js"></script>
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
* Directly from CDN. In which case you don't even need to install.
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<!-- the latest -->
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/js-base64/base64.min.js">
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<!-- with version fixed -->
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/js-base64@2.6.4/base64.min.js">
|
|
42
|
+
```
|
|
43
|
+
|
|
30
44
|
### node.js
|
|
31
45
|
|
|
32
46
|
```javascript
|
|
@@ -44,12 +58,23 @@ import { Base64 } from 'js-base64';
|
|
|
44
58
|
```javascript
|
|
45
59
|
Base64.encode('dankogai'); // ZGFua29nYWk=
|
|
46
60
|
Base64.btoa( 'dankogai'); // ZGFua29nYWk=
|
|
47
|
-
Base64.
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
Base64.fromUint8Array( // ZGFua29nYWk=
|
|
62
|
+
new Uint8Array([100,97,110,107,111,103,97,105])
|
|
63
|
+
);
|
|
64
|
+
Base64.fromUint8Array( // ZGFua29nYW which is URI safe
|
|
65
|
+
new Uint8Array([100,97,110,107,111,103,97,105]), true
|
|
66
|
+
);
|
|
67
|
+
Base64.encode( '小飼弾'); // 5bCP6aO85by+
|
|
68
|
+
Base64.encodeURI('小飼弾'); // 5bCP6aO85by- which equals to Base64.encode('小飼弾', true)
|
|
69
|
+
Base64.btoa( '小飼弾'); // raises exception
|
|
70
|
+
```
|
|
50
71
|
|
|
72
|
+
```javascript
|
|
51
73
|
Base64.decode('ZGFua29nYWk='); // dankogai
|
|
52
74
|
Base64.atob( 'ZGFua29nYWk='); // dankogai
|
|
75
|
+
Base64.toUint8Array( // new Uint8Array([100,97,110,107,111,103,97,105])
|
|
76
|
+
'ZGFua29nYWk='
|
|
77
|
+
);
|
|
53
78
|
Base64.decode('5bCP6aO85by+'); // 小飼弾
|
|
54
79
|
// note .decodeURI() is unnecessary since it accepts both flavors
|
|
55
80
|
Base64.decode('5bCP6aO85by-'); // 小飼弾
|
package/base64.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// existing version for noConflict()
|
|
23
23
|
global = global || {};
|
|
24
24
|
var _Base64 = global.Base64;
|
|
25
|
-
var version = "2.6.
|
|
25
|
+
var version = "2.6.4";
|
|
26
26
|
// constants
|
|
27
27
|
var b64chars
|
|
28
28
|
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -77,18 +77,33 @@
|
|
|
77
77
|
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
|
78
78
|
};
|
|
79
79
|
var _encode = function(u) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
return btoa(utob(String(u)));
|
|
81
|
+
};
|
|
82
|
+
var mkUriSafe = function (b64) {
|
|
83
|
+
return b64.replace(/[+\/]/g, function(m0) {
|
|
84
|
+
return m0 == '+' ? '-' : '_';
|
|
85
|
+
}).replace(/=/g, '');
|
|
86
|
+
};
|
|
84
87
|
var encode = function(u, urisafe) {
|
|
85
|
-
return
|
|
86
|
-
? _encode(u)
|
|
87
|
-
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
|
|
88
|
-
return m0 == '+' ? '-' : '_';
|
|
89
|
-
}).replace(/=/g, '');
|
|
88
|
+
return urisafe ? mkUriSafe(_encode(u)) : _encode(u);
|
|
90
89
|
};
|
|
91
90
|
var encodeURI = function(u) { return encode(u, true) };
|
|
91
|
+
var fromUint8Array;
|
|
92
|
+
if (global.Uint8Array) fromUint8Array = function(a, urisafe) {
|
|
93
|
+
// return btoa(fromCharCode.apply(null, a));
|
|
94
|
+
var b64 = '';
|
|
95
|
+
for (var i = 0, l = a.length; i < l; i += 3) {
|
|
96
|
+
var a0 = a[i], a1 = a[i+1], a2 = a[i+2];
|
|
97
|
+
var ord = a0 << 16 | a1 << 8 | a2;
|
|
98
|
+
b64 += b64chars.charAt( ord >>> 18)
|
|
99
|
+
+ b64chars.charAt((ord >>> 12) & 63)
|
|
100
|
+
+ ( typeof a1 != 'undefined'
|
|
101
|
+
? b64chars.charAt((ord >>> 6) & 63) : '=')
|
|
102
|
+
+ ( typeof a2 != 'undefined'
|
|
103
|
+
? b64chars.charAt( ord & 63) : '=');
|
|
104
|
+
}
|
|
105
|
+
return urisafe ? mkUriSafe(b64) : b64;
|
|
106
|
+
};
|
|
92
107
|
// decoder stuff
|
|
93
108
|
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
94
109
|
var cb_btou = function(cccc) {
|
|
@@ -140,11 +155,19 @@
|
|
|
140
155
|
return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
|
|
141
156
|
};
|
|
142
157
|
var _decode = function(a) { return btou(_atob(a)) };
|
|
158
|
+
var _fromURI = function(a) {
|
|
159
|
+
return String(a).replace(/[-_]/g, function(m0) {
|
|
160
|
+
return m0 == '-' ? '+' : '/'
|
|
161
|
+
}).replace(/[^A-Za-z0-9\+\/]/g, '');
|
|
162
|
+
};
|
|
143
163
|
var decode = function(a){
|
|
144
|
-
return _decode(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
return _decode(_fromURI(a));
|
|
165
|
+
};
|
|
166
|
+
var toUint8Array;
|
|
167
|
+
if (global.Uint8Array) toUint8Array = function(a) {
|
|
168
|
+
return Uint8Array.from(atob(_fromURI(a)), function(c) {
|
|
169
|
+
return c.charCodeAt(0);
|
|
170
|
+
});
|
|
148
171
|
};
|
|
149
172
|
var noConflict = function() {
|
|
150
173
|
var Base64 = global.Base64;
|
|
@@ -164,6 +187,8 @@
|
|
|
164
187
|
btou: btou,
|
|
165
188
|
decode: decode,
|
|
166
189
|
noConflict: noConflict,
|
|
190
|
+
fromUint8Array: fromUint8Array,
|
|
191
|
+
toUint8Array: toUint8Array
|
|
167
192
|
};
|
|
168
193
|
// if ES5 is available, make Base64.extendString() available
|
|
169
194
|
if (typeof Object.defineProperty === 'function') {
|
|
@@ -203,4 +228,3 @@
|
|
|
203
228
|
// that's it!
|
|
204
229
|
return {Base64: global.Base64}
|
|
205
230
|
}));
|
|
206
|
-
|
package/base64.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(global):typeof define==="function"&&define.amd?define(factory):factory(global)})(typeof self!=="undefined"?self:typeof window!=="undefined"?window:typeof global!=="undefined"?global:this,function(global){"use strict";global=global||{};var _Base64=global.Base64;var version="2.6.4";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&&typeof global.btoa=="function"?function(b){return global.btoa(b)}:function(b){if(b.match(/[^\x00-\xFF]/))throw new RangeError("The string contains invalid characters.");return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=function(u){return btoa(utob(String(u)))};var mkUriSafe=function(b64){return b64.replace(/[+\/]/g,function(m0){return m0=="+"?"-":"_"}).replace(/=/g,"")};var encode=function(u,urisafe){return urisafe?mkUriSafe(_encode(u)):_encode(u)};var encodeURI=function(u){return encode(u,true)};var fromUint8Array;if(global.Uint8Array)fromUint8Array=function(a,urisafe){var b64="";for(var i=0,l=a.length;i<l;i+=3){var a0=a[i],a1=a[i+1],a2=a[i+2];var ord=a0<<16|a1<<8|a2;b64+=b64chars.charAt(ord>>>18)+b64chars.charAt(ord>>>12&63)+(typeof a1!="undefined"?b64chars.charAt(ord>>>6&63):"=")+(typeof a2!="undefined"?b64chars.charAt(ord&63):"=")}return urisafe?mkUriSafe(b64):b64};var re_btou=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/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&&typeof global.atob=="function"?function(a){return global.atob(a)}:function(a){return a.replace(/\S{1,4}/g,cb_decode)};var atob=function(a){return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g,""))};var _decode=function(a){return btou(_atob(a))};var _fromURI=function(a){return String(a).replace(/[-_]/g,function(m0){return m0=="-"?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,"")};var decode=function(a){return _decode(_fromURI(a))};var toUint8Array;if(global.Uint8Array)toUint8Array=function(a){return Uint8Array.from(atob(_fromURI(a)),function(c){return c.charCodeAt(0)})};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,fromUint8Array:fromUint8Array,toUint8Array:toUint8Array};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/package.json
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-base64",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
4
4
|
"description": "Yet another Base64 transcoder in pure-JS",
|
|
5
5
|
"main": "base64.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"base64.js",
|
|
8
|
+
"base64.min.js"
|
|
9
|
+
],
|
|
6
10
|
"directories": {
|
|
7
11
|
"test": "test"
|
|
8
12
|
},
|
|
9
13
|
"scripts": {
|
|
10
|
-
"test": "mocha --
|
|
14
|
+
"test": "mocha --require @babel/register",
|
|
15
|
+
"minify": "uglifyjs base64.js > base64.min.js"
|
|
11
16
|
},
|
|
12
17
|
"devDependencies": {
|
|
13
|
-
"babel
|
|
14
|
-
"babel-
|
|
15
|
-
"
|
|
18
|
+
"@babel/core": "^7.10.5",
|
|
19
|
+
"@babel/preset-env": "^7.10.5",
|
|
20
|
+
"@babel/register": "^7.10.5",
|
|
21
|
+
"mocha": "^8.0.0",
|
|
22
|
+
"uglify-js": "^3.10.0"
|
|
16
23
|
},
|
|
17
24
|
"repository": {
|
|
18
25
|
"type": "git",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* $Id: dankogai.js,v 0.4 2012/08/24 05:23:18 dankogai Exp dankogai $
|
|
3
|
-
*
|
|
4
|
-
* use mocha to test me
|
|
5
|
-
* http://visionmedia.github.com/mocha/
|
|
6
|
-
*/
|
|
7
|
-
var assert = assert || require("assert");
|
|
8
|
-
var Base64 = Base64 || require('../base64.js').Base64;
|
|
9
|
-
var is = function (a, e, m) {
|
|
10
|
-
return function () {
|
|
11
|
-
assert.equal(a, e, m)
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('basic', function () {
|
|
16
|
-
it('d', is(Base64.encode('d'), 'ZA=='));
|
|
17
|
-
it('da', is(Base64.encode('da'), 'ZGE='));
|
|
18
|
-
it('dan', is(Base64.encode('dan'), 'ZGFu'));
|
|
19
|
-
it('ZA==', is(Base64.decode('ZA=='), 'd' ));
|
|
20
|
-
it('ZGE=', is(Base64.decode('ZGE='), 'da' ));
|
|
21
|
-
it('ZGFu', is(Base64.decode('ZGFu'), 'dan' ));
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('whitespace', function () {
|
|
25
|
-
it('Z A==', is(Base64.decode('ZA =='), 'd' ));
|
|
26
|
-
it('ZG E=', is(Base64.decode('ZG E='), 'da' ));
|
|
27
|
-
it('ZGF u', is(Base64.decode('ZGF u'), 'dan' ));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('null', function () {
|
|
31
|
-
it('\\0', is(Base64.encode('\0'), 'AA=='));
|
|
32
|
-
it('\\0\\0', is(Base64.encode('\0\0'), 'AAA='));
|
|
33
|
-
it('\\0\\0\\0', is(Base64.encode('\0\0\0'), 'AAAA'));
|
|
34
|
-
it('AA==', is(Base64.decode('AA=='), '\0' ));
|
|
35
|
-
it('AAA=', is(Base64.decode('AAA='), '\0\0' ));
|
|
36
|
-
it('AAAA', is(Base64.decode('AAAA'), '\0\0\0'));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Base64', function () {
|
|
40
|
-
it('.encode', is(Base64.encode('小飼弾'), '5bCP6aO85by+'));
|
|
41
|
-
it('.encodeURI', is(Base64.encodeURI('小飼弾'), '5bCP6aO85by-'));
|
|
42
|
-
it('.decode', is(Base64.decode('5bCP6aO85by+'), '小飼弾'));
|
|
43
|
-
it('.decode', is(Base64.decode('5bCP6aO85by-'), '小飼弾'));
|
|
44
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* $Id: es5.js,v 0.1 2012/08/23 19:43:17 dankogai Exp dankogai $
|
|
3
|
-
*
|
|
4
|
-
* use mocha to test me
|
|
5
|
-
* http://visionmedia.github.com/mocha/
|
|
6
|
-
*/
|
|
7
|
-
var assert = assert || require("assert");
|
|
8
|
-
var Base64 = Base64 || require('../base64.js').Base64;
|
|
9
|
-
var is = function (a, e, m) {
|
|
10
|
-
return function () {
|
|
11
|
-
assert.equal(a, e, m)
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
if ('extendString' in Base64){
|
|
16
|
-
Base64.extendString();
|
|
17
|
-
describe('String', function () {
|
|
18
|
-
it('.toBase64', is('小飼弾'.toBase64(), '5bCP6aO85by+'));
|
|
19
|
-
it('.toBase64', is('小飼弾'.toBase64(true), '5bCP6aO85by-'));
|
|
20
|
-
it('.toBase64URI', is('小飼弾'.toBase64URI(), '5bCP6aO85by-'));
|
|
21
|
-
it('.fromBase64', is('5bCP6aO85by+'.fromBase64(), '小飼弾'));
|
|
22
|
-
it('.fromBase64', is('5bCP6aO85by-'.fromBase64(), '小飼弾'));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,40 +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 src="./moment.js"></script>
|
|
17
|
-
<script src="../base64.js"></script>
|
|
18
|
-
<script>
|
|
19
|
-
var assert = function(expr, msg) {
|
|
20
|
-
if (!expr) throw new Error(msg || 'failed');
|
|
21
|
-
};
|
|
22
|
-
assert.equal = function(a, b, msg) {
|
|
23
|
-
if (a !== b) throw new Error(msg || ('failed : '+a+','+b));
|
|
24
|
-
};
|
|
25
|
-
</script>
|
|
26
|
-
<script src="./dankogai.js"></script>
|
|
27
|
-
<script src="./es5.js"></script>
|
|
28
|
-
<script src="./large.js"></script>
|
|
29
|
-
<script src="./yoshinoya.js"></script>
|
|
30
|
-
<script>
|
|
31
|
-
$(function() {
|
|
32
|
-
mocha.run();
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
</head>
|
|
36
|
-
<body>
|
|
37
|
-
$Id: index.html,v 0.3 2017/09/11 08:43:43 dankogai Exp dankogai $
|
|
38
|
-
<div id="mocha"></div>
|
|
39
|
-
</body>
|
|
40
|
-
</html>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* $Id: large.js,v 0.3 2012/08/23 19:14:37 dankogai Exp dankogai $
|
|
3
|
-
*
|
|
4
|
-
* use mocha to test me
|
|
5
|
-
* http://visionmedia.github.com/mocha/
|
|
6
|
-
*/
|
|
7
|
-
var assert = assert || require("assert");
|
|
8
|
-
var Base64 = Base64 || require('../base64.js').Base64;
|
|
9
|
-
var is = function (a, e, m) {
|
|
10
|
-
return function () {
|
|
11
|
-
assert.equal(a, e, m)
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var seed = function () {
|
|
15
|
-
var a, i;
|
|
16
|
-
for (a = [], i = 0; i < 256; i++) {
|
|
17
|
-
a.push(String.fromCharCode(i));
|
|
18
|
-
}
|
|
19
|
-
return a.join('');
|
|
20
|
-
}();
|
|
21
|
-
describe('Base64', function () {
|
|
22
|
-
for (var i = 0, str = seed; i < 16; str += str, i++) {
|
|
23
|
-
it(''+str.length, is(Base64.decode(Base64.encode(str)), str));
|
|
24
|
-
}
|
|
25
|
-
});
|