compress-json
Advanced tools
Comparing version 1.0.4 to 1.0.5
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.test = exports.bool_to_s = exports.s_to_bool = void 0; | ||
function s_to_bool(s) { | ||
@@ -4,0 +5,0 @@ switch (s) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.config = void 0; | ||
exports.config = { | ||
sort_key: false, | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decompress = exports.decode = exports.compress = void 0; | ||
const debug_1 = require("./debug"); | ||
@@ -4,0 +5,0 @@ const encode_1 = require("./encode"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.throwUnknownDataType = exports.getType = void 0; | ||
function getType(o) { | ||
@@ -4,0 +5,0 @@ return Object.prototype.toString.call(o); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodeStr = exports.encodeStr = exports.decodeBool = exports.encodeBool = exports.decodeKey = exports.decodeNum = exports.encodeNum = void 0; | ||
const number_1 = require("./number"); | ||
@@ -4,0 +5,0 @@ function encodeNum(num) { |
@@ -5,8 +5,8 @@ "use strict"; | ||
var core_1 = require("./core"); | ||
exports.compress = core_1.compress; | ||
exports.decompress = core_1.decompress; | ||
Object.defineProperty(exports, "compress", { enumerable: true, get: function () { return core_1.compress; } }); | ||
Object.defineProperty(exports, "decompress", { enumerable: true, get: function () { return core_1.decompress; } }); | ||
/* for custom wrapper */ | ||
var core_2 = require("./core"); | ||
exports.decode = core_2.decode; | ||
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return core_2.decode; } }); | ||
var memory_1 = require("./memory"); | ||
exports.addValue = memory_1.addValue; | ||
Object.defineProperty(exports, "addValue", { enumerable: true, get: function () { return memory_1.addValue; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addValue = exports.makeInMemoryMemory = exports.makeInMemoryCache = exports.makeInMemoryStore = exports.memToValues = void 0; | ||
const config_1 = require("./config"); | ||
@@ -4,0 +5,0 @@ const debug_1 = require("./debug"); |
export declare function s_to_int(s: string): number; | ||
export declare function s_to_big_int(s: string): bigint; | ||
export declare function int_to_s(int: number): string; | ||
export declare function big_int_to_s(int: bigint): string; | ||
export declare function num_to_s(num: number): string; | ||
export declare function int_str_to_s(int_str: string): string; | ||
export declare function s_to_num(s: string): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.s_to_num = exports.int_str_to_s = exports.num_to_s = exports.big_int_to_s = exports.int_to_s = exports.s_to_big_int = exports.s_to_int = void 0; | ||
let i_to_s = ''; | ||
@@ -35,2 +36,16 @@ for (let i = 0; i < 10; i++) { | ||
exports.s_to_int = s_to_int; | ||
function s_to_big_int(s) { | ||
let acc = BigInt(0); | ||
let pow = BigInt(1); | ||
const n = BigInt(N); | ||
for (let i = s.length - 1; i >= 0; i--) { | ||
const c = s[i]; | ||
let x = BigInt(s_to_i[c]); | ||
x *= pow; | ||
acc += x; | ||
pow *= n; | ||
} | ||
return acc; | ||
} | ||
exports.s_to_big_int = s_to_big_int; | ||
function int_to_s(int) { | ||
@@ -51,2 +66,19 @@ if (int === 0) { | ||
exports.int_to_s = int_to_s; | ||
function big_int_to_s(int) { | ||
const zero = BigInt(0); | ||
const n = BigInt(N); | ||
if (int === zero) { | ||
return i_to_s[0]; | ||
} | ||
const acc = []; | ||
while (int !== zero) { | ||
const i = int % n; | ||
const c = i_to_s[Number(i)]; | ||
acc.push(c); | ||
int -= i; | ||
int /= n; | ||
} | ||
return acc.reverse().join(''); | ||
} | ||
exports.big_int_to_s = big_int_to_s; | ||
function reverse(s) { | ||
@@ -63,8 +95,22 @@ return s.split('').reverse().join(''); | ||
} | ||
a = int_to_s(+a); | ||
a = int_str_to_s(a); | ||
b = reverse(b); | ||
b = int_to_s(+b); | ||
b = int_str_to_s(b); | ||
return a + '.' + b; | ||
} | ||
exports.num_to_s = num_to_s; | ||
function int_str_to_s(int_str) { | ||
const num = +int_str; | ||
if (num.toString() === int_str) { | ||
return int_to_s(num); | ||
} | ||
return ':' + big_int_to_s(BigInt(int_str)); | ||
} | ||
exports.int_str_to_s = int_str_to_s; | ||
function s_to_int_str(s) { | ||
if (s[0] === ':') { | ||
return s_to_big_int(s.substring(1)).toString(); | ||
} | ||
return s_to_int(s).toString(); | ||
} | ||
function s_to_num(s) { | ||
@@ -78,4 +124,4 @@ if (s[0] === '-') { | ||
} | ||
a = s_to_int(a).toString(); | ||
b = s_to_int(b).toString(); | ||
a = s_to_int_str(a); | ||
b = s_to_int_str(b); | ||
b = reverse(b); | ||
@@ -82,0 +128,0 @@ return +(a + '.' + b); |
{ | ||
"name": "compress-json", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "convert JSON data to space efficient format", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
23174
532