@rsdoctor/utils 0.3.10-beta.0 → 0.3.10-beta.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,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var algorithm_exports = {};
20
30
  __export(algorithm_exports, {
@@ -24,8 +34,8 @@ __export(algorithm_exports, {
24
34
  random: () => random
25
35
  });
26
36
  module.exports = __toCommonJS(algorithm_exports);
27
- var import_zlib = require("zlib");
28
37
  var import_buffer = require("buffer");
38
+ var import_lz4 = __toESM(require("lz4"));
29
39
  function mergeIntervals(intervals) {
30
40
  intervals.sort((a, b) => a[0] - b[0]);
31
41
  let previous;
@@ -43,10 +53,18 @@ function mergeIntervals(intervals) {
43
53
  return result;
44
54
  }
45
55
  function compressText(input) {
46
- return (0, import_zlib.deflateSync)(input).toString("base64");
56
+ const inputBuffer = import_buffer.Buffer.from(input);
57
+ let output = import_buffer.Buffer.alloc(import_lz4.default.encodeBound(input.length));
58
+ const compressedSize = import_lz4.default.encodeBlock(inputBuffer, output);
59
+ output = output.slice(0, compressedSize);
60
+ return output.toString("base64");
47
61
  }
48
62
  function decompressText(input) {
49
- return (0, import_zlib.inflateSync)(import_buffer.Buffer.from(input, "base64")).toString();
63
+ let uncompressedBlock = import_buffer.Buffer.alloc(input.length * 10);
64
+ const inputBuffer = import_buffer.Buffer.from(input, "base64");
65
+ const uncompressedSize = import_lz4.default.decodeBlock(inputBuffer, uncompressedBlock);
66
+ uncompressedBlock = uncompressedBlock.slice(0, uncompressedSize);
67
+ return uncompressedBlock.toString("utf-8");
50
68
  }
51
69
  function random(min, max) {
52
70
  return Math.floor(Math.random() * (max - min + 1) + min);
@@ -1,5 +1,5 @@
1
- import { deflateSync, inflateSync } from "zlib";
2
1
  import { Buffer } from "buffer";
2
+ import lz4 from "lz4";
3
3
  function mergeIntervals(intervals) {
4
4
  intervals.sort((a, b) => a[0] - b[0]);
5
5
  let previous;
@@ -17,10 +17,18 @@ function mergeIntervals(intervals) {
17
17
  return result;
18
18
  }
19
19
  function compressText(input) {
20
- return deflateSync(input).toString("base64");
20
+ const inputBuffer = Buffer.from(input);
21
+ let output = Buffer.alloc(lz4.encodeBound(input.length));
22
+ const compressedSize = lz4.encodeBlock(inputBuffer, output);
23
+ output = output.slice(0, compressedSize);
24
+ return output.toString("base64");
21
25
  }
22
26
  function decompressText(input) {
23
- return inflateSync(Buffer.from(input, "base64")).toString();
27
+ let uncompressedBlock = Buffer.alloc(input.length * 10);
28
+ const inputBuffer = Buffer.from(input, "base64");
29
+ const uncompressedSize = lz4.decodeBlock(inputBuffer, uncompressedBlock);
30
+ uncompressedBlock = uncompressedBlock.slice(0, uncompressedSize);
31
+ return uncompressedBlock.toString("utf-8");
24
32
  }
25
33
  function random(min, max) {
26
34
  return Math.floor(Math.random() * (max - min + 1) + min);
@@ -1 +1 @@
1
- {"version":3,"file":"algorithm.d.ts","sourceRoot":"","sources":["../../../src/common/algorithm.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,sBAqB3D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE9C"}
1
+ {"version":3,"file":"algorithm.d.ts","sourceRoot":"","sources":["../../../src/common/algorithm.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,sBAqB3D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOlD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/utils",
3
- "version": "0.3.10-beta.0",
3
+ "version": "0.3.10-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -82,9 +82,10 @@
82
82
  "json-stream-stringify": "3.0.1",
83
83
  "lines-and-columns": "2.0.4",
84
84
  "lodash": "^4.17.21",
85
+ "lz4": "^0.6.5",
85
86
  "rslog": "^1.2.0",
86
87
  "strip-ansi": "^6.0.1",
87
- "@rsdoctor/types": "0.3.10-beta.0"
88
+ "@rsdoctor/types": "0.3.10-beta.1"
88
89
  },
89
90
  "devDependencies": {
90
91
  "@types/babel__code-frame": "7.0.3",
@@ -93,6 +94,7 @@
93
94
  "@types/envinfo": "7.8.4",
94
95
  "@types/fs-extra": "^11.0.2",
95
96
  "@types/lodash": "^4.17.0",
97
+ "@types/lz4": "^0.6.4",
96
98
  "@types/node": "^16",
97
99
  "tslib": "2.4.1",
98
100
  "typescript": "^5.2.2"