base64-no-upper-case 1.0.1 → 1.0.2

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 CHANGED
@@ -44,6 +44,6 @@ console.log(dec)
44
44
 
45
45
  ```html browser
46
46
  <script>
47
- {const r="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",e=function(e){"string"==typeof e&&(e=(new TextEncoder).encode(e));for(var n=e.length,o=Array(4*Math.ceil(n/3)),t=0,a=0;t<n;)o[a++]=r[e[t]>>2&63],o[a++]=r[63&(e[t++]<<4|e[t]>>4)],o[a++]=t>=n?"=":r[63&(e[t++]<<2|e[t]>>6)],o[a++]=t>=n?"=":r[63&e[t++]];return o.join("")},n=function(e){for(var n,o,t=e.length,a=new Uint8Array(Math.floor(t/4*3)-("="==e[t-1]&&1+("="==e[t-2]))),c=0,d=0,i=()=>{if(c>=t||"="==(n=e[c++]))return o=0;if((o=r.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return o};c<t;)a[d++]=i()<<2|i()>>4,a[d++]=o<<4|i()>>2,a[d++]=o<<6|i();return a},o=function(r,e=new TextDecoder){return e.decode(n(r))};self.Base64NoUpperCase={charMap:r,encode:e,decode:n,decodeToString:o}}
47
+ {const r="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",e=function(e){"string"==typeof e&&(e=(new TextEncoder).encode(e));for(var n=e.length,t=Array(4*Math.ceil(n/3)),o=0,a=0;o<n;)t[a++]=r[e[o]>>2&63],t[a++]=r[63&(e[o++]<<4|e[o]>>4)],t[a++]=o>=n?"=":r[63&(e[o++]<<2|e[o]>>6)],t[a++]=o>=n?"=":r[63&e[o++]];return t.join("")},n=function(e){for(var n,t,o=e.length,a=new Uint8Array(Math.floor(o/4*3)-("="==e[o-1]&&1+("="==e[o-2]))),c=0,i=0,d=()=>{if(c>=o||"="==(n=e[c++]))return t=0;if((t=r.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return t};c<o;)a[i++]=d()<<2|d()>>4,a[i++]=t<<4|d()>>2,a[i++]=t<<6|d();return a},t=function(r,e=new TextDecoder){return e.decode(n(r))};this.Base64NoUpperCase={charMap:r,encode:e,decode:n,decodeToString:t}}
48
48
  </script>
49
49
  ```
@@ -1 +1 @@
1
- {const r="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",e=function(e){"string"==typeof e&&(e=(new TextEncoder).encode(e));for(var n=e.length,o=Array(4*Math.ceil(n/3)),t=0,a=0;t<n;)o[a++]=r[e[t]>>2&63],o[a++]=r[63&(e[t++]<<4|e[t]>>4)],o[a++]=t>=n?"=":r[63&(e[t++]<<2|e[t]>>6)],o[a++]=t>=n?"=":r[63&e[t++]];return o.join("")},n=function(e){for(var n,o,t=e.length,a=new Uint8Array(Math.floor(t/4*3)-("="==e[t-1]&&1+("="==e[t-2]))),c=0,d=0,i=()=>{if(c>=t||"="==(n=e[c++]))return o=0;if((o=r.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return o};c<t;)a[d++]=i()<<2|i()>>4,a[d++]=o<<4|i()>>2,a[d++]=o<<6|i();return a},o=function(r,e=new TextDecoder){return e.decode(n(r))};self.Base64NoUpperCase={charMap:r,encode:e,decode:n,decodeToString:o}}
1
+ {const r="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",e=function(e){"string"==typeof e&&(e=(new TextEncoder).encode(e));for(var n=e.length,t=Array(4*Math.ceil(n/3)),o=0,a=0;o<n;)t[a++]=r[e[o]>>2&63],t[a++]=r[63&(e[o++]<<4|e[o]>>4)],t[a++]=o>=n?"=":r[63&(e[o++]<<2|e[o]>>6)],t[a++]=o>=n?"=":r[63&e[o++]];return t.join("")},n=function(e){for(var n,t,o=e.length,a=new Uint8Array(Math.floor(o/4*3)-("="==e[o-1]&&1+("="==e[o-2]))),c=0,i=0,d=()=>{if(c>=o||"="==(n=e[c++]))return t=0;if((t=r.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return t};c<o;)a[i++]=d()<<2|d()>>4,a[i++]=t<<4|d()>>2,a[i++]=t<<6|d();return a},t=function(r,e=new TextDecoder){return e.decode(n(r))};this.Base64NoUpperCase={charMap:r,encode:e,decode:n,decodeToString:t}}
package/dist/main.d.ts CHANGED
@@ -1,12 +1,2 @@
1
- type Uint8ArrayLike = ArrayLike<number>;
2
- export declare const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/";
3
- export declare function encode(input: Uint8ArrayLike | string): string;
4
- export declare function decode(input: string): Uint8Array;
5
- export declare function decodeToString(input: string, textDecoder?: TextDecoder): string;
6
- declare const Base64NoUpperCase: {
7
- charMap: string;
8
- encode: typeof encode;
9
- decode: typeof decode;
10
- decodeToString: typeof decodeToString;
11
- };
12
- export default Base64NoUpperCase;
1
+ import Base64NoUpperCase from './module.d.mts';
2
+ export = Base64NoUpperCase;
package/dist/main.js CHANGED
@@ -1,5 +1,4 @@
1
- export const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/";
2
- export function encode(input) {
1
+ const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/", encode = function (input) {
3
2
  if (typeof input == 'string')
4
3
  input = new TextEncoder().encode(input);
5
4
  var il = input.length, out = Array(Math.ceil(il / 3) * 4), ii = 0, oi = 0;
@@ -12,8 +11,7 @@ export function encode(input) {
12
11
  out[oi++] = ii >= il ? '=' : charMap[input[ii++] & 63];
13
12
  }
14
13
  return out.join('');
15
- }
16
- export function decode(input) {
14
+ }, decode = function (input) {
17
15
  var il = input.length, out = new Uint8Array(Math.floor(il / 4 * 3) - ((input[il - 1] == '=') &&
18
16
  (1 + (input[il - 2] == '=')))), ii = 0, oi = 0, char, cache, next = () => {
19
17
  if (ii >= il || (char = input[ii++]) == '=')
@@ -30,14 +28,12 @@ export function decode(input) {
30
28
  out[oi++] = cache << 6 | next();
31
29
  }
32
30
  return out;
33
- }
34
- export function decodeToString(input, textDecoder = new TextDecoder()) {
31
+ }, decodeToString = function (input, textDecoder = new TextDecoder()) {
35
32
  return textDecoder.decode(decode(input));
36
- }
37
- const Base64NoUpperCase = {
33
+ };
34
+ module.exports = {
38
35
  charMap,
39
36
  encode,
40
37
  decode,
41
38
  decodeToString
42
39
  };
43
- export default Base64NoUpperCase;
@@ -0,0 +1,11 @@
1
+ export declare const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/";
2
+ export declare function encode(input: Uint8Array | string): string;
3
+ export declare function decode(input: string): Uint8Array;
4
+ export declare function decodeToString(input: string, textDecoder?: TextDecoder): string;
5
+ declare const Base64NoUpperCase: {
6
+ charMap: string;
7
+ encode: typeof encode;
8
+ decode: typeof decode;
9
+ decodeToString: typeof decodeToString;
10
+ };
11
+ export default Base64NoUpperCase;
@@ -0,0 +1,43 @@
1
+ export const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/";
2
+ export function encode(input) {
3
+ if (typeof input == 'string')
4
+ input = new TextEncoder().encode(input);
5
+ var il = input.length, out = Array(Math.ceil(il / 3) * 4), ii = 0, oi = 0;
6
+ while (ii < il) {
7
+ // 00000000 11111111 22222222
8
+ // __000000 __001111 __111122 __222222
9
+ out[oi++] = charMap[input[ii] >> 2 & 63];
10
+ out[oi++] = charMap[(input[ii++] << 4 | input[ii] >> 4) & 63];
11
+ out[oi++] = ii >= il ? '=' : charMap[(input[ii++] << 2 | input[ii] >> 6) & 63];
12
+ out[oi++] = ii >= il ? '=' : charMap[input[ii++] & 63];
13
+ }
14
+ return out.join('');
15
+ }
16
+ export function decode(input) {
17
+ var il = input.length, out = new Uint8Array(Math.floor(il / 4 * 3) - ((input[il - 1] == '=') &&
18
+ (1 + (input[il - 2] == '=')))), ii = 0, oi = 0, char, cache, next = () => {
19
+ if (ii >= il || (char = input[ii++]) == '=')
20
+ return cache = 0;
21
+ if ((cache = charMap.indexOf(char)) < 0)
22
+ throw Error("InvalidCharacterError: '" + char + "' at " + (ii - 1));
23
+ return cache;
24
+ };
25
+ while (ii < il) {
26
+ // __000000 __111111 __222222 __333333
27
+ // 00000011 11112222 22333333
28
+ out[oi++] = next() << 2 | next() >> 4;
29
+ out[oi++] = cache << 4 | next() >> 2;
30
+ out[oi++] = cache << 6 | next();
31
+ }
32
+ return out;
33
+ }
34
+ export function decodeToString(input, textDecoder = new TextDecoder()) {
35
+ return textDecoder.decode(decode(input));
36
+ }
37
+ const Base64NoUpperCase = {
38
+ charMap,
39
+ encode,
40
+ decode,
41
+ decodeToString
42
+ };
43
+ export default Base64NoUpperCase;
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "base64-no-upper-case",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Base64, but no UPPER CASE.",
5
+ "type": "commonjs",
5
6
  "main": "./dist/main.js",
6
- "browser": "./dist/browser.js",
7
- "type": "module",
7
+ "browser": "./dist/browser.min.js",
8
+ "module": "./dist/module.js",
8
9
  "scripts": {
9
- "build": "rimraf dist && tsc && node scripts/build-for-browser.js && es-check es2015 --module dist/**/*.js --not dist/browser.* && es-check es2015 dist/browser.*",
10
- "test": "npm run build && node scripts/test.js",
11
- "prepublishOnly": "npm test"
10
+ "build": "rimraf dist && tsc && node scripts/minify.mjs && es-check es6 --checkFeatures dist/**/*.js && es-check es6 --module --checkFeatures dist/**/*.mjs",
11
+ "test": "node --run build && node scripts/test.mjs",
12
+ "prepublishOnly": "node --run test"
12
13
  },
13
14
  "files": [
14
15
  "dist"
package/dist/browser.js DELETED
@@ -1,41 +0,0 @@
1
- {
2
- const charMap = "!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/", encode = function (input) {
3
- if (typeof input == 'string')
4
- input = new TextEncoder().encode(input);
5
- var il = input.length, out = Array(Math.ceil(il / 3) * 4), ii = 0, oi = 0;
6
- while (ii < il) {
7
- // 00000000 11111111 22222222
8
- // __000000 __001111 __111122 __222222
9
- out[oi++] = charMap[input[ii] >> 2 & 63];
10
- out[oi++] = charMap[(input[ii++] << 4 | input[ii] >> 4) & 63];
11
- out[oi++] = ii >= il ? '=' : charMap[(input[ii++] << 2 | input[ii] >> 6) & 63];
12
- out[oi++] = ii >= il ? '=' : charMap[input[ii++] & 63];
13
- }
14
- return out.join('');
15
- }, decode = function (input) {
16
- var il = input.length, out = new Uint8Array(Math.floor(il / 4 * 3) - ((input[il - 1] == '=') &&
17
- (1 + (input[il - 2] == '=')))), ii = 0, oi = 0, char, cache, next = () => {
18
- if (ii >= il || (char = input[ii++]) == '=')
19
- return cache = 0;
20
- if ((cache = charMap.indexOf(char)) < 0)
21
- throw Error("InvalidCharacterError: '" + char + "' at " + (ii - 1));
22
- return cache;
23
- };
24
- while (ii < il) {
25
- // __000000 __111111 __222222 __333333
26
- // 00000011 11112222 22333333
27
- out[oi++] = next() << 2 | next() >> 4;
28
- out[oi++] = cache << 4 | next() >> 2;
29
- out[oi++] = cache << 6 | next();
30
- }
31
- return out;
32
- }, decodeToString = function (input, textDecoder = new TextDecoder()) {
33
- return textDecoder.decode(decode(input));
34
- };
35
- self.Base64NoUpperCase = {
36
- charMap,
37
- encode,
38
- decode,
39
- decodeToString
40
- };
41
- }