diff --git a/cjs/base-ex.cjs b/cjs/base-ex.cjs index 07b1d4b..ce3776c 100644 --- a/cjs/base-ex.cjs +++ b/cjs/base-ex.cjs @@ -1453,7 +1453,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1609,7 +1609,7 @@ class Base1 extends BaseTemplate { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1689,7 +1689,7 @@ class Base16 extends BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1794,7 +1794,7 @@ class Base32 extends BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1944,7 +1944,7 @@ class Base58 extends BaseTemplate{ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2032,7 +2032,7 @@ class Base64 extends BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2236,7 +2236,7 @@ const ees = () => { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2359,7 +2359,7 @@ class Base85 extends BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2590,7 +2590,7 @@ class Base91 extends BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2755,7 +2755,7 @@ class LEB128 extends BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3097,7 +3097,7 @@ class Ecoji extends BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3275,7 +3275,7 @@ class Base2048 extends BaseTemplate { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3375,7 +3375,7 @@ let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"I /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3704,7 +3704,7 @@ class BasePhi extends BaseTemplate { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3822,7 +3822,7 @@ class ByteConverter { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/dist/base-ex.esm.js b/dist/base-ex.esm.js index 7d1a4de..067fd3e 100644 --- a/dist/base-ex.esm.js +++ b/dist/base-ex.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1607,7 +1607,7 @@ class Base1 extends BaseTemplate { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1687,7 +1687,7 @@ class Base16 extends BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1792,7 +1792,7 @@ class Base32 extends BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1942,7 +1942,7 @@ class Base58 extends BaseTemplate{ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2030,7 +2030,7 @@ class Base64 extends BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2234,7 +2234,7 @@ const ees = () => { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2357,7 +2357,7 @@ class Base85 extends BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2588,7 +2588,7 @@ class Base91 extends BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2753,7 +2753,7 @@ class LEB128 extends BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3095,7 +3095,7 @@ class Ecoji extends BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3273,7 +3273,7 @@ class Base2048 extends BaseTemplate { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3373,7 +3373,7 @@ let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"I /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3702,7 +3702,7 @@ class BasePhi extends BaseTemplate { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3820,7 +3820,7 @@ class ByteConverter { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/dist/base-ex.esm.min.js b/dist/base-ex.esm.min.js index af49046..3a63502 100644 --- a/dist/base-ex.esm.min.js +++ b/dist/base-ex.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */class U{constructor(t="buffer"){if(!n.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(n.typeList.join(", ")),new TypeError(e)}this.base1=new u("default",t),this.base16=new d("default",t),this.base32_crockford=new f("rfc4648",t),this.base32_rfc3548=new f("rfc3548",t),this.base32_rfc4648=new f("rfc4648",t),this.base32_zbase32=new f("zbase32",t),this.base58=new p("default",t),this.base58_bitcoin=new p("bitcoin",t),this.base58_flickr=new p("flickr",t),this.base64=new g("default",t),this.base64_urlsafe=new g("urlsafe",t),this.uuencode=new b("default",t),this.xxencode=new b("xx",t),this.base85_adobe=new w("adobe",t),this.base85_ascii=new w("ascii85",t),this.base85_z85=new w("z85",t),this.base91=new v("default",t),this.leb128=new E("default",t),this.ecoji_v1=new A("emojis_v1",t),this.ecoji_v2=new A("emojis_v2",t),this.base2048=new x("default",t),this.basePhi=new _("default",t),this.byteConverter=new N(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new M(e,t)}}export{u as Base1,d as Base16,x as Base2048,f as Base32,p as Base58,g as Base64,w as Base85,v as Base91,U as BaseEx,_ as BasePhi,N as ByteConverter,A as Ecoji,E as LEB128,M as SimpleBase,b as UUencode}; diff --git a/dist/base-ex.iife.js b/dist/base-ex.iife.js index 0285d88..1f0c2f5 100644 --- a/dist/base-ex.iife.js +++ b/dist/base-ex.iife.js @@ -1454,7 +1454,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1610,7 +1610,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1690,7 +1690,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1795,7 +1795,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1945,7 +1945,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2033,7 +2033,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2237,7 +2237,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2360,7 +2360,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -2591,7 +2591,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -2756,7 +2756,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji @@ -3098,7 +3098,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3276,7 +3276,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3376,7 +3376,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3705,7 +3705,7 @@ var BaseEx = (function (exports) { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -3823,7 +3823,7 @@ var BaseEx = (function (exports) { /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/dist/base-ex.iife.min.js b/dist/base-ex.iife.min.js index 190b1ed..08b2208 100644 --- a/dist/base-ex.iife.min.js +++ b/dist/base-ex.iife.min.js @@ -2,7 +2,7 @@ var BaseEx=function(t){"use strict";class e{static toBytes(t){return ArrayBuffer /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */return t.Base1=d,t.Base16=f,t.Base2048=M,t.Base32=p,t.Base58=g,t.Base64=b,t.Base85=w,t.Base91=E,t.BaseEx=class{constructor(t="buffer"){if(!o.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(o.typeList.join(", ")),new TypeError(e)}this.base1=new d("default",t),this.base16=new f("default",t),this.base32_crockford=new p("rfc4648",t),this.base32_rfc3548=new p("rfc3548",t),this.base32_rfc4648=new p("rfc4648",t),this.base32_zbase32=new p("zbase32",t),this.base58=new g("default",t),this.base58_bitcoin=new g("bitcoin",t),this.base58_flickr=new g("flickr",t),this.base64=new b("default",t),this.base64_urlsafe=new b("urlsafe",t),this.uuencode=new y("default",t),this.xxencode=new y("xx",t),this.base85_adobe=new w("adobe",t),this.base85_ascii=new w("ascii85",t),this.base85_z85=new w("z85",t),this.base91=new E("default",t),this.leb128=new A("default",t),this.ecoji_v1=new x("emojis_v1",t),this.ecoji_v2=new x("emojis_v2",t),this.base2048=new M("default",t),this.basePhi=new U("default",t),this.byteConverter=new P(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new T(e,t)}},t.BasePhi=U,t.ByteConverter=P,t.Ecoji=x,t.LEB128=A,t.SimpleBase=T,t.UUencode=y,t}({}); diff --git a/dist/converters/Base1/base-1.esm.js b/dist/converters/Base1/base-1.esm.js index 11e83a0..ab10515 100644 --- a/dist/converters/Base1/base-1.esm.js +++ b/dist/converters/Base1/base-1.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base1/base-1.esm.min.js b/dist/converters/Base1/base-1.esm.min.js index 27043c8..89e4751 100644 --- a/dist/converters/Base1/base-1.esm.min.js +++ b/dist/converters/Base1/base-1.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends h{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let n,r;[n,r]=this.utils.inputHandler.toBytes(t,i);let s=this.converter.encode(n,null,i.littleEndian)[0],o=BigInt(s);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],l=a.length;let h="";if(1===l)h=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(h=a.at(1).repeat((o-t)/5)),h+=a.at(0).repeat(t)}else for(let t=0;t?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let n,r;[n,r]=this.utils.inputHandler.toBytes(t,i);let s=this.converter.encode(n,null,i.littleEndian)[0],o=BigInt(s);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],l=a.length;let h="";if(1===l)h=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(h=a.at(1).repeat((o-t)/5)),h+=a.at(0).repeat(t)}else for(let t=0;t((t=t.replace(/^0x/,"")).length%2&&(t="0".concat(t)),t)),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base16/base-16.iife.js b/dist/converters/Base16/base-16.iife.js index fcb0a4c..08001d5 100644 --- a/dist/converters/Base16/base-16.iife.js +++ b/dist/converters/Base16/base-16.iife.js @@ -1454,7 +1454,7 @@ var Base16 = (function () { /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base16/base-16.iife.min.js b/dist/converters/Base16/base-16.iife.min.js index f8e6080..77ef27d 100644 --- a/dist/converters/Base16/base-16.iife.min.js +++ b/dist/converters/Base16/base-16.iife.min.js @@ -2,7 +2,7 @@ var Base16=function(){"use strict";class t{static toBytes(t){return ArrayBuffer. /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{constructor(...t){super(),this.converter=new l(16,1,2),this.charsets.default=[..."0123456789abcdef"],this.padChars.default=[],this.hasSignedMode=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>((t=t.replace(/^0x/,"")).length%2&&(t="0".concat(t)),t)),null,!1,...e)}}}(); diff --git a/dist/converters/Base2048/base-2048.esm.js b/dist/converters/Base2048/base-2048.esm.js index 684da5a..f8ee8bd 100644 --- a/dist/converters/Base2048/base-2048.esm.js +++ b/dist/converters/Base2048/base-2048.esm.js @@ -1101,7 +1101,7 @@ class BaseTemplate { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base2048/base-2048.esm.min.js b/dist/converters/Base2048/base-2048.esm.min.js index 7e00656..388ebb4 100644 --- a/dist/converters/Base2048/base-2048.esm.min.js +++ b/dist/converters/Base2048/base-2048.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class h extends l{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e);let i=this.utils.inputHandler.toBytes(t,r).at(0);const n=this.charsets[r.version],s=this.padChars[r.version];let o="",a=0,l=0;if(i.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),l++,l===this.converter.bsEnc&&(o+=n.at(a),a=0,l=0)})),0!==l){let t,e;for(l<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);l!==t;)if(a=1+(a<<1),l++,l>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?s.at(a):n.at(a)}return this.utils.wrapOutput(o,r.options.lineWrap)}decode(t,...e){const r=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const i=[...t],n=this.charsets[r.version],s=this.padChars[r.version],a=new Array;let l=0,h=0;return i.forEach(((t,e)=>{let u,c=n.indexOf(t);if(c>-1)u=this.converter.bsEnc;else if(c=s.indexOf(t),c>-1){if(e+1!==i.length)throw new o(null,`Secondary character found before end of input, index: ${e}`);u=this.converter.bsEncPad}else if(r.integrity)throw new o(t);for(let t=u-1;t>=0;t--)l=(l<<1)+(c>>t&1),h++,h===this.converter.bsDec&&(a.push(l),l=0,h=0)})),this.utils.outputHandler.compile(Uint8Array.from(a),r.outputType)}}export{h as default}; diff --git a/dist/converters/Base2048/base-2048.iife.js b/dist/converters/Base2048/base-2048.iife.js index 72f069d..91b5c67 100644 --- a/dist/converters/Base2048/base-2048.iife.js +++ b/dist/converters/Base2048/base-2048.iife.js @@ -1104,7 +1104,7 @@ var Base2048 = (function () { /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base2048/base-2048.iife.min.js b/dist/converters/Base2048/base-2048.iife.min.js index 33a5ef2..a455da3 100644 --- a/dist/converters/Base2048/base-2048.iife.min.js +++ b/dist/converters/Base2048/base-2048.iife.min.js @@ -2,7 +2,7 @@ var Base2048=function(){"use strict";class t{static toBytes(t){return ArrayBuffe /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const r=this.utils.validateArgs(e);let i=this.utils.inputHandler.toBytes(t,r).at(0);const n=this.charsets[r.version],s=this.padChars[r.version];let o="",a=0,h=0;if(i.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=n.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?s.at(a):n.at(a)}return this.utils.wrapOutput(o,r.options.lineWrap)}decode(t,...e){const r=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const i=[...t],n=this.charsets[r.version],s=this.padChars[r.version],a=new Array;let h=0,l=0;return i.forEach(((t,e)=>{let u,c=n.indexOf(t);if(c>-1)u=this.converter.bsEnc;else if(c=s.indexOf(t),c>-1){if(e+1!==i.length)throw new o(null,`Secondary character found before end of input, index: ${e}`);u=this.converter.bsEncPad}else if(r.integrity)throw new o(t);for(let t=u-1;t>=0;t--)h=(h<<1)+(c>>t&1),l++,l===this.converter.bsDec&&(a.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(a),r.outputType)}}}(); diff --git a/dist/converters/Base32/base-32.esm.js b/dist/converters/Base32/base-32.esm.js index 81c995b..dd66de4 100644 --- a/dist/converters/Base32/base-32.esm.js +++ b/dist/converters/Base32/base-32.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base32/base-32.esm.min.js b/dist/converters/Base32/base-32.esm.min.js index 2bdb47f..48d378a 100644 --- a/dist/converters/Base32/base-32.esm.min.js +++ b/dist/converters/Base32/base-32.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:r})=>{if(!e.littleEndian&&r){const i=this.converter.padBytes(r),n=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(n.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base32/base-32.iife.js b/dist/converters/Base32/base-32.iife.js index ebce163..7cbad1b 100644 --- a/dist/converters/Base32/base-32.iife.js +++ b/dist/converters/Base32/base-32.iife.js @@ -1454,7 +1454,7 @@ var Base32 = (function () { /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base32/base-32.iife.min.js b/dist/converters/Base32/base-32.iife.min.js index 7d766bb..2dcbc04 100644 --- a/dist/converters/Base32/base-32.iife.min.js +++ b/dist/converters/Base32/base-32.iife.min.js @@ -2,7 +2,7 @@ var Base32=function(){"use strict";class t{static toBytes(t){return ArrayBuffer. /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends l{constructor(...t){super(),this.converter=new h(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:r})=>{if(!e.littleEndian&&r){const i=this.converter.padBytes(r),n=this.padChars[e.version].at(0);t=t.slice(0,-i),e.padding&&(t=t.concat(n.repeat(i)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base58/base-58.esm.js b/dist/converters/Base58/base-58.esm.js index c226ba3..aefbd51 100644 --- a/dist/converters/Base58/base-58.esm.js +++ b/dist/converters/Base58/base-58.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base58/base-58.esm.min.js b/dist/converters/Base58/base-58.esm.min.js index 5c17938..44897a7 100644 --- a/dist/converters/Base58/base-58.esm.min.js +++ b/dist/converters/Base58/base-58.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends l{constructor(...t){super(),this.converter=new h(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:n})=>{if(i.padding&&"int"!==n){let n=0;const r=t.length,s=this.charsets[i.version].at(0);if(r){for(;!t[n];)if(n++,n===r){n=0;break}const i=n;i&&(e=s.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const n=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===n;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}export{u as default}; diff --git a/dist/converters/Base58/base-58.iife.js b/dist/converters/Base58/base-58.iife.js index 3d4f07e..885bf3c 100644 --- a/dist/converters/Base58/base-58.iife.js +++ b/dist/converters/Base58/base-58.iife.js @@ -1454,7 +1454,7 @@ var Base58 = (function () { /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base58/base-58.iife.min.js b/dist/converters/Base58/base-58.iife.min.js index dd320ce..155074e 100644 --- a/dist/converters/Base58/base-58.iife.min.js +++ b/dist/converters/Base58/base-58.iife.min.js @@ -2,7 +2,7 @@ var Base58=function(){"use strict";class t{static toBytes(t){return ArrayBuffer. /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends l{constructor(...t){super(),this.converter=new h(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:n})=>{if(i.padding&&"int"!==n){let n=0;const r=t.length,s=this.charsets[i.version].at(0);if(r){for(;!t[n];)if(n++,n===r){n=0;break}const i=n;i&&(e=s.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const n=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===n;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}}(); diff --git a/dist/converters/Base64/base-64.esm.js b/dist/converters/Base64/base-64.esm.js index b58e4c5..a5cb557 100644 --- a/dist/converters/Base64/base-64.esm.js +++ b/dist/converters/Base64/base-64.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base64/base-64.esm.min.js b/dist/converters/Base64/base-64.esm.min.js index ab00b25..614ef77 100644 --- a/dist/converters/Base64/base-64.esm.min.js +++ b/dist/converters/Base64/base-64.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base64/base-64.iife.js b/dist/converters/Base64/base-64.iife.js index b2c3a44..664fab6 100644 --- a/dist/converters/Base64/base-64.iife.js +++ b/dist/converters/Base64/base-64.iife.js @@ -1454,7 +1454,7 @@ var Base64 = (function () { /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base64/base-64.iife.min.js b/dist/converters/Base64/base-64.iife.min.js index a676f2a..3f680cd 100644 --- a/dist/converters/Base64/base-64.iife.min.js +++ b/dist/converters/Base64/base-64.iife.min.js @@ -2,7 +2,7 @@ var Base64=function(){"use strict";class t{static toBytes(t){return ArrayBuffer. /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{if(n){const r=this.converter.padBytes(n),i=this.padChars[e.version].at(0);t=t.slice(0,-r),e.padding&&(t=t.concat(i.repeat(r)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}}(); diff --git a/dist/converters/Base85/base-85.esm.js b/dist/converters/Base85/base-85.esm.js index 837293d..d257585 100644 --- a/dist/converters/Base85/base-85.esm.js +++ b/dist/converters/Base85/base-85.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base85/base-85.esm.min.js b/dist/converters/Base85/base-85.esm.min.js index 32fce36..04e7067 100644 --- a/dist/converters/Base85/base-85.esm.min.js +++ b/dist/converters/Base85/base-85.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends h{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:n})=>{if(n){const e=this.converter.padBytes(n);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/Base85/base-85.iife.js b/dist/converters/Base85/base-85.iife.js index 70b382f..d8cc9a1 100644 --- a/dist/converters/Base85/base-85.iife.js +++ b/dist/converters/Base85/base-85.iife.js @@ -1454,7 +1454,7 @@ var Base85 = (function () { /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Base85/base-85.iife.min.js b/dist/converters/Base85/base-85.iife.min.js index f6a4160..3362772 100644 --- a/dist/converters/Base85/base-85.iife.min.js +++ b/dist/converters/Base85/base-85.iife.min.js @@ -2,7 +2,7 @@ var Base85=function(){"use strict";class t{static toBytes(t){return ArrayBuffer. /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:n})=>{if(n){const e=this.converter.padBytes(n);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}}(); diff --git a/dist/converters/Base91/base-91.esm.js b/dist/converters/Base91/base-91.esm.js index f3c44db..c77fde4 100644 --- a/dist/converters/Base91/base-91.esm.js +++ b/dist/converters/Base91/base-91.esm.js @@ -1101,7 +1101,7 @@ class BaseTemplate { /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/dist/converters/Base91/base-91.esm.min.js b/dist/converters/Base91/base-91.esm.min.js index 72a8d35..d65a1e1 100644 --- a/dist/converters/Base91/base-91.esm.min.js +++ b/dist/converters/Base91/base-91.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */class h extends l{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0),this.isMutable.integrity=!1}encode(t,...e){const i=this.utils.validateArgs(e),n=this.utils.inputHandler.toBytes(t,i)[0];let r=0,s=0,o="";const a=this.charsets[i.version];if(n.forEach((t=>{if(s+=t<13){let t,e,i=13,n=s%8192;n<89&&(i=14,n=s%16384),s>>=i,r-=i,[t,e]=this.#n(n,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#n(s,91),o=o.concat(a[e]),(r>7||s>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const n=[...t];let r=n.length,s=!1;r%2&&(s=!0,r--);let a=0,l=0;const h=this.charsets[i.version],u=new Array;for(let t=0;t88?13:14;do{u.push(a%256),a>>=8,l-=8}while(l>7)}if(s){const t=n.at(r),e=h.indexOf(t);u.push(((e<?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0),this.isMutable.integrity=!1}encode(t,...e){const i=this.utils.validateArgs(e),n=this.utils.inputHandler.toBytes(t,i)[0];let r=0,s=0,o="";const a=this.charsets[i.version];if(n.forEach((t=>{if(s+=t<13){let t,e,i=13,n=s%8192;n<89&&(i=14,n=s%16384),s>>=i,r-=i,[t,e]=this.#n(n,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#n(s,91),o=o.concat(a[e]),(r>7||s>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const n=[...t];let r=n.length,s=!1;r%2&&(s=!0,r--);let a=0,l=0;const u=this.charsets[i.version],h=new Array;for(let t=0;t88?13:14;do{h.push(a%256),a>>=8,l-=8}while(l>7)}if(s){const t=n.at(r),e=u.indexOf(t);h.push(((e<{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");r--}r>-1?l.unshift(r):h.push(r),o=o.minus(t),d(t,e,r)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=i[0],f--;a+=i[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n;[t,n]=this.utils.extractSign(this.utils.normalizeInput(t));const[s,a]=t.split(".");let l=y(0),h=this.#i.minus(1),u=y(1);if([...s].reverse().forEach((t=>{const e=i.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new o(t);[h,u]=this.#n(h,u)})),a){let t=y(1);u=this.#i.minus(t),[...a].forEach((e=>{const r=i.indexOf(e);if(1===r)l=l.plus(u);else if(0!==r)throw new o(e);[u,t]=this.#o(u,t)}))}if(r.decimalMode)return l.toNumber();l=l.round().toFixed();const c=this.b10.decode(l,[..."0123456789"],[],r.integrity,r.littleEndian);return this.utils.outputHandler.compile(c,r.outputType,r.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}export{w as default}; diff --git a/dist/converters/BasePhi/base-phi.iife.js b/dist/converters/BasePhi/base-phi.iife.js index 1d47f26..e1cd63c 100644 --- a/dist/converters/BasePhi/base-phi.iife.js +++ b/dist/converters/BasePhi/base-phi.iife.js @@ -1459,7 +1459,7 @@ var BasePhi = (function () { /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/BasePhi/base-phi.iife.min.js b/dist/converters/BasePhi/base-phi.iife.min.js index 14bbd5d..a79b2ff 100644 --- a/dist/converters/BasePhi/base-phi.iife.min.js +++ b/dist/converters/BasePhi/base-phi.iife.min.js @@ -2,7 +2,7 @@ var BasePhi=function(){"use strict";class t{static toBytes(t){return ArrayBuffer /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{#i=b("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0),this.isMutable.integrity=!1}encode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n,s,o,a="";if(r.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(s=!0,o=b(-t)):(s=!1,o=b(t))}else[n,s]=this.utils.inputHandler.toBytes(t,r),o=b(this.b10.encode(n,null,r.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=i[o.toNumber()],s&&(a=`-${a}`),a;const l=[],h=[];let u=b(1),c=this.#i,f=0;for(;c.lt(o);)[u,c]=this.#n(u,c),f++;const d=(t,e,r)=>{if(!this.#s(o)){for(;t.gt(o);){if([t,e]=this.#o(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");r--}r>-1?l.unshift(r):h.push(r),o=o.minus(t),d(t,e,r)}};return d(u,c,f),f=0,l.forEach((t=>{for(;f{for(;f>t;)a+=i[0],f--;a+=i[1],f--})),s&&(a=`-${a}`),a}decode(t,...e){const r=this.utils.validateArgs(e),i=this.charsets[r.version];let n;[t,n]=this.utils.extractSign(this.utils.normalizeInput(t));const[s,a]=t.split(".");let l=b(0),h=this.#i.minus(1),u=b(1);if([...s].reverse().forEach((t=>{const e=i.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new o(t);[h,u]=this.#n(h,u)})),a){let t=b(1);u=this.#i.minus(t),[...a].forEach((e=>{const r=i.indexOf(e);if(1===r)l=l.plus(u);else if(0!==r)throw new o(e);[u,t]=this.#o(u,t)}))}if(r.decimalMode)return l.toNumber();l=l.round().toFixed();const c=this.b10.decode(l,[..."0123456789"],[],r.integrity,r.littleEndian);return this.utils.outputHandler.compile(c,r.outputType,r.littleEndian,n)}#s(t){return!t.round(50).abs().toNumber()}#n(t,e){return[e,t.plus(e)]}#o(t,e){return[e.minus(t),t]}}}(); diff --git a/dist/converters/ByteConverter/byte-converter.esm.js b/dist/converters/ByteConverter/byte-converter.esm.js index c186435..9474bd2 100644 --- a/dist/converters/ByteConverter/byte-converter.esm.js +++ b/dist/converters/ByteConverter/byte-converter.esm.js @@ -460,7 +460,7 @@ class SmartOutput { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/ByteConverter/byte-converter.esm.min.js b/dist/converters/ByteConverter/byte-converter.esm.min.js index 2dc4681..dd9ea2c 100644 --- a/dist/converters/ByteConverter/byte-converter.esm.min.js +++ b/dist/converters/ByteConverter/byte-converter.esm.min.js @@ -2,7 +2,7 @@ class t{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e) /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */const n=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class i{constructor(...t){this.littleEndian=n,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,n=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=e.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!e.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),n)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(e,...n){const i=this.utils.validateArgs(n);return t.toBytes(e,i)[0]}decode(t,...n){const i=this.utils.validateArgs(n);return e.compile(t,i.outputType,i.littleEndian)}}export{i as default}; diff --git a/dist/converters/ByteConverter/byte-converter.iife.js b/dist/converters/ByteConverter/byte-converter.iife.js index 288c0db..884e371 100644 --- a/dist/converters/ByteConverter/byte-converter.iife.js +++ b/dist/converters/ByteConverter/byte-converter.iife.js @@ -463,7 +463,7 @@ var ByteConverter = (function () { /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/ByteConverter/byte-converter.iife.min.js b/dist/converters/ByteConverter/byte-converter.iife.min.js index 24666d4..838a215 100644 --- a/dist/converters/ByteConverter/byte-converter.iife.min.js +++ b/dist/converters/ByteConverter/byte-converter.iife.min.js @@ -2,7 +2,7 @@ var ByteConverter=function(){"use strict";class t{static makeDataView(t){const e /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */const n=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();return class{constructor(...t){this.littleEndian=n,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,n=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=e.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!e.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),n)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(e,...n){const i=this.utils.validateArgs(n);return t.toBytes(e,i)[0]}decode(t,...n){const i=this.utils.validateArgs(n);return e.compile(t,i.outputType,i.littleEndian)}}}(); diff --git a/dist/converters/Dev/dev.esm.js b/dist/converters/Dev/dev.esm.js deleted file mode 100644 index 8b13789..0000000 --- a/dist/converters/Dev/dev.esm.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dist/converters/Dev/dev.esm.min.js b/dist/converters/Dev/dev.esm.min.js deleted file mode 100644 index 8b13789..0000000 --- a/dist/converters/Dev/dev.esm.min.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dist/converters/Dev/dev.iife.js b/dist/converters/Dev/dev.iife.js deleted file mode 100644 index 31dfeb9..0000000 --- a/dist/converters/Dev/dev.iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - - -})(); diff --git a/dist/converters/Dev/dev.iife.min.js b/dist/converters/Dev/dev.iife.min.js deleted file mode 100644 index 8b13789..0000000 --- a/dist/converters/Dev/dev.iife.min.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dist/converters/Ecoji/ecoji.esm.js b/dist/converters/Ecoji/ecoji.esm.js index a0a4b8b..9134c25 100644 --- a/dist/converters/Ecoji/ecoji.esm.js +++ b/dist/converters/Ecoji/ecoji.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.esm.min.js b/dist/converters/Ecoji/ecoji.esm.min.js index 6d033be..8516a9a 100644 --- a/dist/converters/Ecoji/ecoji.esm.min.js +++ b/dist/converters/Ecoji/ecoji.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.iife.js b/dist/converters/Ecoji/ecoji.iife.js index ea57c51..88d30c0 100644 --- a/dist/converters/Ecoji/ecoji.iife.js +++ b/dist/converters/Ecoji/ecoji.iife.js @@ -1454,7 +1454,7 @@ var Ecoji = (function () { /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Ecoji/ecoji.iife.min.js b/dist/converters/Ecoji/ecoji.iife.min.js index 714022f..c64d431 100644 --- a/dist/converters/Ecoji/ecoji.iife.min.js +++ b/dist/converters/Ecoji/ecoji.iife.min.js @@ -2,7 +2,7 @@ var Ecoji=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.i /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/dist/converters/Leb128/leb-128.esm.js b/dist/converters/Leb128/leb-128.esm.js index b814fe5..f1319b6 100644 --- a/dist/converters/Leb128/leb-128.esm.js +++ b/dist/converters/Leb128/leb-128.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Leb128/leb-128.esm.min.js b/dist/converters/Leb128/leb-128.esm.min.js index 6fa96ac..9eda8be 100644 --- a/dist/converters/Leb128/leb-128.esm.min.js +++ b/dist/converters/Leb128/leb-128.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends h{constructor(...t){super(),this.converter=new l(10,0,0),this.hexlify=new l(16,1,2),this.charsets.default="",this.charsets.hex="",this.version="default",this.frozenCharsets=!0,this.littleEndian=!0,this.hasSignedMode=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const n=this.utils.validateArgs(e),i=n.signed;n.signed=!0;const[r,s]=this.utils.inputHandler.toBytes(t,n);let o=this.converter.encode(r,null,n.littleEndian)[0],a=BigInt(o),l=new Array;if(s){if(!i)throw new TypeError("Negative values in unsigned mode are invalid.");a=-a}if(i)for(;;){const t=Number(127n&a);if(a>>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===n.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...n){const i=this.utils.validateArgs(n);if("hex"===i.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],i.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),i.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===n.version?this.hexlify.encode(h,[..."0123456789abcdef"],!1)[0]:h}decode(e,...n){const i=this.utils.validateArgs(n);if("hex"===i.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],i.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),i.outputType,!0);e=Array.from(e);let r,s,o,a=0n,l=-7n;for(r of e)l+=7n,a+=BigInt(127&r)<62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}export{u as default}; diff --git a/dist/converters/SimpleBase/simple-base.iife.js b/dist/converters/SimpleBase/simple-base.iife.js index bf1baea..ab20293 100644 --- a/dist/converters/SimpleBase/simple-base.iife.js +++ b/dist/converters/SimpleBase/simple-base.iife.js @@ -1454,7 +1454,7 @@ var SimpleBase = (function () { /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/SimpleBase/simple-base.iife.min.js b/dist/converters/SimpleBase/simple-base.iife.min.js index 15a59f2..04ae50e 100644 --- a/dist/converters/SimpleBase/simple-base.iife.min.js +++ b/dist/converters/SimpleBase/simple-base.iife.min.js @@ -2,7 +2,7 @@ var SimpleBase=function(){"use strict";class t{static toBytes(t){return ArrayBuf /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */return class extends h{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}}(); diff --git a/dist/converters/Utf8/utf8.esm.js b/dist/converters/Utf8/utf8.esm.js deleted file mode 100644 index 9707ded..0000000 --- a/dist/converters/Utf8/utf8.esm.js +++ /dev/null @@ -1,1527 +0,0 @@ -/** - * Simple Input Handler. - * -------------------- - * Accepts only bytes eg. TypedArray, ArrayBuffer, - * DataView, also a regular array (filled with integers) - * is possible. - */ -class BytesInput { - static toBytes(input) { - if (ArrayBuffer.isView(input)) { - input = input.buffer; - } - return [new Uint8Array(input), false, "bytes"]; - } -} - -/** - * Simple Output Handler. - * --------------------- - * Returns bytes in the form of: - * - ArrayBuffer - * - Uint8Array - * - DataView - */ -class BytesOutput { - - static get typeList() { - return [ - "buffer", - "bytes", - "uint8", - "view" - ]; - } - - static getType(type) { - if (!BytesOutput.typeList.includes(type)) { - throw new TypeError(`Unknown output type: '${type}'`); - } - return type; - } - - static compile(Uint8ArrayOut, type) { - type = BytesOutput.getType(type); - let compiled; - - if (type === "buffer") { - compiled = Uint8ArrayOut.buffer; - } - - else if (type === "view") { - compiled = new DataView(Uint8ArrayOut.buffer); - } - - else { - compiled = Uint8ArrayOut; - } - - return compiled; - } -} - - -/** - * Advanced Input Handler. - * ---------------------- - * Accepts almost every Input and converts it - * into an Uint8Array (bytes). - */ -class SmartInput { - - static makeDataView(byteLen) { - const buffer = new ArrayBuffer(byteLen); - return new DataView(buffer); - } - - static floatingPoints(input, littleEndian=false) { - const view = this.makeDataView(8); - view.setFloat64(0, input, littleEndian); - return view; - } - - static numbers(input, littleEndian=false) { - - let view; - let type; - - // Integer - if (Number.isInteger(input)) { - - type = "int"; - - if (!Number.isSafeInteger(input)) { - - let safeInt; - let smallerOrBigger; - let minMax; - - if (input < 0) { - safeInt = Number.MIN_SAFE_INTEGER; - smallerOrBigger = "smaller"; - minMax = "MIN"; - } else { - safeInt = Number.MAX_SAFE_INTEGER; - smallerOrBigger = "bigger"; - minMax = "MAX"; - } - - throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`); - } - - // Signed Integer - if (input < 0) { - - // 64 bit - if (input < -2147483648) { - view = this.makeDataView(8); - view.setBigInt64(0, BigInt(input), littleEndian); - } - - // 32 littleEndian - else if (input < -32768) { - view = this.makeDataView(4); - view.setInt32(0, input, littleEndian); - } - - // 16 littleEndian - else { - view = this.makeDataView(2); - view.setInt16(0, input, littleEndian); - } - } - - // Unsigned Integer - else if (input > 0) { - - // 64 bit - if (input > 4294967295) { - view = this.makeDataView(8); - view.setBigUint64(0, BigInt(input), littleEndian); - } - - // 32 bit - else if (input > 65535) { - view = this.makeDataView(4); - view.setUint32(0, input, littleEndian); - } - - // 16 bit - else { - view = this.makeDataView(2); - view.setInt16(0, input, littleEndian); - } - } - - // Zero - else { - view = new Uint16Array([0]); - } - } - - // Floating Point Number: - else { - type = "float"; - view = this.floatingPoints(input, littleEndian); - } - - return [new Uint8Array(view.buffer), type]; - - } - - - static bigInts(input, littleEndian=false) { - // Since BigInts are not limited to 64 bits, they might - // overflow the BigInt64Array values. A little more - // handwork is therefore needed. - - // as the integer size is not known yet, the bytes get a - // makeshift home "byteArray", which is a regular array - - const byteArray = new Array(); - const append = (littleEndian) ? "push" : "unshift"; - const maxN = 18446744073709551616n; - - // split the input into 64 bit integers - if (input < 0) { - while (input < -9223372036854775808n) { - byteArray[append](input % maxN); - input >>= 64n; - } - } else { - while (input >= maxN) { - byteArray[append](input % maxN); - input >>= 64n; - } - } - - // append the remaining byte - byteArray[append](input); - - // determine the required size for the typed array - // by taking the amount of 64 bit integers * 8 - // (8 bytes for each 64 bit integer) - const byteLen = byteArray.length * 8; - - // create a fresh data view - const view = this.makeDataView(byteLen); - - // set all 64 bit integers - byteArray.forEach((bigInt, i) => { - const offset = i * 8; - view.setBigUint64(offset, bigInt, littleEndian); - }); - - return new Uint8Array(view.buffer); - } - - - static toBytes(input, settings) { - - let inputUint8; - let negative = false; - let type = "bytes"; - - // Buffer: - if (input instanceof ArrayBuffer) { - inputUint8 = new Uint8Array(input.slice()); - } - - // TypedArray or DataView: - else if (ArrayBuffer.isView(input)) { - inputUint8 = new Uint8Array(input.buffer.slice()); - } - - // String: - else if (typeof input === "string" || input instanceof String) { - inputUint8 = new TextEncoder().encode(input); - } - - // Number: - else if (typeof input === "number") { - if (isNaN(input)) { - throw new TypeError("Cannot proceed. Input is NaN."); - } else if (input == Infinity) { - throw new TypeError("Cannot proceed. Input is Infinity."); - } - - if (settings.signed && input < 0) { - negative = true; - input = -input; - } - - if (settings.numberMode) { - const view = this.floatingPoints(input, settings.littleEndian); - inputUint8 = new Uint8Array(view.buffer); - type = "float"; - } else { - [inputUint8, type] = this.numbers(input, settings.littleEndian); - } - } - - // BigInt: - else if (typeof input === "bigint") { - if (settings.signed && input < 0) { - negative = true; - input *= -1n; - } - inputUint8 = this.bigInts(input, settings.littleEndian); - type = "int"; - } - - // Array - else if (Array.isArray(input)) { - const collection = new Array(); - for (const elem of input) { - collection.push(...this.toBytes(elem, settings)[0]); - } - inputUint8 = Uint8Array.from(collection); - } - - else { - throw new TypeError("The provided input type can not be processed."); - } - - return [inputUint8, negative, type]; - } -} - -/** - * Advanced Output Handler. - * ----------------------- - * This Output handler makes it possible to - * convert an Uint8Array (bytes) into a desired - * format of a big variety. - * - * The default output is an ArrayBuffer. - */ -class SmartOutput { - - static get typeList() { - return [ - "bigint64", - "bigint_n", - "biguint64", - "buffer", - "bytes", - "float32", - "float64", - "float_n", - "int8", - "int16", - "int32", - "int_n", - "str", - "uint8", - "uint16", - "uint32", - "uint_n", - "view" - ]; - } - - static getType(type) { - if (!this.typeList.includes(type)) { - throw new TypeError(`Unknown output type: '${type}'`); - } - return type; - } - - static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) { - - const len = Uint8ArrayOut.byteLength; - const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem; - const newLen = len + delta; - - // if the array is negative and the len is gt 1 - // fill the whole array with 255 - const fillVal = (negative && len > 1) ? 255 : 0; - - let newArray = Uint8ArrayOut; - - if (delta) { - newArray = new Uint8Array(newLen); - newArray.fill(fillVal); - - const offset = (littleEndian) ? 0 : delta; - newArray.set(Uint8ArrayOut, offset); - } - - - return newArray.buffer; - } - - static makeTypedArray(inArray, type, littleEndian, negative) { - let outArray; - - if (type === "int16" || type === "uint16") { - - const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative); - outArray = (type === "int16") ? new Int16Array(buffer) : new Uint16Array(buffer); - - } else if (type === "int32" || type === "uint32" || type === "float32") { - - const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative); - - if (type === "int32") { - outArray = new Int32Array(buffer); - } else if (type === "uint32") { - outArray = new Uint32Array(buffer); - } else { - outArray = new Float32Array(buffer); - } - - } else if (type === "bigint64" || type === "biguint64" || type === "float64") { - - const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative); - - if (type === "bigint64") { - outArray = new BigInt64Array(buffer); - } else if (type === "biguint64") { - outArray = new BigUint64Array(buffer); - } else { - outArray = new Float64Array(buffer); - } - } - - return outArray; - } - - static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) { - type = this.getType(type); - let compiled; - - // If the array is negative (which is only - // true for signed encoding) get the positive - // decimal number first and feed it with a - // negative sign to SmartInput to construct - // the unsigned output which is not shortened. - - if (negative) { - let n; - if (type.match(/^float/)) { - n = -(this.compile(Uint8ArrayOut, "float_n", littleEndian)); - } else { - n = -(this.compile(Uint8ArrayOut, "uint_n", littleEndian)); - } - if (type === "float_n") { - return n; - } - Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0]; - } - - if (type === "buffer") { - compiled = Uint8ArrayOut.buffer; - } - - else if (type === "bytes" || type === "uint8") { - compiled = Uint8ArrayOut; - } - - else if (type === "int8") { - compiled = new Int8Array(Uint8ArrayOut.buffer); - } - - else if (type === "view") { - compiled = new DataView(Uint8ArrayOut.buffer); - } - - else if (type === "str") { - compiled = new TextDecoder().decode(Uint8ArrayOut); - } - - else if (type === "uint_n" || type === "int_n" || type === "bigint_n") { - - // If the input consists of only one byte, expand it - if (Uint8ArrayOut.length === 1) { - const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative); - Uint8ArrayOut = new Uint8Array(uint16Buffer); - } - - if (littleEndian) { - Uint8ArrayOut.reverse(); - } - - // calculate a unsigned big integer - let n = 0n; - Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b)); - - // convert to signed int if requested - if (type !== "uint_n") { - n = BigInt.asIntN(Uint8ArrayOut.length*8, n); - } - - // convert to regular number if possible (and no bigint was requested) - if (type !== "bigint_n" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { - compiled = Number(n); - } else { - compiled = n; - } - } - - else if (type === "float_n") { - - if (Uint8ArrayOut.length <= 4) { - - let array; - if (Uint8ArrayOut.length === 4) { - array = Uint8ArrayOut; - } else { - array = this.makeTypedArray(Uint8ArrayOut, "float32", false, negative); - } - - const view = new DataView(array.buffer); - compiled = view.getFloat32(0, littleEndian); - - } - - else if (Uint8ArrayOut.length <= 8) { - - let array; - if (Uint8ArrayOut.length === 8) { - array = Uint8ArrayOut; - } else { - array = this.makeTypedArray(Uint8ArrayOut, "float64", false, negative); - } - - const view = new DataView(array.buffer); - compiled = view.getFloat64(0, littleEndian); - - } - - else { - throw new RangeError("The provided input is to complex to be converted into a floating point.") - } - } - - else if (type === "number") { - if (Uint8ArrayOut.length !== 8) { - throw new TypeError("Type mismatch. Cannot convert into number."); - } - - const float64 = new Float64Array(Uint8ArrayOut.buffer); - compiled = Number(float64); - } - - else { - compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative); - } - - return compiled; - } -} - -const DEFAULT_INPUT_HANDLER = SmartInput; -const DEFAULT_OUTPUT_HANDLER = SmartOutput; - -class SignError extends TypeError { - constructor() { - super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); - this.name = "SignError"; - } -} - -class DecodingError extends TypeError { - constructor(char, msg=null) { - if (msg === null) { - msg = `Character '${char}' is not part of the charset.`; - } - super(msg); - this.name = "DecodingError"; - } -} - - -/** - * Utilities for every BaseEx class. - * -------------------------------- - * Requires IO Handlers - */ -class Utils { - - constructor(main) { - - // Store the calling class in this.root - // for accessability. - this.root = main; - - // set specific args object for converters - this.converterArgs = {}; - - // If charsets are uses by the parent class, - // add extra functions for the user. - - this.#charsetUserToolsConstructor(); - } - - setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) { - this.inputHandler = inputHandler; - this.outputHandler = outputHandler; - } - - - /** - * Constructor for the ability to add a charset and - * change the default version. - */ - #charsetUserToolsConstructor() { - - /** - * Save method to add a charset. - * @param {string} name - "Charset name." - * @param {[string|set|array]} - "Charset" - */ - this.root.addCharset = (name, _charset, _padChars=[], info=true) => { - - const normalize = (typeName, set, setLen) => { - - if (setLen === 0 && set.length) { - console.warn(`This converter has no ${typeName}. The following argument was ignored:\n'${set}'`); - return []; - } - - let inputLen = setLen; - - if (typeof set === "string") { - set = [...set]; - } - - if (Array.isArray(set)) { - - // Store the input length of the input - inputLen = set.length; - - // Convert to "Set" -> eliminate duplicates - // If duplicates are found the length of the - // Set and the length of the initial input - // differ. - - set = new Set(set); - - } else if (!(set instanceof Set)) { - throw new TypeError(`The ${typeName} must be one of the types:\n'str', 'set', 'array'."`); - } - - if (set.size === setLen) { - return [...set]; - } - - if (inputLen !== setLen) { - throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`); - } else { - const charAmounts = {}; - _charset = [..._charset]; - _charset.forEach(c => { - if (c in charAmounts) { - charAmounts[c]++; - } else { - charAmounts[c] = 1; - } - }); - - let infoStr = ""; - if (setLen < 100) { - infoStr = `${_charset.join("")}\n`; - _charset.forEach(c => { - if (charAmounts[c] > 1) { - infoStr += "^"; - } else { - infoStr += " "; - } - }); - } - const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1); - throw new Error(`You have repetitive char(s) [ ${rChars.join(" | ")} ] in your ${typeName}. Make sure each character is unique.\n${infoStr}`); - } - }; - - if (this.root.frozenCharsets) { - throw new Error("The charsets of this converter cannot be changed."); - } - - if (typeof name !== "string") { - throw new TypeError("The charset name must be a string."); - } - - if (info && name in this.root.charsets) { - console.warn(`An existing charset with name ${name} will get replaced.`); - } - - const charset = normalize("charset", _charset, this.root.converter.radix); - const padChars = normalize("padding set", _padChars, this.root.padCharAmount); - - this.root.charsets[name] = charset; - if (padChars.length) { - this.root.padChars[name] = padChars; - } - - if (info) { - console.info(`New charset '${name}' was added and is ready to use`); - } - }; - - // Save method (argument gets validated) to - // change the default version. - this.root.setDefaultCharset = (version) => { - if (!(version in this.root.charsets)) { - const sets = Object.keys(this.root.charsets).join("\n * "); - const msg = `Charset ${version} was not found. Available charsets are:\n * ${sets}`; - throw new TypeError(msg); - } - this.root.version = version; - }; - } - - /** - * Argument lists for error messages. - * @param {string[]} args - * @returns string - Arguments joined as a string. - */ - #makeArgList(args) { - return args.map(s => `'${s}'`).join(", "); - } - - /** - * Removes all padded zeros a the start of the string, - * adds a "-" if value is negative. - * @param {string} output - Former output. - * @param {boolean} negative - Indicates a negative value if true. - * @returns {string} - Output without zero padding and a sign if negative. - */ - toSignedStr(output, negative) { - - output = output.replace(/^0+(?!$)/, ""); - - if (negative) { - output = "-".concat(output); - } - - return output; - } - - /** - * Analyzes the input for a negative sign. - * If a sign is found, it gets removed but - * negative bool gets true; - * @param {string} input - Input number as a string. - * @returns {array} - Number without sign and negativity indication bool. - */ - extractSign(input) { - let negative = false; - if (input[0] === "-") { - negative = true; - input = input.slice(1); - } - - return [input, negative]; - } - - /** - * All possible error messages for invalid arguments, - * gets adjusted according to the converter settings. - * @param {string} arg - Argument. - * @param {string[]} versions - Charset array. - * @param {string[]} outputTypes - Array of output types. - * @param {boolean} initial - Indicates if the arguments where passed during construction. - */ - #invalidArgument(arg, versions, outputTypes, initial) { - const loopConverterArgs = () => Object.keys(this.converterArgs).map( - key => this.converterArgs[key].map( - keyword => `'${keyword}'` - ) - .join(" and ") - ) - .join("\n - "); - - throw new TypeError([ - `'${arg}'\n\nParameters:`, - initial ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : "", - this.root.isMutable.signed ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : "", - this.root.isMutable.littleEndian ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : "", - this.root.isMutable.padding ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : "", - this.root.isMutable.upper ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : "", - `\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`, - versions ? `\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : "", - "\n * valid args for integrity check are: 'integrity' and 'nointegrity'", - this.root.hasDecimalMode ? "\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)" : "", - "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)", - Object.keys(this.converterArgs).length ? `\n * converter specific args:\n - ${loopConverterArgs()}` : "", - "\n\nTraceback:" - ].join("")); - } - - - /** - * Test if provided arguments are in the argument list. - * Everything gets converted to lowercase and returned. - * @param {string[]} args - Passed arguments. - * @param {boolean} initial - Indicates if the arguments where passed during construction. - * @returns {Object} - Converter settings object. - */ - validateArgs(args, initial=false) { - - // default settings - const parameters = { - decimalMode: this.root.decimalMode, - integrity: this.root.integrity, - littleEndian: this.root.littleEndian, - numberMode: this.root.numberMode, - options: this.root.options, - outputType: this.root.outputType, - padding: this.root.padding, - signed: this.root.signed, - upper: this.root.upper, - version: this.root.version - }; - - // add any existing converter specific args - for (const param in this.converterArgs) { - parameters[param] = this.root[param]; - } - - // if no args are provided return the default settings immediately - if (!args.length) { - - // if initial call set default IO handlers - if (initial) { - this.setIOHandlers(); - } - - return parameters; - } - - // Helper function to test the presence of a - // particular arg. If found, true is returned - // and it gets removed from the array. - const extractArg = (arg) => { - if (args.includes(arg)) { - args.splice(args.indexOf(arg), 1); - return true; - } - return false; - }; - - // set available versions and extra arguments - const versions = Object.keys(this.root.charsets); - const extraArgList = { - integrity: ["nointegrity", "integrity"], - littleEndian: ["be", "le"], - padding: ["nopad", "pad"], - signed: ["unsigned", "signed"], - upper: ["lower", "upper"], - ...this.converterArgs - }; - - // if initial, look for IO specifications - if (initial) { - if (extractArg("bytes_only")) { - this.setIOHandlers(BytesInput, BytesOutput); - } else { - const inHandler = (extractArg("bytes_in")) ? BytesInput : DEFAULT_INPUT_HANDLER; - const outHandler = (extractArg("bytes_out")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER; - this.setIOHandlers(inHandler, outHandler); - } - } - - // set valid output types - const outputTypes = this.outputHandler.typeList; - - // test for special "number" keyword - if (extractArg("number")) { - parameters.numberMode = true; - parameters.outputType = "float_n"; - } - - // test for the special "decimal" keyword - if (extractArg("decimal")) { - if (!this.root.hasDecimalMode) { - throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`); - } - parameters.decimalMode = true; - parameters.outputType = "decimal"; - - if (parameters.numberMode) { - parameters.numberMode = false; - console.warn("-> number-mode was disabled due to the decimal-mode"); - } - } - - // walk through the remaining arguments - args.forEach((arg) => { - - // additional/optional non boolean options - if (typeof arg === "object") { - parameters.options = {...parameters.options, ...arg}; - return; - } - - arg = String(arg).toLowerCase(); - - if (versions.includes(arg)) { - parameters.version = arg; - } else if (outputTypes.includes(arg)) { - parameters.outputType = arg; - } else { - // set invalid args to true for starters - // if a valid arg is found later it will - // get changed - - let invalidArg = true; - - // walk through the mutable parameter list - - for (const param in extraArgList) { - - if (extraArgList[param].includes(arg)) { - - invalidArg = false; - - // extra params always have two options - // they are converted into booleans - // index 0 > false - // index 1 > true - - if (this.root.isMutable[param]) { - parameters[param] = Boolean(extraArgList[param].indexOf(arg)); - } else { - throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`); - } - } - } - - if (invalidArg) { - this.#invalidArgument(arg, versions, outputTypes, initial); - } - } - }); - - // If padding and signed are true, padding - // is set to false and a warning is getting - // displayed. - if (parameters.padding && parameters.signed) { - parameters.padding = false; - console.warn("-> padding was set to false due to the signed conversion"); - } - - // overwrite the default parameters for the initial call - if (initial) { - for (const param in parameters) { - this.root[param] = parameters[param]; - } - } - - return parameters; - } - - /** - * A TypeError specifically for sign errors. - */ - signError() { - throw new SignError(); - } - - /** - * Wrap output to "cols" characters per line. - * @param {string} output - Output string. - * @param {number} cols - Number of cols per line. - * @returns {string} - Wrapped output. - */ - wrapOutput(output, cols=0) { - if (!cols) { - return output; - } - const m = new RegExp(`.{1,${cols}}`, "gu"); - return output.match(m).join("\n"); - } - - /** - * Ensures a string input. - * @param {*} input - Input. - * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present. - * @returns {string} - Normalized input. - */ - normalizeInput(input, keepWS=false) { - if (keepWS) { - return String(input); - } - return String(input).replace(/\s/g, ""); - } - -} - -/** - * BaseEx Base Converter. - * --------------------- - * Core class for base-conversion and substitution - * based on a given charset. - */ -class BaseConverter { - - /** - * BaseEx BaseConverter Constructor. - * @param {number} radix - Radix for the converter. - * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation). - * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation). - * @param {number} [decPadVal=0] - Value used for padding during decoding. - */ - constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) { - - this.radix = radix; - - if (bsEnc !== null && bsDec !== null) { - this.bsEnc = bsEnc; - this.bsDec = bsDec; - } else { - [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix); - } - - this.decPadVal = decPadVal; - } - - /** - * Experimental feature! - * Calc how many bits are needed to represent - * 256 conditions (1 byte). If the radix is - * less than 8 bits, skip that part and use - * the radix value directly. - */ - static guessBS(radix) { - - let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix); - - // If the result is a multiple of 8 it - // is appropriate to reduce the result - - while (bsDecPre > 8 && !(bsDecPre % 8)) { - bsDecPre /= 8; - } - - // Search for the amount of bytes, which are necessary - // to represent the assumed amount of bytes. If the result - // is equal or bigger than the assumption for decoding, the - // amount of bytes for encoding is found. - - let bsEnc = 0; - while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) { - bsEnc++; - } - - // The result for decoding can now get calculated accurately. - const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix)); - - return [bsEnc, bsDec]; - } - - - /** - * BaseEx Universal Base Encoding. - * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array. - * @param {string} charset - The charset used for conversion. - * @param {boolean} littleEndian - Byte order, little endian bool. - * @param {function} replacer - Replacer function can replace groups of characters during encoding. - * @returns {number[]} - Output string and padding amount. - */ - encode(inputBytes, charset, littleEndian=false, replacer=null) { - - // Initialize output string and set yet unknown - // zero padding to zero. - let bs = this.bsEnc; - if (bs === 0) { - bs = inputBytes.byteLength; - } - - let output = ""; - - const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0; - const zeroArray = new Array(zeroPadding).fill(0); - let byteArray; - - if (littleEndian) { - - // as the following loop walks through the array - // from left to right, the input bytes get reversed - // to favor the least significant first - - inputBytes.reverse(); - byteArray = [...zeroArray, ...inputBytes]; - } else { - byteArray = [...inputBytes, ...zeroArray]; - } - - // Iterate over the input array in groups with the length - // of the given blocksize. - - // If the radix is 10, make a shortcut here by converting - // all bytes into the decimal number "n" and return the - // result as a string. - if (this.radix === 10) { - let n = 0n; - - for (let i=0; i= this.radix) { - [q, r] = this.divmod(q, this.radix); - bXarray.unshift(parseInt(r, 10)); - } - - // Append the remaining quotient to the array - bXarray.unshift(parseInt(q, 10)); - - // If the length of the array is less than the - // given output bs, it gets filled up with zeros. - // (This happens in groups of null bytes) - - while (bXarray.length < this.bsDec) { - bXarray.unshift(0); - } - - // Each digit is used as an index to pick a - // corresponding char from the charset. The - // chars get concatenated and stored in "frame". - - let frame = ""; - bXarray.forEach( - charIndex => frame = frame.concat(charset[charIndex]) - ); - - // Ascii85 is replacing four consecutive "!" into "z" - // Also other replacements can be implemented and used - // at this point. - if (replacer) { - frame = replacer(frame, zeroPadding); - } - - output = output.concat(frame); - } - - // The output string is returned. Also the amount - // of padded zeros. The specific class decides how - // to handle the padding. - - return [output, zeroPadding]; - } - - - /** - * BaseEx Universal Base Decoding. - * Decodes to a string of the given radix to a byte array. - * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that). - * @param {string[]} charset - The charset used for conversion. - * @param {string[]} padSet - Padding characters for integrity check. - * @param {boolean} integrity - If set to false invalid character will be ignored. - * @param {boolean} littleEndian - Byte order, little endian bool. - * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array. - */ - decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) { - - // Convert each char of the input to the radix-integer - // (this becomes the corresponding index of the char - // from the charset). Every char, that is not found in - // in the set is getting ignored. - - if (!inputBaseStr) { - return new Uint8Array(0); - } - - - let bs = this.bsDec; - const byteArray = new Array(); - - [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { - byteArray.push(index); - } else if (integrity && padSet.indexOf(c) === -1) { - throw new DecodingError(c); - } - }); - - let padChars; - - if (bs === 0) { - bs = byteArray.length; - } else { - padChars = (bs - byteArray.length % bs) % bs; - const fillArray = new Array(padChars).fill(this.decPadVal); - if (littleEndian) { - byteArray.unshift(...fillArray); - } else { - byteArray.push(...fillArray); - } - } - - // Initialize a new default array to store - // the converted radix-256 integers. - - let b256Array = new Array(); - - // Iterate over the input bytes in groups of - // the blocksize. - - for (let i=0, l=byteArray.length; i= 256) { - [q, r] = this.divmod(q, 256); - subArray256.unshift(parseInt(r, 10)); - } - - // Append the remaining quotient to the array - subArray256.unshift(parseInt(q, 10)); - - // If the length of the array is less than the required - // bs after decoding it gets filled up with zeros. - // (Again, this happens with null bytes.) - - while (subArray256.length < this.bsEnc) { - subArray256.unshift(0); - } - - // The subarray gets concatenated with the - // main array. - b256Array = b256Array.concat(subArray256); - } - - // Remove padded zeros (or in case of LE all leading zeros) - - if (littleEndian) { - if (b256Array.length > 1) { - - // remove all zeros from the start of the array - while (!b256Array[0]) { - b256Array.shift(); - } - - if (!b256Array.length) { - b256Array.push(0); - } - - b256Array.reverse(); - } - } else if (this.bsDec) { - const padding = this.padChars(padChars); - - // remove all bytes according to the padding - b256Array.splice(b256Array.length-padding); - } - - return Uint8Array.from(b256Array); - } - - - /** - * Calculates the amount of bytes, which are padding bytes. - * @param {number} charCount - Pass the amount of characters, which were added during encoding. - * @returns {number} - Amount of padding characters. - */ - padBytes(charCount) { - return Math.floor((charCount * this.bsDec) / this.bsEnc); - } - - /** - * Calculates the amount of bytes which can get removed - * from the decoded output bytes. - * @param {number} byteCount - Added bytes for padding - * @returns {number} - Amount of output bytes to be removed. - */ - padChars(byteCount) { - return Math.ceil((byteCount * this.bsEnc) / this.bsDec); - } - - - /** - * Calculates the power for the current base - * according to the given position as BigInt. - * - * @param {number} n - Position - * @returns {BigInt} - BigInt power value - */ - pow(n) { - return BigInt(this.radix)**BigInt(n); - } - - - /** - * Divmod function, which returns the results as - * an array of two BigInts. - * @param {*} x - Dividend - * @param {*} y - Divisor - * @returns {number[]} - [Quotient, Remainder] - */ - divmod(x, y) { - [x, y] = [BigInt(x), BigInt(y)]; - return [(x / y), (x % y)]; - } -} - - -/** - * Base of every BaseConverter. Provides basic - * en- and decoding, makes sure, that every - * property is set (to false by default). - * Also allows global feature additions. - * - * Requires BaseEx Utils - */ -class BaseTemplate { - - /** - * BaseEx BaseTemplate Constructor. - * @param {boolean} appendUtils - If set to false, the utils are not getting used. - */ - constructor(appendUtils=true) { - - // predefined settings - this.charsets = {}; - this.decimalMode = false; - this.frozenCharsets = false; - this.hasDecimalMode = false; - this.hasSignedMode = false; - this.integrity = true; - this.littleEndian = false; - this.numberMode = false; - this.outputType = "buffer"; - this.padding = false; - this.padCharAmount = 0; - this.padChars = {}; - this.signed = false; - this.upper = null; - if (appendUtils) this.utils = new Utils(this); - this.version = "default"; - this.options = { - lineWrap: 0 - }; - - // list of allowed/disallowed args to change - this.isMutable = { - integrity: true, - littleEndian: false, - padding: false, - signed: false, - upper: false, - }; - } - - /** - * BaseEx Generic Encoder. - * @param {*} input - Any input the used byte converter allows. - * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. - * @param {function} [postEncodeFN] - Function, which is executed after encoding. - * @param {...any} args - Converter settings. - * @returns {string} - Base encoded string. - */ - encode(input, replacerFN, postEncodeFN, ...args) { - - // apply settings - const settings = this.utils.validateArgs(args); - - // handle input - let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); - - // generate replacer function if given - let replacer = null; - if (replacerFN) { - replacer = replacerFN(settings); - } - - // Convert to base string - let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); - - // set sign if requested - if (settings.signed) { - output = this.utils.toSignedStr(output, negative); - } - - // set upper case if requested - if (settings.upper) { - output = output.toUpperCase(); - } - - // modify the output based on a given function (optionally) - if (postEncodeFN) { - output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type }); - } - - return this.utils.wrapOutput(output, settings.options.lineWrap); - } - - - /** - * BaseEx Generic Decoder. - * @param {string} input - Base String. - * @param {function} [preDecodeFN] - Function, which gets executed before decoding. - * @param {function} [postDecodeFN] - Function, which gets executed after decoding - * @param {...any} args - Converter settings. - * @returns {*} - Output according to converter settings. - */ - decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) { - - // apply settings - const settings = this.utils.validateArgs(args); - - // ensure a string input - input = this.utils.normalizeInput(input, keepNL); - - // set negative to false for starters - let negative = false; - - // Test for a negative sign if converter supports it - if (this.hasSignedMode) { - [ input, negative ] = this.utils.extractSign(input); - - // But don't allow a sign if the decoder is not configured to use it - if (negative && !settings.signed) { - this.utils.signError(); - } - } - - // Make the input lower case if alphabet has only one case - // (single case alphabets are stored as lower case strings) - if (this.isMutable.upper) { - input = input.toLowerCase(); - } - - // Run pre decode function if provided - if (preDecodeFN) { - input = preDecodeFN({ input, settings }); - } - - // Run the decoder - let output = this.converter.decode( - input, - this.charsets[settings.version], - this.padChars[settings.version], - settings.integrity, - settings.littleEndian - ); - - // Run post decode function if provided - if (postDecodeFN) { - output = postDecodeFN({ input, output, settings }); - } - - return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative); - } -} - -/** - * [BaseEx|UTF8 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.5.0 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */ - - /** - * BaseEx Little Endian Base 128 Converter. - * --------------------------------------- - * - * This is a utf8 converter. Various input can be - * converted to a utf8 string or a utf8 string - * can be decoded into various formats. - * - * There is no real charset available as the input is - * getting converted to bytes. For having the chance - * to store these bytes, there is a hexadecimal output - * available. - */ - class Utf8 extends BaseTemplate { - - /** - * BaseEx UTF8 Constructor. - * @param {...string} [args] - Converter settings. - */ - constructor(...args) { - // initialize base template without utils - super(); - - // converters - this.converter = new BaseConverter(10, 0, 0); - - // charsets - this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"]; - - // predefined settings - this.version = "default"; - this.frozenCharsets = true; - - // apply user settings - this.utils.validateArgs(args, true); - } - - - /** - * BaseEx UTF8 Encoder. - * @param {*} input - Input according to the used byte converter. - * @param {...str} [args] - Converter settings. - * @returns { sting } - UTF8 encoded Unit8Array (or hex string of it). - */ - encode(input, ...args) { - - // argument validation and input settings - const settings = this.utils.validateArgs(args); - - const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0]; - - let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0]; - - let n = BigInt(base10); - - return n; - } - - show() { - // - } - - - #ranges = { - a: 1 - } -} - -export { Utf8 as default }; diff --git a/dist/converters/Utf8/utf8.esm.min.js b/dist/converters/Utf8/utf8.esm.min.js deleted file mode 100644 index 50504ca..0000000 --- a/dist/converters/Utf8/utf8.esm.min.js +++ /dev/null @@ -1,8 +0,0 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} -/** - * [BaseEx|UTF8 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.5.0 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */class u extends h{constructor(...t){super(),this.converter=new l(10,0,0),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],this.version="default",this.frozenCharsets=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const n=this.utils.validateArgs(e),i=this.utils.inputHandler.toBytes(t,n)[0];let r=this.converter.encode(i,null,n.littleEndian)[0];return BigInt(r)}show(){}#i={a:1}}export{u as default}; diff --git a/dist/converters/Utf8/utf8.iife.js b/dist/converters/Utf8/utf8.iife.js deleted file mode 100644 index 5e3c7d1..0000000 --- a/dist/converters/Utf8/utf8.iife.js +++ /dev/null @@ -1,1532 +0,0 @@ -var Utf8 = (function () { - 'use strict'; - - /** - * Simple Input Handler. - * -------------------- - * Accepts only bytes eg. TypedArray, ArrayBuffer, - * DataView, also a regular array (filled with integers) - * is possible. - */ - class BytesInput { - static toBytes(input) { - if (ArrayBuffer.isView(input)) { - input = input.buffer; - } - return [new Uint8Array(input), false, "bytes"]; - } - } - - /** - * Simple Output Handler. - * --------------------- - * Returns bytes in the form of: - * - ArrayBuffer - * - Uint8Array - * - DataView - */ - class BytesOutput { - - static get typeList() { - return [ - "buffer", - "bytes", - "uint8", - "view" - ]; - } - - static getType(type) { - if (!BytesOutput.typeList.includes(type)) { - throw new TypeError(`Unknown output type: '${type}'`); - } - return type; - } - - static compile(Uint8ArrayOut, type) { - type = BytesOutput.getType(type); - let compiled; - - if (type === "buffer") { - compiled = Uint8ArrayOut.buffer; - } - - else if (type === "view") { - compiled = new DataView(Uint8ArrayOut.buffer); - } - - else { - compiled = Uint8ArrayOut; - } - - return compiled; - } - } - - - /** - * Advanced Input Handler. - * ---------------------- - * Accepts almost every Input and converts it - * into an Uint8Array (bytes). - */ - class SmartInput { - - static makeDataView(byteLen) { - const buffer = new ArrayBuffer(byteLen); - return new DataView(buffer); - } - - static floatingPoints(input, littleEndian=false) { - const view = this.makeDataView(8); - view.setFloat64(0, input, littleEndian); - return view; - } - - static numbers(input, littleEndian=false) { - - let view; - let type; - - // Integer - if (Number.isInteger(input)) { - - type = "int"; - - if (!Number.isSafeInteger(input)) { - - let safeInt; - let smallerOrBigger; - let minMax; - - if (input < 0) { - safeInt = Number.MIN_SAFE_INTEGER; - smallerOrBigger = "smaller"; - minMax = "MIN"; - } else { - safeInt = Number.MAX_SAFE_INTEGER; - smallerOrBigger = "bigger"; - minMax = "MAX"; - } - - throw new RangeError(`The provided integer is ${smallerOrBigger} than ${minMax}_SAFE_INTEGER: '${safeInt}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`); - } - - // Signed Integer - if (input < 0) { - - // 64 bit - if (input < -2147483648) { - view = this.makeDataView(8); - view.setBigInt64(0, BigInt(input), littleEndian); - } - - // 32 littleEndian - else if (input < -32768) { - view = this.makeDataView(4); - view.setInt32(0, input, littleEndian); - } - - // 16 littleEndian - else { - view = this.makeDataView(2); - view.setInt16(0, input, littleEndian); - } - } - - // Unsigned Integer - else if (input > 0) { - - // 64 bit - if (input > 4294967295) { - view = this.makeDataView(8); - view.setBigUint64(0, BigInt(input), littleEndian); - } - - // 32 bit - else if (input > 65535) { - view = this.makeDataView(4); - view.setUint32(0, input, littleEndian); - } - - // 16 bit - else { - view = this.makeDataView(2); - view.setInt16(0, input, littleEndian); - } - } - - // Zero - else { - view = new Uint16Array([0]); - } - } - - // Floating Point Number: - else { - type = "float"; - view = this.floatingPoints(input, littleEndian); - } - - return [new Uint8Array(view.buffer), type]; - - } - - - static bigInts(input, littleEndian=false) { - // Since BigInts are not limited to 64 bits, they might - // overflow the BigInt64Array values. A little more - // handwork is therefore needed. - - // as the integer size is not known yet, the bytes get a - // makeshift home "byteArray", which is a regular array - - const byteArray = new Array(); - const append = (littleEndian) ? "push" : "unshift"; - const maxN = 18446744073709551616n; - - // split the input into 64 bit integers - if (input < 0) { - while (input < -9223372036854775808n) { - byteArray[append](input % maxN); - input >>= 64n; - } - } else { - while (input >= maxN) { - byteArray[append](input % maxN); - input >>= 64n; - } - } - - // append the remaining byte - byteArray[append](input); - - // determine the required size for the typed array - // by taking the amount of 64 bit integers * 8 - // (8 bytes for each 64 bit integer) - const byteLen = byteArray.length * 8; - - // create a fresh data view - const view = this.makeDataView(byteLen); - - // set all 64 bit integers - byteArray.forEach((bigInt, i) => { - const offset = i * 8; - view.setBigUint64(offset, bigInt, littleEndian); - }); - - return new Uint8Array(view.buffer); - } - - - static toBytes(input, settings) { - - let inputUint8; - let negative = false; - let type = "bytes"; - - // Buffer: - if (input instanceof ArrayBuffer) { - inputUint8 = new Uint8Array(input.slice()); - } - - // TypedArray or DataView: - else if (ArrayBuffer.isView(input)) { - inputUint8 = new Uint8Array(input.buffer.slice()); - } - - // String: - else if (typeof input === "string" || input instanceof String) { - inputUint8 = new TextEncoder().encode(input); - } - - // Number: - else if (typeof input === "number") { - if (isNaN(input)) { - throw new TypeError("Cannot proceed. Input is NaN."); - } else if (input == Infinity) { - throw new TypeError("Cannot proceed. Input is Infinity."); - } - - if (settings.signed && input < 0) { - negative = true; - input = -input; - } - - if (settings.numberMode) { - const view = this.floatingPoints(input, settings.littleEndian); - inputUint8 = new Uint8Array(view.buffer); - type = "float"; - } else { - [inputUint8, type] = this.numbers(input, settings.littleEndian); - } - } - - // BigInt: - else if (typeof input === "bigint") { - if (settings.signed && input < 0) { - negative = true; - input *= -1n; - } - inputUint8 = this.bigInts(input, settings.littleEndian); - type = "int"; - } - - // Array - else if (Array.isArray(input)) { - const collection = new Array(); - for (const elem of input) { - collection.push(...this.toBytes(elem, settings)[0]); - } - inputUint8 = Uint8Array.from(collection); - } - - else { - throw new TypeError("The provided input type can not be processed."); - } - - return [inputUint8, negative, type]; - } - } - - /** - * Advanced Output Handler. - * ----------------------- - * This Output handler makes it possible to - * convert an Uint8Array (bytes) into a desired - * format of a big variety. - * - * The default output is an ArrayBuffer. - */ - class SmartOutput { - - static get typeList() { - return [ - "bigint64", - "bigint_n", - "biguint64", - "buffer", - "bytes", - "float32", - "float64", - "float_n", - "int8", - "int16", - "int32", - "int_n", - "str", - "uint8", - "uint16", - "uint32", - "uint_n", - "view" - ]; - } - - static getType(type) { - if (!this.typeList.includes(type)) { - throw new TypeError(`Unknown output type: '${type}'`); - } - return type; - } - - static makeTypedArrayBuffer(Uint8ArrayOut, bytesPerElem, littleEndian, negative) { - - const len = Uint8ArrayOut.byteLength; - const delta = (bytesPerElem - (Uint8ArrayOut.byteLength % bytesPerElem)) % bytesPerElem; - const newLen = len + delta; - - // if the array is negative and the len is gt 1 - // fill the whole array with 255 - const fillVal = (negative && len > 1) ? 255 : 0; - - let newArray = Uint8ArrayOut; - - if (delta) { - newArray = new Uint8Array(newLen); - newArray.fill(fillVal); - - const offset = (littleEndian) ? 0 : delta; - newArray.set(Uint8ArrayOut, offset); - } - - - return newArray.buffer; - } - - static makeTypedArray(inArray, type, littleEndian, negative) { - let outArray; - - if (type === "int16" || type === "uint16") { - - const buffer = this.makeTypedArrayBuffer(inArray, 2, littleEndian, negative); - outArray = (type === "int16") ? new Int16Array(buffer) : new Uint16Array(buffer); - - } else if (type === "int32" || type === "uint32" || type === "float32") { - - const buffer = this.makeTypedArrayBuffer(inArray, 4, littleEndian, negative); - - if (type === "int32") { - outArray = new Int32Array(buffer); - } else if (type === "uint32") { - outArray = new Uint32Array(buffer); - } else { - outArray = new Float32Array(buffer); - } - - } else if (type === "bigint64" || type === "biguint64" || type === "float64") { - - const buffer = this.makeTypedArrayBuffer(inArray, 8, littleEndian, negative); - - if (type === "bigint64") { - outArray = new BigInt64Array(buffer); - } else if (type === "biguint64") { - outArray = new BigUint64Array(buffer); - } else { - outArray = new Float64Array(buffer); - } - } - - return outArray; - } - - static compile(Uint8ArrayOut, type, littleEndian=false, negative=false) { - type = this.getType(type); - let compiled; - - // If the array is negative (which is only - // true for signed encoding) get the positive - // decimal number first and feed it with a - // negative sign to SmartInput to construct - // the unsigned output which is not shortened. - - if (negative) { - let n; - if (type.match(/^float/)) { - n = -(this.compile(Uint8ArrayOut, "float_n", littleEndian)); - } else { - n = -(this.compile(Uint8ArrayOut, "uint_n", littleEndian)); - } - if (type === "float_n") { - return n; - } - Uint8ArrayOut = SmartInput.toBytes(n, {littleEndian, numberMode: false, signed: false})[0]; - } - - if (type === "buffer") { - compiled = Uint8ArrayOut.buffer; - } - - else if (type === "bytes" || type === "uint8") { - compiled = Uint8ArrayOut; - } - - else if (type === "int8") { - compiled = new Int8Array(Uint8ArrayOut.buffer); - } - - else if (type === "view") { - compiled = new DataView(Uint8ArrayOut.buffer); - } - - else if (type === "str") { - compiled = new TextDecoder().decode(Uint8ArrayOut); - } - - else if (type === "uint_n" || type === "int_n" || type === "bigint_n") { - - // If the input consists of only one byte, expand it - if (Uint8ArrayOut.length === 1) { - const uint16Buffer = this.makeTypedArrayBuffer(Uint8ArrayOut, 2, littleEndian, negative); - Uint8ArrayOut = new Uint8Array(uint16Buffer); - } - - if (littleEndian) { - Uint8ArrayOut.reverse(); - } - - // calculate a unsigned big integer - let n = 0n; - Uint8ArrayOut.forEach((b) => n = (n << 8n) + BigInt(b)); - - // convert to signed int if requested - if (type !== "uint_n") { - n = BigInt.asIntN(Uint8ArrayOut.length*8, n); - } - - // convert to regular number if possible (and no bigint was requested) - if (type !== "bigint_n" && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) { - compiled = Number(n); - } else { - compiled = n; - } - } - - else if (type === "float_n") { - - if (Uint8ArrayOut.length <= 4) { - - let array; - if (Uint8ArrayOut.length === 4) { - array = Uint8ArrayOut; - } else { - array = this.makeTypedArray(Uint8ArrayOut, "float32", false, negative); - } - - const view = new DataView(array.buffer); - compiled = view.getFloat32(0, littleEndian); - - } - - else if (Uint8ArrayOut.length <= 8) { - - let array; - if (Uint8ArrayOut.length === 8) { - array = Uint8ArrayOut; - } else { - array = this.makeTypedArray(Uint8ArrayOut, "float64", false, negative); - } - - const view = new DataView(array.buffer); - compiled = view.getFloat64(0, littleEndian); - - } - - else { - throw new RangeError("The provided input is to complex to be converted into a floating point.") - } - } - - else if (type === "number") { - if (Uint8ArrayOut.length !== 8) { - throw new TypeError("Type mismatch. Cannot convert into number."); - } - - const float64 = new Float64Array(Uint8ArrayOut.buffer); - compiled = Number(float64); - } - - else { - compiled = this.makeTypedArray(Uint8ArrayOut, type, littleEndian, negative); - } - - return compiled; - } - } - - const DEFAULT_INPUT_HANDLER = SmartInput; - const DEFAULT_OUTPUT_HANDLER = SmartOutput; - - class SignError extends TypeError { - constructor() { - super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); - this.name = "SignError"; - } - } - - class DecodingError extends TypeError { - constructor(char, msg=null) { - if (msg === null) { - msg = `Character '${char}' is not part of the charset.`; - } - super(msg); - this.name = "DecodingError"; - } - } - - - /** - * Utilities for every BaseEx class. - * -------------------------------- - * Requires IO Handlers - */ - class Utils { - - constructor(main) { - - // Store the calling class in this.root - // for accessability. - this.root = main; - - // set specific args object for converters - this.converterArgs = {}; - - // If charsets are uses by the parent class, - // add extra functions for the user. - - this.#charsetUserToolsConstructor(); - } - - setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) { - this.inputHandler = inputHandler; - this.outputHandler = outputHandler; - } - - - /** - * Constructor for the ability to add a charset and - * change the default version. - */ - #charsetUserToolsConstructor() { - - /** - * Save method to add a charset. - * @param {string} name - "Charset name." - * @param {[string|set|array]} - "Charset" - */ - this.root.addCharset = (name, _charset, _padChars=[], info=true) => { - - const normalize = (typeName, set, setLen) => { - - if (setLen === 0 && set.length) { - console.warn(`This converter has no ${typeName}. The following argument was ignored:\n'${set}'`); - return []; - } - - let inputLen = setLen; - - if (typeof set === "string") { - set = [...set]; - } - - if (Array.isArray(set)) { - - // Store the input length of the input - inputLen = set.length; - - // Convert to "Set" -> eliminate duplicates - // If duplicates are found the length of the - // Set and the length of the initial input - // differ. - - set = new Set(set); - - } else if (!(set instanceof Set)) { - throw new TypeError(`The ${typeName} must be one of the types:\n'str', 'set', 'array'."`); - } - - if (set.size === setLen) { - return [...set]; - } - - if (inputLen !== setLen) { - throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`); - } else { - const charAmounts = {}; - _charset = [..._charset]; - _charset.forEach(c => { - if (c in charAmounts) { - charAmounts[c]++; - } else { - charAmounts[c] = 1; - } - }); - - let infoStr = ""; - if (setLen < 100) { - infoStr = `${_charset.join("")}\n`; - _charset.forEach(c => { - if (charAmounts[c] > 1) { - infoStr += "^"; - } else { - infoStr += " "; - } - }); - } - const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1); - throw new Error(`You have repetitive char(s) [ ${rChars.join(" | ")} ] in your ${typeName}. Make sure each character is unique.\n${infoStr}`); - } - }; - - if (this.root.frozenCharsets) { - throw new Error("The charsets of this converter cannot be changed."); - } - - if (typeof name !== "string") { - throw new TypeError("The charset name must be a string."); - } - - if (info && name in this.root.charsets) { - console.warn(`An existing charset with name ${name} will get replaced.`); - } - - const charset = normalize("charset", _charset, this.root.converter.radix); - const padChars = normalize("padding set", _padChars, this.root.padCharAmount); - - this.root.charsets[name] = charset; - if (padChars.length) { - this.root.padChars[name] = padChars; - } - - if (info) { - console.info(`New charset '${name}' was added and is ready to use`); - } - }; - - // Save method (argument gets validated) to - // change the default version. - this.root.setDefaultCharset = (version) => { - if (!(version in this.root.charsets)) { - const sets = Object.keys(this.root.charsets).join("\n * "); - const msg = `Charset ${version} was not found. Available charsets are:\n * ${sets}`; - throw new TypeError(msg); - } - this.root.version = version; - }; - } - - /** - * Argument lists for error messages. - * @param {string[]} args - * @returns string - Arguments joined as a string. - */ - #makeArgList(args) { - return args.map(s => `'${s}'`).join(", "); - } - - /** - * Removes all padded zeros a the start of the string, - * adds a "-" if value is negative. - * @param {string} output - Former output. - * @param {boolean} negative - Indicates a negative value if true. - * @returns {string} - Output without zero padding and a sign if negative. - */ - toSignedStr(output, negative) { - - output = output.replace(/^0+(?!$)/, ""); - - if (negative) { - output = "-".concat(output); - } - - return output; - } - - /** - * Analyzes the input for a negative sign. - * If a sign is found, it gets removed but - * negative bool gets true; - * @param {string} input - Input number as a string. - * @returns {array} - Number without sign and negativity indication bool. - */ - extractSign(input) { - let negative = false; - if (input[0] === "-") { - negative = true; - input = input.slice(1); - } - - return [input, negative]; - } - - /** - * All possible error messages for invalid arguments, - * gets adjusted according to the converter settings. - * @param {string} arg - Argument. - * @param {string[]} versions - Charset array. - * @param {string[]} outputTypes - Array of output types. - * @param {boolean} initial - Indicates if the arguments where passed during construction. - */ - #invalidArgument(arg, versions, outputTypes, initial) { - const loopConverterArgs = () => Object.keys(this.converterArgs).map( - key => this.converterArgs[key].map( - keyword => `'${keyword}'` - ) - .join(" and ") - ) - .join("\n - "); - - throw new TypeError([ - `'${arg}'\n\nParameters:`, - initial ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : "", - this.root.isMutable.signed ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : "", - this.root.isMutable.littleEndian ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : "", - this.root.isMutable.padding ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : "", - this.root.isMutable.upper ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : "", - `\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`, - versions ? `\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : "", - "\n * valid args for integrity check are: 'integrity' and 'nointegrity'", - this.root.hasDecimalMode ? "\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)" : "", - "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)", - Object.keys(this.converterArgs).length ? `\n * converter specific args:\n - ${loopConverterArgs()}` : "", - "\n\nTraceback:" - ].join("")); - } - - - /** - * Test if provided arguments are in the argument list. - * Everything gets converted to lowercase and returned. - * @param {string[]} args - Passed arguments. - * @param {boolean} initial - Indicates if the arguments where passed during construction. - * @returns {Object} - Converter settings object. - */ - validateArgs(args, initial=false) { - - // default settings - const parameters = { - decimalMode: this.root.decimalMode, - integrity: this.root.integrity, - littleEndian: this.root.littleEndian, - numberMode: this.root.numberMode, - options: this.root.options, - outputType: this.root.outputType, - padding: this.root.padding, - signed: this.root.signed, - upper: this.root.upper, - version: this.root.version - }; - - // add any existing converter specific args - for (const param in this.converterArgs) { - parameters[param] = this.root[param]; - } - - // if no args are provided return the default settings immediately - if (!args.length) { - - // if initial call set default IO handlers - if (initial) { - this.setIOHandlers(); - } - - return parameters; - } - - // Helper function to test the presence of a - // particular arg. If found, true is returned - // and it gets removed from the array. - const extractArg = (arg) => { - if (args.includes(arg)) { - args.splice(args.indexOf(arg), 1); - return true; - } - return false; - }; - - // set available versions and extra arguments - const versions = Object.keys(this.root.charsets); - const extraArgList = { - integrity: ["nointegrity", "integrity"], - littleEndian: ["be", "le"], - padding: ["nopad", "pad"], - signed: ["unsigned", "signed"], - upper: ["lower", "upper"], - ...this.converterArgs - }; - - // if initial, look for IO specifications - if (initial) { - if (extractArg("bytes_only")) { - this.setIOHandlers(BytesInput, BytesOutput); - } else { - const inHandler = (extractArg("bytes_in")) ? BytesInput : DEFAULT_INPUT_HANDLER; - const outHandler = (extractArg("bytes_out")) ? BytesOutput : DEFAULT_OUTPUT_HANDLER; - this.setIOHandlers(inHandler, outHandler); - } - } - - // set valid output types - const outputTypes = this.outputHandler.typeList; - - // test for special "number" keyword - if (extractArg("number")) { - parameters.numberMode = true; - parameters.outputType = "float_n"; - } - - // test for the special "decimal" keyword - if (extractArg("decimal")) { - if (!this.root.hasDecimalMode) { - throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`); - } - parameters.decimalMode = true; - parameters.outputType = "decimal"; - - if (parameters.numberMode) { - parameters.numberMode = false; - console.warn("-> number-mode was disabled due to the decimal-mode"); - } - } - - // walk through the remaining arguments - args.forEach((arg) => { - - // additional/optional non boolean options - if (typeof arg === "object") { - parameters.options = {...parameters.options, ...arg}; - return; - } - - arg = String(arg).toLowerCase(); - - if (versions.includes(arg)) { - parameters.version = arg; - } else if (outputTypes.includes(arg)) { - parameters.outputType = arg; - } else { - // set invalid args to true for starters - // if a valid arg is found later it will - // get changed - - let invalidArg = true; - - // walk through the mutable parameter list - - for (const param in extraArgList) { - - if (extraArgList[param].includes(arg)) { - - invalidArg = false; - - // extra params always have two options - // they are converted into booleans - // index 0 > false - // index 1 > true - - if (this.root.isMutable[param]) { - parameters[param] = Boolean(extraArgList[param].indexOf(arg)); - } else { - throw TypeError(`Argument '${arg}' is not allowed for this type of converter.`); - } - } - } - - if (invalidArg) { - this.#invalidArgument(arg, versions, outputTypes, initial); - } - } - }); - - // If padding and signed are true, padding - // is set to false and a warning is getting - // displayed. - if (parameters.padding && parameters.signed) { - parameters.padding = false; - console.warn("-> padding was set to false due to the signed conversion"); - } - - // overwrite the default parameters for the initial call - if (initial) { - for (const param in parameters) { - this.root[param] = parameters[param]; - } - } - - return parameters; - } - - /** - * A TypeError specifically for sign errors. - */ - signError() { - throw new SignError(); - } - - /** - * Wrap output to "cols" characters per line. - * @param {string} output - Output string. - * @param {number} cols - Number of cols per line. - * @returns {string} - Wrapped output. - */ - wrapOutput(output, cols=0) { - if (!cols) { - return output; - } - const m = new RegExp(`.{1,${cols}}`, "gu"); - return output.match(m).join("\n"); - } - - /** - * Ensures a string input. - * @param {*} input - Input. - * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present. - * @returns {string} - Normalized input. - */ - normalizeInput(input, keepWS=false) { - if (keepWS) { - return String(input); - } - return String(input).replace(/\s/g, ""); - } - - } - - /** - * BaseEx Base Converter. - * --------------------- - * Core class for base-conversion and substitution - * based on a given charset. - */ - class BaseConverter { - - /** - * BaseEx BaseConverter Constructor. - * @param {number} radix - Radix for the converter. - * @param {number} [bsEnc] - Block Size (input bytes grouped by bs) for encoding (if zero the integer has no limitation). - * @param {number} [bsDec] - Block Size (input bytes grouped by bs) for decoding (if zero the integer has no limitation). - * @param {number} [decPadVal=0] - Value used for padding during decoding. - */ - constructor(radix, bsEnc=null, bsDec=null, decPadVal=0) { - - this.radix = radix; - - if (bsEnc !== null && bsDec !== null) { - this.bsEnc = bsEnc; - this.bsDec = bsDec; - } else { - [this.bsEnc, this.bsDec] = this.constructor.guessBS(radix); - } - - this.decPadVal = decPadVal; - } - - /** - * Experimental feature! - * Calc how many bits are needed to represent - * 256 conditions (1 byte). If the radix is - * less than 8 bits, skip that part and use - * the radix value directly. - */ - static guessBS(radix) { - - let bsDecPre = (radix < 8) ? radix : Math.ceil(256 / radix); - - // If the result is a multiple of 8 it - // is appropriate to reduce the result - - while (bsDecPre > 8 && !(bsDecPre % 8)) { - bsDecPre /= 8; - } - - // Search for the amount of bytes, which are necessary - // to represent the assumed amount of bytes. If the result - // is equal or bigger than the assumption for decoding, the - // amount of bytes for encoding is found. - - let bsEnc = 0; - while (((bsEnc * 8) * Math.log(2) / Math.log(radix)) < bsDecPre) { - bsEnc++; - } - - // The result for decoding can now get calculated accurately. - const bsDec = Math.ceil((bsEnc * 8) * Math.log(2) / Math.log(radix)); - - return [bsEnc, bsDec]; - } - - - /** - * BaseEx Universal Base Encoding. - * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array. - * @param {string} charset - The charset used for conversion. - * @param {boolean} littleEndian - Byte order, little endian bool. - * @param {function} replacer - Replacer function can replace groups of characters during encoding. - * @returns {number[]} - Output string and padding amount. - */ - encode(inputBytes, charset, littleEndian=false, replacer=null) { - - // Initialize output string and set yet unknown - // zero padding to zero. - let bs = this.bsEnc; - if (bs === 0) { - bs = inputBytes.byteLength; - } - - let output = ""; - - const zeroPadding = (bs) ? (bs - inputBytes.length % bs) % bs : 0; - const zeroArray = new Array(zeroPadding).fill(0); - let byteArray; - - if (littleEndian) { - - // as the following loop walks through the array - // from left to right, the input bytes get reversed - // to favor the least significant first - - inputBytes.reverse(); - byteArray = [...zeroArray, ...inputBytes]; - } else { - byteArray = [...inputBytes, ...zeroArray]; - } - - // Iterate over the input array in groups with the length - // of the given blocksize. - - // If the radix is 10, make a shortcut here by converting - // all bytes into the decimal number "n" and return the - // result as a string. - if (this.radix === 10) { - let n = 0n; - - for (let i=0; i= this.radix) { - [q, r] = this.divmod(q, this.radix); - bXarray.unshift(parseInt(r, 10)); - } - - // Append the remaining quotient to the array - bXarray.unshift(parseInt(q, 10)); - - // If the length of the array is less than the - // given output bs, it gets filled up with zeros. - // (This happens in groups of null bytes) - - while (bXarray.length < this.bsDec) { - bXarray.unshift(0); - } - - // Each digit is used as an index to pick a - // corresponding char from the charset. The - // chars get concatenated and stored in "frame". - - let frame = ""; - bXarray.forEach( - charIndex => frame = frame.concat(charset[charIndex]) - ); - - // Ascii85 is replacing four consecutive "!" into "z" - // Also other replacements can be implemented and used - // at this point. - if (replacer) { - frame = replacer(frame, zeroPadding); - } - - output = output.concat(frame); - } - - // The output string is returned. Also the amount - // of padded zeros. The specific class decides how - // to handle the padding. - - return [output, zeroPadding]; - } - - - /** - * BaseEx Universal Base Decoding. - * Decodes to a string of the given radix to a byte array. - * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that). - * @param {string[]} charset - The charset used for conversion. - * @param {string[]} padSet - Padding characters for integrity check. - * @param {boolean} integrity - If set to false invalid character will be ignored. - * @param {boolean} littleEndian - Byte order, little endian bool. - * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array. - */ - decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) { - - // Convert each char of the input to the radix-integer - // (this becomes the corresponding index of the char - // from the charset). Every char, that is not found in - // in the set is getting ignored. - - if (!inputBaseStr) { - return new Uint8Array(0); - } - - - let bs = this.bsDec; - const byteArray = new Array(); - - [...inputBaseStr].forEach(c => { - const index = charset.indexOf(c); - if (index > -1) { - byteArray.push(index); - } else if (integrity && padSet.indexOf(c) === -1) { - throw new DecodingError(c); - } - }); - - let padChars; - - if (bs === 0) { - bs = byteArray.length; - } else { - padChars = (bs - byteArray.length % bs) % bs; - const fillArray = new Array(padChars).fill(this.decPadVal); - if (littleEndian) { - byteArray.unshift(...fillArray); - } else { - byteArray.push(...fillArray); - } - } - - // Initialize a new default array to store - // the converted radix-256 integers. - - let b256Array = new Array(); - - // Iterate over the input bytes in groups of - // the blocksize. - - for (let i=0, l=byteArray.length; i= 256) { - [q, r] = this.divmod(q, 256); - subArray256.unshift(parseInt(r, 10)); - } - - // Append the remaining quotient to the array - subArray256.unshift(parseInt(q, 10)); - - // If the length of the array is less than the required - // bs after decoding it gets filled up with zeros. - // (Again, this happens with null bytes.) - - while (subArray256.length < this.bsEnc) { - subArray256.unshift(0); - } - - // The subarray gets concatenated with the - // main array. - b256Array = b256Array.concat(subArray256); - } - - // Remove padded zeros (or in case of LE all leading zeros) - - if (littleEndian) { - if (b256Array.length > 1) { - - // remove all zeros from the start of the array - while (!b256Array[0]) { - b256Array.shift(); - } - - if (!b256Array.length) { - b256Array.push(0); - } - - b256Array.reverse(); - } - } else if (this.bsDec) { - const padding = this.padChars(padChars); - - // remove all bytes according to the padding - b256Array.splice(b256Array.length-padding); - } - - return Uint8Array.from(b256Array); - } - - - /** - * Calculates the amount of bytes, which are padding bytes. - * @param {number} charCount - Pass the amount of characters, which were added during encoding. - * @returns {number} - Amount of padding characters. - */ - padBytes(charCount) { - return Math.floor((charCount * this.bsDec) / this.bsEnc); - } - - /** - * Calculates the amount of bytes which can get removed - * from the decoded output bytes. - * @param {number} byteCount - Added bytes for padding - * @returns {number} - Amount of output bytes to be removed. - */ - padChars(byteCount) { - return Math.ceil((byteCount * this.bsEnc) / this.bsDec); - } - - - /** - * Calculates the power for the current base - * according to the given position as BigInt. - * - * @param {number} n - Position - * @returns {BigInt} - BigInt power value - */ - pow(n) { - return BigInt(this.radix)**BigInt(n); - } - - - /** - * Divmod function, which returns the results as - * an array of two BigInts. - * @param {*} x - Dividend - * @param {*} y - Divisor - * @returns {number[]} - [Quotient, Remainder] - */ - divmod(x, y) { - [x, y] = [BigInt(x), BigInt(y)]; - return [(x / y), (x % y)]; - } - } - - - /** - * Base of every BaseConverter. Provides basic - * en- and decoding, makes sure, that every - * property is set (to false by default). - * Also allows global feature additions. - * - * Requires BaseEx Utils - */ - class BaseTemplate { - - /** - * BaseEx BaseTemplate Constructor. - * @param {boolean} appendUtils - If set to false, the utils are not getting used. - */ - constructor(appendUtils=true) { - - // predefined settings - this.charsets = {}; - this.decimalMode = false; - this.frozenCharsets = false; - this.hasDecimalMode = false; - this.hasSignedMode = false; - this.integrity = true; - this.littleEndian = false; - this.numberMode = false; - this.outputType = "buffer"; - this.padding = false; - this.padCharAmount = 0; - this.padChars = {}; - this.signed = false; - this.upper = null; - if (appendUtils) this.utils = new Utils(this); - this.version = "default"; - this.options = { - lineWrap: 0 - }; - - // list of allowed/disallowed args to change - this.isMutable = { - integrity: true, - littleEndian: false, - padding: false, - signed: false, - upper: false, - }; - } - - /** - * BaseEx Generic Encoder. - * @param {*} input - Any input the used byte converter allows. - * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. - * @param {function} [postEncodeFN] - Function, which is executed after encoding. - * @param {...any} args - Converter settings. - * @returns {string} - Base encoded string. - */ - encode(input, replacerFN, postEncodeFN, ...args) { - - // apply settings - const settings = this.utils.validateArgs(args); - - // handle input - let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); - - // generate replacer function if given - let replacer = null; - if (replacerFN) { - replacer = replacerFN(settings); - } - - // Convert to base string - let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); - - // set sign if requested - if (settings.signed) { - output = this.utils.toSignedStr(output, negative); - } - - // set upper case if requested - if (settings.upper) { - output = output.toUpperCase(); - } - - // modify the output based on a given function (optionally) - if (postEncodeFN) { - output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type }); - } - - return this.utils.wrapOutput(output, settings.options.lineWrap); - } - - - /** - * BaseEx Generic Decoder. - * @param {string} input - Base String. - * @param {function} [preDecodeFN] - Function, which gets executed before decoding. - * @param {function} [postDecodeFN] - Function, which gets executed after decoding - * @param {...any} args - Converter settings. - * @returns {*} - Output according to converter settings. - */ - decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) { - - // apply settings - const settings = this.utils.validateArgs(args); - - // ensure a string input - input = this.utils.normalizeInput(input, keepNL); - - // set negative to false for starters - let negative = false; - - // Test for a negative sign if converter supports it - if (this.hasSignedMode) { - [ input, negative ] = this.utils.extractSign(input); - - // But don't allow a sign if the decoder is not configured to use it - if (negative && !settings.signed) { - this.utils.signError(); - } - } - - // Make the input lower case if alphabet has only one case - // (single case alphabets are stored as lower case strings) - if (this.isMutable.upper) { - input = input.toLowerCase(); - } - - // Run pre decode function if provided - if (preDecodeFN) { - input = preDecodeFN({ input, settings }); - } - - // Run the decoder - let output = this.converter.decode( - input, - this.charsets[settings.version], - this.padChars[settings.version], - settings.integrity, - settings.littleEndian - ); - - // Run post decode function if provided - if (postDecodeFN) { - output = postDecodeFN({ input, output, settings }); - } - - return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative); - } - } - - /** - * [BaseEx|UTF8 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.5.0 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */ - - /** - * BaseEx Little Endian Base 128 Converter. - * --------------------------------------- - * - * This is a utf8 converter. Various input can be - * converted to a utf8 string or a utf8 string - * can be decoded into various formats. - * - * There is no real charset available as the input is - * getting converted to bytes. For having the chance - * to store these bytes, there is a hexadecimal output - * available. - */ - class Utf8 extends BaseTemplate { - - /** - * BaseEx UTF8 Constructor. - * @param {...string} [args] - Converter settings. - */ - constructor(...args) { - // initialize base template without utils - super(); - - // converters - this.converter = new BaseConverter(10, 0, 0); - - // charsets - this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"]; - - // predefined settings - this.version = "default"; - this.frozenCharsets = true; - - // apply user settings - this.utils.validateArgs(args, true); - } - - - /** - * BaseEx UTF8 Encoder. - * @param {*} input - Input according to the used byte converter. - * @param {...str} [args] - Converter settings. - * @returns { sting } - UTF8 encoded Unit8Array (or hex string of it). - */ - encode(input, ...args) { - - // argument validation and input settings - const settings = this.utils.validateArgs(args); - - const inputBytes = this.utils.inputHandler.toBytes(input, settings)[0]; - - let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0]; - - let n = BigInt(base10); - - return n; - } - - show() { - // - } - - - #ranges = { - a: 1 - } - } - - return Utf8; - -})(); diff --git a/dist/converters/Utf8/utf8.iife.min.js b/dist/converters/Utf8/utf8.iife.min.js deleted file mode 100644 index 85676a1..0000000 --- a/dist/converters/Utf8/utf8.iife.min.js +++ /dev/null @@ -1,8 +0,0 @@ -var Utf8=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,n){let i;return i="buffer"===(n=e.getType(n))?t.buffer:"view"===n?new DataView(t.buffer):t,i}}class n{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const n=this.makeDataView(8);return n.setFloat64(0,t,e),n}static numbers(t,e=!1){let n,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,n,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,n="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,n="bigger",i="MAX"),new RangeError(`The provided integer is ${n} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(n=this.makeDataView(8),n.setBigInt64(0,BigInt(t),e)):t<-32768?(n=this.makeDataView(4),n.setInt32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):t>0?t>4294967295?(n=this.makeDataView(8),n.setBigUint64(0,BigInt(t),e)):t>65535?(n=this.makeDataView(4),n.setUint32(0,t,e)):(n=this.makeDataView(2),n.setInt16(0,t,e)):n=new Uint16Array([0])}else i="float",n=this.floatingPoints(t,e);return[new Uint8Array(n.buffer),i]}static bigInts(t,e=!1){const n=new Array,i=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)n[i](t%r),t>>=64n;else for(;t>=r;)n[i](t%r),t>>=64n;n[i](t);const s=8*n.length,o=this.makeDataView(s);return n.forEach(((t,n)=>{const i=8*n;o.setBigUint64(i,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let n,i=!1,r="bytes";if(t instanceof ArrayBuffer)n=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))n=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)n=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);n=new Uint8Array(i.buffer),r="float"}else[n,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),n=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const n of t)i.push(...this.toBytes(n,e)[0]);n=Uint8Array.from(i)}}return[n,i,r]}}const i=n,r=class{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,n,i){const r=t.byteLength,s=(e-t.byteLength%e)%e,o=i&&r>1?255:0;let a=t;if(s){a=new Uint8Array(r+s),a.fill(o);const e=n?0:s;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,n,i){let r;if("int16"===e||"uint16"===e){const s=this.makeTypedArrayBuffer(t,2,n,i);r="int16"===e?new Int16Array(s):new Uint16Array(s)}else if("int32"===e||"uint32"===e||"float32"===e){const s=this.makeTypedArrayBuffer(t,4,n,i);r="int32"===e?new Int32Array(s):"uint32"===e?new Uint32Array(s):new Float32Array(s)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const s=this.makeTypedArrayBuffer(t,8,n,i);r="bigint64"===e?new BigInt64Array(s):"biguint64"===e?new BigUint64Array(s):new Float64Array(s)}return r}static compile(t,e,i=!1,r=!1){let s;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return r;t=n.toBytes(r,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)s=t.buffer;else if("bytes"===e||"uint8"===e)s=t;else if("int8"===e)s=new Int8Array(t.buffer);else if("view"===e)s=new DataView(t.buffer);else if("str"===e)s=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,r);t=new Uint8Array(e)}i&&t.reverse();let n=0n;t.forEach((t=>n=(n<<8n)+BigInt(t))),"uint_n"!==e&&(n=BigInt.asIntN(8*t.length,n)),s="bigint_n"!==e&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?Number(n):n}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);s=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);s=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);s=Number(e)}else s=this.makeTypedArray(t,e,i,r);return s}};class s extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class o extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class a{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=i,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,n=[],i=!0)=>{const r=(t,n,i)=>{if(0===i&&n.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${n}'`),[];let r=i;if("string"==typeof n&&(n=[...n]),Array.isArray(n))r=n.length,n=new Set(n);else if(!(n instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(n.size===i)return[...n];if(r!==i)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${i}.`);{const n={};(e=[...e]).forEach((t=>{t in n?n[t]++:n[t]=1}));let r="";i<100&&(r=`${e.join("")}\n`,e.forEach((t=>{n[t]>1?r+="^":r+=" "})));const s=Object.keys(n).filter((t=>n[t]>1));throw new Error(`You have repetitive char(s) [ ${s.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");i&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const s=r("charset",e,this.root.converter.radix),o=r("padding set",n,this.root.padCharAmount);this.root.charsets[t]=s,o.length&&(this.root.padChars[t]=o),i&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#n(t,e,n,i){throw new TypeError([`'${t}'\n\nParameters:`,i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(n)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(n,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!n.length)return s&&this.setIOHandlers(),o;const a=t=>!!n.includes(t)&&(n.splice(n.indexOf(t),1),!0),l=Object.keys(this.root.charsets),h={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const n=a("bytes_in")?t:i,s=a("bytes_out")?e:r;this.setIOHandlers(n,s)}const u=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(n.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),l.includes(t))o.version=t;else if(u.includes(t))o.outputType=t;else{let e=!0;for(const n in h)if(h[n].includes(t)){if(e=!1,!this.root.isMutable[n])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[n]=Boolean(h[n].indexOf(t))}e&&this.#n(t,l,u,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new s}wrapOutput(t,e=0){if(!e)return t;const n=new RegExp(`.{1,${e}}`,"gu");return t.match(n).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,n=null,i=0){this.radix=t,null!==e&&null!==n?(this.bsEnc=e,this.bsDec=n):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let n=0;for(;8*n*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),a.unshift(parseInt(h,10));for(a.unshift(parseInt(u,10));a.lengthc=c.concat(e[t]))),i&&(c=i(c,o)),s=s.concat(c)}return[s,o]}decode(t,e,n=[],i=!0,r=!1){if(!t)return new Uint8Array(0);let s=this.bsDec;const a=new Array;let l;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)a.push(r);else if(i&&-1===n.indexOf(t))throw new o(t)})),0===s)s=a.length;else{l=(s-a.length%s)%s;const t=new Array(l).fill(this.decPadVal);r?a.unshift(...t):a.push(...t)}let h=new Array;for(let t=0,e=a.length;t=256;)[r,i]=this.divmod(r,256),n.unshift(parseInt(i,10));for(n.unshift(parseInt(r,10));n.length1){for(;!h[0];)h.shift();h.length||h.push(0),h.reverse()}}else if(this.bsDec){const t=this.padChars(l);h.splice(h.length-t)}return Uint8Array.from(h)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class h{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,n,...i){const r=this.utils.validateArgs(i);let[s,o,a]=this.utils.inputHandler.toBytes(t,r),l=null;e&&(l=e(r));let[h,u]=this.converter.encode(s,this.charsets[r.version],r.littleEndian,l);return r.signed&&(h=this.utils.toSignedStr(h,o)),r.upper&&(h=h.toUpperCase()),n&&(h=n({inputBytes:s,output:h,settings:r,zeroPadding:u,type:a})),this.utils.wrapOutput(h,r.options.lineWrap)}decode(t,e,n,i,...r){const s=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,i);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!s.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:s}));let a=this.converter.decode(t,this.charsets[s.version],this.padChars[s.version],s.integrity,s.littleEndian);return n&&(a=n({input:t,output:a,settings:s})),this.utils.outputHandler.compile(a,s.outputType,s.littleEndian,o)}} -/** - * [BaseEx|UTF8 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.5.0 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */return class extends h{constructor(...t){super(),this.converter=new l(10,0,0),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],this.version="default",this.frozenCharsets=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const n=this.utils.validateArgs(e),i=this.utils.inputHandler.toBytes(t,n)[0];let r=this.converter.encode(i,null,n.littleEndian)[0];return BigInt(r)}show(){}#i={a:1}}}(); diff --git a/dist/converters/Uuencode/uuencode.esm.js b/dist/converters/Uuencode/uuencode.esm.js index 2222f64..941dd3e 100644 --- a/dist/converters/Uuencode/uuencode.esm.js +++ b/dist/converters/Uuencode/uuencode.esm.js @@ -1451,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Uuencode/uuencode.esm.min.js b/dist/converters/Uuencode/uuencode.esm.min.js index 878eafa..3173d34 100644 --- a/dist/converters/Uuencode/uuencode.esm.min.js +++ b/dist/converters/Uuencode/uuencode.esm.min.js @@ -2,7 +2,7 @@ class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8A /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */class u extends l{constructor(...t){super(),this.converter=new h(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{const i=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||c()} ${e.options.file||d()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-n;t+=`${i.at(r)}${e.join("")}\n`;break}t+=`${i.at(45)}${e.join("")}\n`}return t+=`${i.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let n=0;return super.decode(t,(({input:t,settings:e})=>{const i=this.charsets[e.version],r=t.trim().split("\n"),s=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const e=[...t],r=i.indexOf(e.shift());if(!(r>0))break;if(s.push(...e),45!==r){n=this.converter.padChars(e.length)-r;break}}return s.join("")}),(({output:t})=>(n&&(t=new Uint8Array(t.slice(0,-n))),t)),!0,...e)}}const c=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},d=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};export{u as default}; diff --git a/dist/converters/Uuencode/uuencode.iife.js b/dist/converters/Uuencode/uuencode.iife.js index fb9e0c4..e592f91 100644 --- a/dist/converters/Uuencode/uuencode.iife.js +++ b/dist/converters/Uuencode/uuencode.iife.js @@ -1454,7 +1454,7 @@ var Uuencode = (function () { /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/converters/Uuencode/uuencode.iife.min.js b/dist/converters/Uuencode/uuencode.iife.min.js index c46eb8f..053c64a 100644 --- a/dist/converters/Uuencode/uuencode.iife.min.js +++ b/dist/converters/Uuencode/uuencode.iife.min.js @@ -2,7 +2,7 @@ var Uuencode=function(){"use strict";class t{static toBytes(t){return ArrayBuffe /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */const u=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},c=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};return class extends l{constructor(...t){super(),this.converter=new h(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:n})=>{const i=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||u()} ${e.options.file||c()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-n;t+=`${i.at(r)}${e.join("")}\n`;break}t+=`${i.at(45)}${e.join("")}\n`}return t+=`${i.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let n=0;return super.decode(t,(({input:t,settings:e})=>{const i=this.charsets[e.version],r=t.trim().split("\n"),s=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const e=[...t],r=i.indexOf(e.shift());if(!(r>0))break;if(s.push(...e),45!==r){n=this.converter.padChars(e.length)-r;break}}return s.join("")}),(({output:t})=>(n&&(t=new Uint8Array(t.slice(0,-n))),t)),!0,...e)}}}(); diff --git a/package-lock.json b/package-lock.json index dd61111..77c36d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "base-ex", - "version": "0.5.0", + "version": "0.5.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "base-ex", - "version": "0.5.0", + "version": "0.5.1", "license": "GPL-3.0", "bin": { "bx": "src/cli.js" diff --git a/package.json b/package.json index 226bdaf..39f6ddc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "base-ex", - "version": "0.5.0", + "version": "0.5.1", "description": "A collection of classes for data representation written in JavaScript.", "main": "./cjs/base-ex.cjs", "module": "./src/base-ex.js", diff --git a/src/base-ex.js b/src/base-ex.js index 580de1d..9a76269 100644 --- a/src/base-ex.js +++ b/src/base-ex.js @@ -1,7 +1,7 @@ /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/src/converters/base-1.js b/src/converters/base-1.js index 4a88e3e..258caad 100644 --- a/src/converters/base-1.js +++ b/src/converters/base-1.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-16.js b/src/converters/base-16.js index ca7320e..ce6a23b 100644 --- a/src/converters/base-16.js +++ b/src/converters/base-16.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-2048.js b/src/converters/base-2048.js index adc56cc..3c98fdf 100644 --- a/src/converters/base-2048.js +++ b/src/converters/base-2048.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-32.js b/src/converters/base-32.js index 2511e76..36fff63 100644 --- a/src/converters/base-32.js +++ b/src/converters/base-32.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-58.js b/src/converters/base-58.js index a2f100e..f135b86 100644 --- a/src/converters/base-58.js +++ b/src/converters/base-58.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-64.js b/src/converters/base-64.js index 88f5b2c..42e0ad0 100644 --- a/src/converters/base-64.js +++ b/src/converters/base-64.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-85.js b/src/converters/base-85.js index 7d906af..cafc169 100644 --- a/src/converters/base-85.js +++ b/src/converters/base-85.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/base-91.js b/src/converters/base-91.js index f0c3670..9bb4ed1 100644 --- a/src/converters/base-91.js +++ b/src/converters/base-91.js @@ -1,7 +1,7 @@ /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ diff --git a/src/converters/base-phi.js b/src/converters/base-phi.js index e8789de..29c4197 100644 --- a/src/converters/base-phi.js +++ b/src/converters/base-phi.js @@ -1,7 +1,7 @@ /** * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/byte-converter.js b/src/converters/byte-converter.js index d302c86..8f22ee6 100644 --- a/src/converters/byte-converter.js +++ b/src/converters/byte-converter.js @@ -1,7 +1,7 @@ /** * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/ecoji.js b/src/converters/ecoji.js index dd098d2..a8b1c0d 100644 --- a/src/converters/ecoji.js +++ b/src/converters/ecoji.js @@ -1,7 +1,7 @@ /** * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/ecoji.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 OR Apache-2.0 * @see https://github.com/keith-turner/ecoji diff --git a/src/converters/leb-128.js b/src/converters/leb-128.js index 31bc19a..9a4d760 100644 --- a/src/converters/leb-128.js +++ b/src/converters/leb-128.js @@ -1,7 +1,7 @@ /** * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/simple-base.js b/src/converters/simple-base.js index cc5ed85..ba59b41 100644 --- a/src/converters/simple-base.js +++ b/src/converters/simple-base.js @@ -1,7 +1,7 @@ /** * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/src/converters/uuencode.js b/src/converters/uuencode.js index 6fd3705..6f25df3 100644 --- a/src/converters/uuencode.js +++ b/src/converters/uuencode.js @@ -1,7 +1,7 @@ /** * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.5.0 + * @version 0.5.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */