@pfeiferio/custom-base 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encodeNumber.d.ts","sourceRoot":"","sources":["../src/encodeNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"encodeNumber.d.ts","sourceRoot":"","sources":["../src/encodeNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,OAAO,EAAgB,MAAM,cAAc,CAAC;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,GAAG,OAAO,KAAG,MAkBxE,CAAA"}
|
package/dist/encodeNumber.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ensureCharset } from "./Charset.js";
|
|
2
2
|
/**
|
|
3
3
|
* Converts an integer to a string representation in a custom base using a predefined charset.
|
|
4
4
|
* This function allows converting numbers into a string format based on any custom numeric system,
|
|
@@ -9,9 +9,9 @@ import { isCharset } from "./Charset.js";
|
|
|
9
9
|
* @return {string} The string representation of the integer in the custom base.
|
|
10
10
|
*/
|
|
11
11
|
export const encodeNumber = (number, charset) => {
|
|
12
|
-
|
|
13
|
-
const base =
|
|
14
|
-
const characters =
|
|
12
|
+
charset = ensureCharset(charset);
|
|
13
|
+
const base = charset.int.base;
|
|
14
|
+
const characters = charset.chars;
|
|
15
15
|
let result = '';
|
|
16
16
|
if (number < base) {
|
|
17
17
|
return characters.charAt(number);
|
package/dist/encodeNumber.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encodeNumber.js","sourceRoot":"","sources":["../src/encodeNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,
|
|
1
|
+
{"version":3,"file":"encodeNumber.js","sourceRoot":"","sources":["../src/encodeNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAC,MAAM,cAAc,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,OAAyB,EAAU,EAAE;IAEhF,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAA;IAEhC,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,IAAI,MAAM,GAAG,IAAI,EAAE,CAAC;QAClB,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;QAC5B,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAA;QAC1C,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/package.json
CHANGED