@cobol-ts/base64 0.0.3 → 0.0.5
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/dist/index.js.map +1 -0
- package/dist/src/base64.d.ts +2 -0
- package/dist/src/base64.js +17 -0
- package/dist/src/base64.js.map +1 -0
- package/dist/src/base64.spec.d.ts +1 -0
- package/dist/src/base64.spec.js +21 -0
- package/dist/src/base64.spec.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBase64 = toBase64;
|
|
4
|
+
exports.fromBase64 = fromBase64;
|
|
5
|
+
function toBase64(value) {
|
|
6
|
+
const bytes = new TextEncoder().encode(value);
|
|
7
|
+
let binary = '';
|
|
8
|
+
for (const byte of bytes)
|
|
9
|
+
binary += String.fromCharCode(byte);
|
|
10
|
+
return btoa(binary);
|
|
11
|
+
}
|
|
12
|
+
function fromBase64(value) {
|
|
13
|
+
const binary = atob(value);
|
|
14
|
+
const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
|
|
15
|
+
return new TextDecoder().decode(bytes);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/base64.ts"],"names":[],"mappings":";;AAAA,4BAKC;AAED,gCAIC;AAXD,SAAgB,QAAQ,CAAC,KAAa;IAClC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC7C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC;AAED,SAAgB,UAAU,CAAC,KAAa;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base64_1 = require("./base64");
|
|
4
|
+
describe('base64', () => {
|
|
5
|
+
it('round trips a simple string', () => {
|
|
6
|
+
expect((0, base64_1.fromBase64)((0, base64_1.toBase64)('Hello, world!'))).toBe('Hello, world!');
|
|
7
|
+
});
|
|
8
|
+
it('round trips an empty string', () => {
|
|
9
|
+
expect((0, base64_1.fromBase64)((0, base64_1.toBase64)(''))).toBe('');
|
|
10
|
+
});
|
|
11
|
+
it('round trips unicode', () => {
|
|
12
|
+
expect((0, base64_1.fromBase64)((0, base64_1.toBase64)('Hello £世界'))).toBe('Hello £世界');
|
|
13
|
+
});
|
|
14
|
+
it('encodes a known value', () => {
|
|
15
|
+
expect((0, base64_1.toBase64)('hello')).toBe('aGVsbG8=');
|
|
16
|
+
});
|
|
17
|
+
it('decodes a known value', () => {
|
|
18
|
+
expect((0, base64_1.fromBase64)('aGVsbG8=')).toBe('hello');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=base64.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.spec.js","sourceRoot":"","sources":["../../src/base64.spec.ts"],"names":[],"mappings":";;AAAA,qCAA8C;AAE9C,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,IAAA,mBAAU,EAAC,IAAA,iBAAQ,EAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,IAAA,mBAAU,EAAC,IAAA,iBAAQ,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,IAAA,mBAAU,EAAC,IAAA,iBAAQ,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,IAAA,iBAAQ,EAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,IAAA,mBAAU,EAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/base64",
|
|
3
3
|
"description": "utilities about base64 encoding",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"dist/index.js",
|
|
46
46
|
"dist/index.d.ts",
|
|
47
47
|
"dist/src/",
|
|
48
|
-
"build/"
|
|
48
|
+
"build/",
|
|
49
|
+
"dist/**/*"
|
|
49
50
|
],
|
|
50
51
|
"keywords": [
|
|
51
52
|
"indexing"
|