@thi.ng/base-n
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -16,3 +16,3 @@ import { U8 } from "@thi.ng/hex"; | ||
res = base[x % N] + res; | ||
x = (x / N) | 0; | ||
x = Math.floor(x / N); | ||
} | ||
@@ -19,0 +19,0 @@ return res; |
@@ -6,34 +6,13 @@ # Change Log | ||
## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@1.0.3...@thi.ng/base-n@1.0.4) (2021-08-17) | ||
## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@1.0.4...@thi.ng/base-n@1.0.5) (2021-08-24) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
### Bug Fixes | ||
* **base-n:** fix [#308](https://github.com/thi-ng/umbrella/issues/308), remove unintentional int cast ([27a0d7e](https://github.com/thi-ng/umbrella/commit/27a0d7e5052d6c40b247bfe4ef8c1611b9907a6a)) | ||
## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@1.0.2...@thi.ng/base-n@1.0.3) (2021-08-08) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@1.0.1...@thi.ng/base-n@1.0.2) (2021-08-08) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@0.2.0...@thi.ng/base-n@1.0.1) (2021-08-08) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@0.1.8...@thi.ng/base-n@0.2.0) (2021-08-07) | ||
@@ -50,18 +29,2 @@ | ||
## [0.1.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@0.1.7...@thi.ng/base-n@0.1.8) (2021-07-01) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
## [0.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/base-n@0.1.6...@thi.ng/base-n@0.1.7) (2021-06-08) | ||
**Note:** Version bump only for package @thi.ng/base-n | ||
# 0.1.0 (2021-01-13) | ||
@@ -68,0 +31,0 @@ |
@@ -21,3 +21,3 @@ 'use strict'; | ||
res = base[x % N] + res; | ||
x = (x / N) | 0; | ||
x = Math.floor(x / N); | ||
} | ||
@@ -24,0 +24,0 @@ return res; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/hex")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/hex"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.baseN={}),e.thi.ng.hex)}(this,(function(e,t){"use strict";const n=e=>new i(e);class i{constructor(e){this.base=e,this.N=e.length,this.index=[...e].reduce(((e,t,n)=>(e[t]=n,e)),{})}encode(e){const{base:t,N:n}=this;if(0===e)return t[0];let i="";for(;e>0;)i=t[e%n]+i,e=e/n|0;return i}encodeBigInt(e){if(e<BigInt(2**53))return this.encode(Number(e));const{base:t,N:n}=this;if(e===BigInt(0))return t[0];const i=BigInt(n);let s="";for(;e>0;)s=t[Number(e%i)]+s,e/=i;return s}encodeBytes(e){let n="";for(let i=0,s=e.length;i<s;i++)n+=t.U8(e[i]);return this.encodeBigInt(BigInt(`0x${n}`))}decode(e){const{index:t,N:n}=this;let i=0;for(let s=e.length-1,o=0;o<=s;o++)i+=t[e[o]]*n**(s-o);return i}decodeBigInt(e){const{index:t,N:n}=this,i=BigInt(n);let s=BigInt(0);for(let n=e.length-1,o=0;o<=n;o++)s+=BigInt(t[e[o]])*i**BigInt(n-o);return s}decodeBytes(e,t){let n=this.decodeBigInt(e);const i=BigInt(255),s=BigInt(8);for(let e=t.length;--e>=0;)t[e]=Number(n&i),n>>=s;return t}validate(e){return new RegExp(`^[${this.base}]+$`).test(e)}size(e){return Math.ceil(Math.log(e)/Math.log(this.N))}}const s=n("0123456789ABCDEF"),o=n("0123456789abcdef"),r=n("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),B=n("0123456789ABCDEFGHIJKLMNOPQRSTUV"),h=n("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),d="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",g=n(d),c="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",l=n(c),u=d+"abcdefghijklmnopqrstuvwxyz",f=n(u),a=u+"+/",A=n(a),S=n("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~");e.B36_CHARS=d,e.B58_CHARS=c,e.B62_CHARS=u,e.B64_CHARS=a,e.BASE16_LC=o,e.BASE16_UC=s,e.BASE32_CROCKFORD=h,e.BASE32_HEX=B,e.BASE32_RFC4648=r,e.BASE36=g,e.BASE58=l,e.BASE62=f,e.BASE64=A,e.BASE85=S,e.BaseN=i,e.defBase=n,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/hex")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/hex"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.baseN={}),e.thi.ng.hex)}(this,(function(e,t){"use strict";const n=e=>new i(e);class i{constructor(e){this.base=e,this.N=e.length,this.index=[...e].reduce(((e,t,n)=>(e[t]=n,e)),{})}encode(e){const{base:t,N:n}=this;if(0===e)return t[0];let i="";for(;e>0;)i=t[e%n]+i,e=Math.floor(e/n);return i}encodeBigInt(e){if(e<BigInt(2**53))return this.encode(Number(e));const{base:t,N:n}=this;if(e===BigInt(0))return t[0];const i=BigInt(n);let o="";for(;e>0;)o=t[Number(e%i)]+o,e/=i;return o}encodeBytes(e){let n="";for(let i=0,o=e.length;i<o;i++)n+=t.U8(e[i]);return this.encodeBigInt(BigInt(`0x${n}`))}decode(e){const{index:t,N:n}=this;let i=0;for(let o=e.length-1,s=0;s<=o;s++)i+=t[e[s]]*n**(o-s);return i}decodeBigInt(e){const{index:t,N:n}=this,i=BigInt(n);let o=BigInt(0);for(let n=e.length-1,s=0;s<=n;s++)o+=BigInt(t[e[s]])*i**BigInt(n-s);return o}decodeBytes(e,t){let n=this.decodeBigInt(e);const i=BigInt(255),o=BigInt(8);for(let e=t.length;--e>=0;)t[e]=Number(n&i),n>>=o;return t}validate(e){return new RegExp(`^[${this.base}]+$`).test(e)}size(e){return Math.ceil(Math.log(e)/Math.log(this.N))}}const o=n("0123456789ABCDEF"),s=n("0123456789abcdef"),r=n("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),B=n("0123456789ABCDEFGHIJKLMNOPQRSTUV"),h=n("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),d="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",g=n(d),c="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",l=n(c),f=d+"abcdefghijklmnopqrstuvwxyz",u=n(f),a=f+"+/",A=n(a),S=n("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~");e.B36_CHARS=d,e.B58_CHARS=c,e.B62_CHARS=f,e.B64_CHARS=a,e.BASE16_LC=s,e.BASE16_UC=o,e.BASE32_CROCKFORD=h,e.BASE32_HEX=B,e.BASE32_RFC4648=r,e.BASE36=g,e.BASE58=l,e.BASE62=u,e.BASE64=A,e.BASE85=S,e.BaseN=i,e.defBase=n,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/base-n", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Arbitrary base-n conversions w/ presets for base16/32/36/58/62/64/85, support for arrays & bigints", | ||
@@ -72,3 +72,3 @@ "module": "./index.js", | ||
}, | ||
"gitHead": "3365151f112c39f224541f5ac4cedf3370eb9ba4" | ||
"gitHead": "b6baa4829554847fef1e3980ed8f2767202d44f9" | ||
} |
@@ -44,3 +44,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 811 bytes / CJS: 919 bytes / UMD: 995 bytes | ||
Package sizes (gzipped, pre-treeshake): ESM: 817 bytes / CJS: 925 bytes / UMD: 1001 bytes | ||
@@ -47,0 +47,0 @@ ## Dependencies |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38784