socket-function 0.92.0 → 0.94.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.92.0",
3
+ "version": "0.94.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -84,6 +84,7 @@ export class JSONLACKS {
84
84
  // then it is about 2X slower (although it depends on the size and complexity of the objects!)
85
85
  @measureFnc
86
86
  public static parse<T>(text: string, config?: JSONLACKS_ParseConfig, hydrateState?: HydrateState): T {
87
+ if (text.trim() === "undefined") return undefined as T;
87
88
  let obj: unknown;
88
89
 
89
90
  let extendedParsing = config?.extended ?? JSONLACKS.EXTENDED_PARSER;
@@ -1,3 +1,4 @@
1
+ import { isNode } from "../misc";
1
2
  import { hslToHex, hslToRGB } from "./colors";
2
3
 
3
4
  function ansiHSL(h: number, s: number, l: number, text: string): string {
@@ -5,7 +6,10 @@ function ansiHSL(h: number, s: number, l: number, text: string): string {
5
6
  return ansiRGB(r, g, b, text);
6
7
  }
7
8
  function ansiRGB(r: number, g: number, b: number, text: string): string {
8
- return `\x1b[38;5;${16 + (36 * Math.round(r / 255 * 5)) + (6 * Math.round(g / 255 * 5)) + Math.round(b / 255 * 5)}m${text}\x1b[0m`;
9
+ if (isNode()) {
10
+ return `\x1b[38;5;${16 + (36 * Math.round(r / 255 * 5)) + (6 * Math.round(g / 255 * 5)) + Math.round(b / 255 * 5)}m${text}\x1b[0m`;
11
+ }
12
+ return `\x1b[38;2;${r};${g};${b}m${text}\x1b[0m`;
9
13
  }
10
14
 
11
15
  const lightness = 68;