base64-no-upper-case 1.0.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/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ Base64, but no UPPER CASE.
2
+
3
+ ```
4
+ !#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/
5
+ ```
6
+
7
+ ## Setup
8
+
9
+ ### npm
10
+
11
+ ```
12
+ npm i base64-no-upper-case
13
+ ```
14
+
15
+ ```js
16
+ import Base64NoUpperCase from "base64-no-upper-case"
17
+
18
+ // Encode string
19
+ var enc = Base64NoUpperCase.encode("Hello world!")
20
+ console.log(enc)
21
+
22
+ // Decode to string
23
+ var dec = Base64NoUpperCase.decodeToString("])`sb)8gd29yb)@h")
24
+ console.log(dec)
25
+
26
+ // Encode Uint8Array
27
+ var enc = Base64NoUpperCase.encode(new Uint8Array(16))
28
+ console.log(enc)
29
+
30
+ // Decode to Uint8Array
31
+ var dec = Base64NoUpperCase.decode("^2rn8;ffl7<z*}{.|m@|{w==")
32
+ console.log(dec)
33
+ ```
34
+
35
+ ### Browser
36
+
37
+ ```html browser
38
+ <script>
39
+ {const e="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",r=function(r){"string"==typeof r&&(r=(new TextEncoder).encode(r));for(var n=r.length,t=Array(4*Math.ceil(n/3)),o=0,a=0;o<r.length;)t[a++]=e[r[o]>>2],t[a++]=e[r[o++]<<4&63|r[o]>>4],t[a++]=o>=n?"=":e[r[o++]<<2&63|r[o]>>6],t[a++]=o>=n?"=":e[63&r[o++]];return t.join("")},n=function(r){for(var n,t,o=r.length,a=new Uint8Array(Math.floor(o/4*3)-("="==r[o-1]&&1+("="==r[o-2]))),c=0,d=0,i=()=>{if("="==(n=r[c++]))return t=0;if((t=e.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return t};c<o;)a[d++]=i()<<2|i()>>4,a[d++]=t<<4|i()>>2,a[d++]=t<<6|i();return a},t=function(e,r=new TextDecoder){return r.decode(n(e))};self.Base64NoUpperCase={charMap:e,encode:r,decode:n,decodeToString:t}}
40
+ </script>
41
+ ```
@@ -0,0 +1,41 @@
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 < input.length) {
7
+ // 00000000 11111111 22222222
8
+ // __000000 __001111 __111122 __222222
9
+ out[oi++] = charMap[input[ii] >> 2];
10
+ out[oi++] = charMap[input[ii++] << 4 & 63 | input[ii] >> 4];
11
+ out[oi++] = ii >= il ? '=' : charMap[input[ii++] << 2 & 63 | input[ii] >> 6];
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 ((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
+ }
@@ -0,0 +1 @@
1
+ {const e="!#$%&()*,-.:;<>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyz0123456789+/",r=function(r){"string"==typeof r&&(r=(new TextEncoder).encode(r));for(var n=r.length,t=Array(4*Math.ceil(n/3)),o=0,a=0;o<r.length;)t[a++]=e[r[o]>>2],t[a++]=e[r[o++]<<4&63|r[o]>>4],t[a++]=o>=n?"=":e[r[o++]<<2&63|r[o]>>6],t[a++]=o>=n?"=":e[63&r[o++]];return t.join("")},n=function(r){for(var n,t,o=r.length,a=new Uint8Array(Math.floor(o/4*3)-("="==r[o-1]&&1+("="==r[o-2]))),c=0,d=0,i=()=>{if("="==(n=r[c++]))return t=0;if((t=e.indexOf(n))<0)throw Error("InvalidCharacterError: '"+n+"' at "+(c-1));return t};c<o;)a[d++]=i()<<2|i()>>4,a[d++]=t<<4|i()>>2,a[d++]=t<<6|i();return a},t=function(e,r=new TextDecoder){return r.decode(n(e))};self.Base64NoUpperCase={charMap:e,encode:r,decode:n,decodeToString:t}}
package/dist/main.d.ts ADDED
@@ -0,0 +1,12 @@
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;
package/dist/main.js ADDED
@@ -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 < input.length) {
7
+ // 00000000 11111111 22222222
8
+ // __000000 __001111 __111122 __222222
9
+ out[oi++] = charMap[input[ii] >> 2];
10
+ out[oi++] = charMap[input[ii++] << 4 & 63 | input[ii] >> 4];
11
+ out[oi++] = ii >= il ? '=' : charMap[input[ii++] << 2 & 63 | input[ii] >> 6];
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 ((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 ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "base64-no-upper-case",
3
+ "version": "1.0.0",
4
+ "description": "Base64, but no UPPER CASE.",
5
+ "main": "./dist/main.js",
6
+ "browser": "./dist/browser.js",
7
+ "type": "module",
8
+ "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"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/bddjr/base64-no-upper-case-js.git"
19
+ },
20
+ "keywords": [
21
+ "base64",
22
+ "scratch",
23
+ "upper",
24
+ "lower",
25
+ "case",
26
+ "uppercase",
27
+ "lowercase",
28
+ "encode",
29
+ "decode"
30
+ ],
31
+ "author": "bddjr",
32
+ "license": "Unlicense",
33
+ "bugs": {
34
+ "url": "https://github.com/bddjr/base64-no-upper-case-js/issues"
35
+ },
36
+ "homepage": "https://github.com/bddjr/base64-no-upper-case-js#readme",
37
+ "devDependencies": {
38
+ "@types/node": "^25.0.3",
39
+ "es-check": "^9.5.3",
40
+ "rimraf": "^6.1.2",
41
+ "terser": "^5.44.1",
42
+ "typescript": "^5.9.3"
43
+ }
44
+ }