@calcit/procs 0.8.9 → 0.8.11

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,6 +1,5 @@
1
- var _a;
2
1
  // CALCIT VERSION
3
- export const calcit_version = "0.8.9";
2
+ export const calcit_version = "0.8.11";
4
3
  import { parse } from "@cirru/parser.ts";
5
4
  import { writeCirruCode } from "@cirru/writer.ts";
6
5
  import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
@@ -20,7 +19,7 @@ import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
20
19
  import { CalcitSet } from "./js-set.mjs";
21
20
  import { CalcitTuple } from "./js-tuple.mjs";
22
21
  import { to_calcit_data, extract_cirru_edn, CalcitCirruQuote } from "./js-cirru.mjs";
23
- let inNodeJs = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) === "node";
22
+ let inNodeJs = typeof process !== "undefined" && process?.release?.name === "node";
24
23
  export let type_of = (x) => {
25
24
  if (typeof x === "string") {
26
25
  return newTag("string");
@@ -904,7 +903,7 @@ export let get_env = (name, v0) => {
904
903
  if (v == null && v0 == null) {
905
904
  console.warn(`(get-env "${name}"): config not found`);
906
905
  }
907
- return v !== null && v !== void 0 ? v : v0;
906
+ return v ?? v0;
908
907
  };
909
908
  export let turn_tag = (x) => {
910
909
  if (typeof x === "string") {
@@ -1014,7 +1013,7 @@ export let _$n_str_$o_compare = (x, y) => {
1014
1013
  return 0;
1015
1014
  };
1016
1015
  export let arrayToList = (xs) => {
1017
- return new CalcitSliceList(xs !== null && xs !== void 0 ? xs : []);
1016
+ return new CalcitSliceList(xs ?? []);
1018
1017
  };
1019
1018
  export let listToArray = (xs) => {
1020
1019
  if (xs == null) {
@@ -1069,14 +1068,13 @@ export let buffer_$q_ = (x) => {
1069
1068
  };
1070
1069
  export let _$n_str_$o_escape = (x) => JSON.stringify(x);
1071
1070
  export let read_file = (path) => {
1072
- var _a;
1073
1071
  if (inNodeJs) {
1074
1072
  // TODO
1075
1073
  globalThis["__calcit_injections__"].read_file(path);
1076
1074
  }
1077
1075
  else {
1078
1076
  // no actual File API in browser
1079
- return (_a = localStorage.get(path)) !== null && _a !== void 0 ? _a : "";
1077
+ return localStorage.get(path) ?? "";
1080
1078
  }
1081
1079
  };
1082
1080
  export let write_file = (path, content) => {
@@ -1258,12 +1256,16 @@ function lookup_class(obj) {
1258
1256
  klass = calcit_builtin_classes.map;
1259
1257
  }
1260
1258
  else {
1261
- throw new Error("Cannot find class for this object for invoking");
1259
+ return null;
1262
1260
  }
1263
1261
  return [klass, tag];
1264
1262
  }
1265
1263
  export function invoke_method(p, obj, ...args) {
1266
- let [klass, tag] = lookup_class(obj);
1264
+ let pair = lookup_class(obj);
1265
+ if (pair == null) {
1266
+ throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
1267
+ }
1268
+ let [klass, tag] = pair;
1267
1269
  let method = klass.getOrNil(p);
1268
1270
  if (method == null) {
1269
1271
  throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd) => fd.value).join(" ")}`);
@@ -126,6 +126,19 @@ export let load_console_formatter_$x_ = () => {
126
126
  if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
127
127
  let ret = ["div", { style: "color: hsl(280, 80%, 60%)" }];
128
128
  let pairs = obj.pairs();
129
+ pairs.sort((pa, pb) => {
130
+ let ka = pa[0].toString();
131
+ let kb = pb[0].toString();
132
+ if (ka < kb) {
133
+ return -1;
134
+ }
135
+ else if (ka > kb) {
136
+ return 1;
137
+ }
138
+ else {
139
+ return 0;
140
+ }
141
+ });
129
142
  for (let idx = 0; idx < pairs.length; idx++) {
130
143
  let [k, v] = pairs[idx];
131
144
  ret.push([
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.8.9",
3
+ "version": "0.8.11",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
- "@types/node": "^20.8.6",
7
- "typescript": "^5.2.2"
6
+ "@types/node": "^20.9.4",
7
+ "typescript": "^5.3.2"
8
8
  },
9
9
  "scripts": {
10
10
  "compile": "rm -rfv lib/* && tsc",
@@ -0,0 +1,3 @@
1
+
2
+ [toolchain]
3
+ channel = "nightly"
@@ -1,5 +1,5 @@
1
1
  // CALCIT VERSION
2
- export const calcit_version = "0.8.9";
2
+ export const calcit_version = "0.8.11";
3
3
 
4
4
  import { parse, ICirruNode } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
@@ -1348,13 +1348,17 @@ function lookup_class(obj: CalcitValue): [CalcitRecord, string] {
1348
1348
  tag = "&core-map-class";
1349
1349
  klass = calcit_builtin_classes.map;
1350
1350
  } else {
1351
- throw new Error("Cannot find class for this object for invoking");
1351
+ return null;
1352
1352
  }
1353
1353
  return [klass, tag];
1354
1354
  }
1355
1355
 
1356
1356
  export function invoke_method(p: string, obj: CalcitValue, ...args: CalcitValue[]) {
1357
- let [klass, tag] = lookup_class(obj);
1357
+ let pair = lookup_class(obj);
1358
+ if (pair == null) {
1359
+ throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
1360
+ }
1361
+ let [klass, tag] = pair;
1358
1362
  let method = klass.getOrNil(p);
1359
1363
  if (method == null) {
1360
1364
  throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd: CalcitTag) => fd.value).join(" ")}`);
@@ -143,6 +143,17 @@ export let load_console_formatter_$x_ = () => {
143
143
  if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
144
144
  let ret: any[] = ["div", { style: "color: hsl(280, 80%, 60%)" }];
145
145
  let pairs = obj.pairs();
146
+ pairs.sort((pa, pb) => {
147
+ let ka = pa[0].toString();
148
+ let kb = pb[0].toString();
149
+ if (ka < kb) {
150
+ return -1;
151
+ } else if (ka > kb) {
152
+ return 1;
153
+ } else {
154
+ return 0;
155
+ }
156
+ });
146
157
  for (let idx = 0; idx < pairs.length; idx++) {
147
158
  let [k, v] = pairs[idx];
148
159
  ret.push([