Socket
Socket
Sign inDemoInstall

@thi.ng/base-n

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/base-n - npm Package Compare versions

Comparing version 2.5.25 to 2.6.0

83.d.ts

3

base.d.ts

@@ -9,3 +9,5 @@ import type { IBase } from "./api.js";

readonly index: Record<string, number>;
private __pc;
constructor(base: string);
clear(): void;
encode(x: number, size?: number): string;

@@ -19,3 +21,4 @@ encodeBigInt(x: bigint, size?: number): string;

size(x: number): number;
private __pad;
}
//# sourceMappingURL=base.d.ts.map

20

base.js

@@ -18,6 +18,10 @@ const defBase = (chars) => new BaseN(chars);

index;
__pc = [];
clear() {
this.__pc.length = 0;
}
encode(x, size = 0) {
const { base, N } = this;
if (x === 0)
return __pad(base[0], size, base[0]);
return this.__pad(base[0], size);
let res = "";

@@ -28,3 +32,3 @@ while (x > 0) {

}
return __pad(res, size, base[0]);
return this.__pad(res, size);
}

@@ -36,3 +40,3 @@ encodeBigInt(x, size = 0) {

if (x === ZERO)
return __pad(base[0], size, base[0]);
return this.__pad(base[0], size);
const NN = BigInt(N);

@@ -44,3 +48,3 @@ let res = "";

}
return __pad(res, size, base[0]);
return this.__pad(res, size);
}

@@ -84,7 +88,7 @@ encodeBytes(buf, size = 0) {

}
__pad(x, size) {
const d = size - x.length;
return d > 0 ? (this.__pc[d] || (this.__pc[d] = this.base[0].repeat(d))) + x : x;
}
}
const __pad = (x, size, fill) => {
const d = size - x.length;
return d > 0 ? fill.repeat(d) + x : x;
};
const __u8 = (x) => __B16_LC_CHARS[x >>> 4 & 15] + __B16_LC_CHARS[x & 15];

@@ -91,0 +95,0 @@ export {

# Change Log
- **Last updated**: 2024-01-23T15:58:27Z
- **Last updated**: 2024-01-26T18:03:04Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,15 @@

## [2.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/base-n@2.6.0) (2024-01-26)
#### 🚀 Features
- add base83 chars & preset ([5e09baf](https://github.com/thi-ng/umbrella/commit/5e09baf))
- add `B83_CHARS` and `BASE83`
#### ⏱ Performance improvements
- memoize value padding (encoding w/ size) ([62ccf80](https://github.com/thi-ng/umbrella/commit/62ccf80))
- migrate padding into BaseN class
- add BaseN.clear() for clearing memoization cache
### [2.5.11](https://github.com/thi-ng/umbrella/tree/@thi.ng/base-n@2.5.11) (2023-08-14)

@@ -14,0 +27,0 @@

@@ -10,3 +10,4 @@ export * from "./api.js";

export * from "./64.js";
export * from "./83.js";
export * from "./85.js";
//# sourceMappingURL=index.d.ts.map

@@ -10,2 +10,3 @@ export * from "./api.js";

export * from "./64.js";
export * from "./83.js";
export * from "./85.js";
{
"name": "@thi.ng/base-n",
"version": "2.5.25",
"description": "Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/85, support for bigints and encoding/decoding of byte arrays",
"version": "2.6.0",
"description": "Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/83/85, support for bigints and encoding/decoding of byte arrays",
"type": "module",

@@ -97,2 +97,5 @@ "module": "./index.js",

},
"./83": {
"default": "./83.js"
},
"./85": {

@@ -111,3 +114,3 @@ "default": "./85.js"

},
"gitHead": "417b5a7ea7bd54a3b4f086fe0fc2ce8e8933c9b2\n"
"gitHead": "7426e2ae6fca5482c6eaf649872296fc89955374\n"
}

@@ -24,3 +24,3 @@ <!-- This file is generated - DO NOT EDIT! -->

Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/85, support for bigints and encoding/decoding of byte arrays.
Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/83/85, support for bigints and encoding/decoding of byte arrays.

@@ -56,3 +56,3 @@ In addition to the actual converters/encoders, the package also provides the

Package sizes (brotli'd, pre-treeshake): ESM: 1.01 KB
Package sizes (brotli'd, pre-treeshake): ESM: 1.07 KB

@@ -59,0 +59,0 @@ ## Dependencies

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc