@rsdoctor/utils
Advanced tools
Comparing version 0.3.10-beta.0 to 0.3.10-beta.1
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,10 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -28,4 +38,4 @@ var algorithm_exports = {}; | ||
module.exports = __toCommonJS(algorithm_exports); | ||
var import_zlib = require("zlib"); | ||
var import_buffer = require("buffer"); | ||
var import_lz4 = __toESM(require("lz4")); | ||
function mergeIntervals(intervals) { | ||
@@ -48,6 +58,14 @@ intervals.sort((a, b) => a[0] - b[0]); | ||
function compressText(input) { | ||
return (0, import_zlib.deflateSync)(input).toString("base64"); | ||
const inputBuffer = import_buffer.Buffer.from(input); | ||
let output = import_buffer.Buffer.alloc(import_lz4.default.encodeBound(input.length)); | ||
const compressedSize = import_lz4.default.encodeBlock(inputBuffer, output); | ||
output = output.slice(0, compressedSize); | ||
return output.toString("base64"); | ||
} | ||
function decompressText(input) { | ||
return (0, import_zlib.inflateSync)(import_buffer.Buffer.from(input, "base64")).toString(); | ||
let uncompressedBlock = import_buffer.Buffer.alloc(input.length * 10); | ||
const inputBuffer = import_buffer.Buffer.from(input, "base64"); | ||
const uncompressedSize = import_lz4.default.decodeBlock(inputBuffer, uncompressedBlock); | ||
uncompressedBlock = uncompressedBlock.slice(0, uncompressedSize); | ||
return uncompressedBlock.toString("utf-8"); | ||
} | ||
@@ -54,0 +72,0 @@ function random(min, max) { |
@@ -1,3 +0,3 @@ | ||
import { deflateSync, inflateSync } from "zlib"; | ||
import { Buffer } from "buffer"; | ||
import lz4 from "lz4"; | ||
function mergeIntervals(intervals) { | ||
@@ -20,6 +20,14 @@ intervals.sort((a, b) => a[0] - b[0]); | ||
function compressText(input) { | ||
return deflateSync(input).toString("base64"); | ||
const inputBuffer = Buffer.from(input); | ||
let output = Buffer.alloc(lz4.encodeBound(input.length)); | ||
const compressedSize = lz4.encodeBlock(inputBuffer, output); | ||
output = output.slice(0, compressedSize); | ||
return output.toString("base64"); | ||
} | ||
function decompressText(input) { | ||
return inflateSync(Buffer.from(input, "base64")).toString(); | ||
let uncompressedBlock = Buffer.alloc(input.length * 10); | ||
const inputBuffer = Buffer.from(input, "base64"); | ||
const uncompressedSize = lz4.decodeBlock(inputBuffer, uncompressedBlock); | ||
uncompressedBlock = uncompressedBlock.slice(0, uncompressedSize); | ||
return uncompressedBlock.toString("utf-8"); | ||
} | ||
@@ -26,0 +34,0 @@ function random(min, max) { |
{ | ||
"name": "@rsdoctor/utils", | ||
"version": "0.3.10-beta.0", | ||
"version": "0.3.10-beta.1", | ||
"repository": { | ||
@@ -85,5 +85,6 @@ "type": "git", | ||
"lodash": "^4.17.21", | ||
"lz4": "^0.6.5", | ||
"rslog": "^1.2.0", | ||
"strip-ansi": "^6.0.1", | ||
"@rsdoctor/types": "0.3.10-beta.0" | ||
"@rsdoctor/types": "0.3.10-beta.1" | ||
}, | ||
@@ -97,2 +98,3 @@ "devDependencies": { | ||
"@types/lodash": "^4.17.0", | ||
"@types/lz4": "^0.6.4", | ||
"@types/node": "^16", | ||
@@ -99,0 +101,0 @@ "tslib": "2.4.1", |
Sorry, the diff of this file is not supported yet
287788
7211
19
10
+ Addedlz4@^0.6.5
+ Added@rsdoctor/types@0.3.10-beta.1(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcuint@0.2.2(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedlz4@0.6.5(transitive)
+ Addednan@2.22.2(transitive)
+ Addedxxhashjs@0.2.2(transitive)
- Removed@rsdoctor/types@0.3.10-beta.0(transitive)