@calcit/procs 0.6.30 → 0.7.0-a2

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.
@@ -10,12 +10,12 @@ import { CalcitTuple } from "./js-tuple.mjs";
10
10
  import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
11
11
  // we have to inject cache in a dirty way in some cases
12
12
  const calcit_dirty_hash_key = "_calcit_cached_hash";
13
- let keywordIdx = 0;
14
- export class CalcitKeyword {
13
+ let tagIdx = 0;
14
+ export class CalcitTag {
15
15
  constructor(x) {
16
16
  this.value = x;
17
- this.idx = keywordIdx;
18
- keywordIdx++;
17
+ this.idx = tagIdx;
18
+ tagIdx++;
19
19
  this.cachedHash = null;
20
20
  }
21
21
  toString() {
@@ -96,7 +96,7 @@ export let getStringName = (x) => {
96
96
  if (typeof x === "string") {
97
97
  return x;
98
98
  }
99
- if (x instanceof CalcitKeyword) {
99
+ if (x instanceof CalcitTag) {
100
100
  return x.value;
101
101
  }
102
102
  if (x instanceof CalcitSymbol) {
@@ -127,35 +127,35 @@ export function findInFields(xs, y) {
127
127
  return upper;
128
128
  return -1;
129
129
  }
130
- var keywordRegistery = {};
131
- export let kwd = (content) => {
132
- let item = keywordRegistery[content];
130
+ var tagRegistery = {};
131
+ export let newTag = (content) => {
132
+ let item = tagRegistery[content];
133
133
  if (item != null) {
134
134
  return item;
135
135
  }
136
136
  else {
137
- let v = new CalcitKeyword(content);
138
- keywordRegistery[content] = v;
137
+ let v = new CalcitTag(content);
138
+ tagRegistery[content] = v;
139
139
  return v;
140
140
  }
141
141
  };
142
- export let castKwd = (x) => {
143
- if (x instanceof CalcitKeyword) {
142
+ export let castTag = (x) => {
143
+ if (x instanceof CalcitTag) {
144
144
  return x;
145
145
  }
146
146
  if (typeof x === "string") {
147
- return kwd(x);
147
+ return newTag(x);
148
148
  }
149
149
  if (x instanceof CalcitSymbol) {
150
- return kwd(x.value);
150
+ return newTag(x.value);
151
151
  }
152
- throw new Error(`Cannot cast this to keyword: ${x}`);
152
+ throw new Error(`Cannot cast this to tag: ${x}`);
153
153
  };
154
154
  export var refsRegistry = new Map();
155
155
  let defaultHash_nil = valueHash("nil:");
156
156
  let defaultHash_number = valueHash("number:");
157
157
  let defaultHash_string = valueHash("string:");
158
- let defaultHash_keyword = valueHash("keyword:");
158
+ let defaultHash_tag = valueHash("tag:");
159
159
  let defaultHash_true = valueHash("bool:true");
160
160
  let defaultHash_false = valueHash("bool:false");
161
161
  let defaultHash_symbol = valueHash("symbol:");
@@ -187,8 +187,8 @@ export let hashFunction = (x) => {
187
187
  if (x[calcit_dirty_hash_key] != null) {
188
188
  return x[calcit_dirty_hash_key];
189
189
  }
190
- if (x instanceof CalcitKeyword) {
191
- let h = mergeValueHash(defaultHash_keyword, x.idx);
190
+ if (x instanceof CalcitTag) {
191
+ let h = mergeValueHash(defaultHash_tag, x.idx);
192
192
  x.cachedHash = h;
193
193
  return h;
194
194
  }
@@ -345,7 +345,7 @@ export let toString = (x, escaped, disableJsDataWarning = false) => {
345
345
  if (x instanceof CalcitSymbol) {
346
346
  return x.toString();
347
347
  }
348
- if (x instanceof CalcitKeyword) {
348
+ if (x instanceof CalcitTag) {
349
349
  return x.toString();
350
350
  }
351
351
  if (x instanceof CalcitList || x instanceof CalcitSliceList) {
@@ -390,7 +390,7 @@ export let to_js_data = (x, addColon = false) => {
390
390
  if (typeof x === "function") {
391
391
  return x;
392
392
  }
393
- if (x instanceof CalcitKeyword) {
393
+ if (x instanceof CalcitTag) {
394
394
  if (addColon) {
395
395
  return `:${x.value}`;
396
396
  }
@@ -477,8 +477,8 @@ export let _$n__$e_ = (x, y) => {
477
477
  // comparing functions by reference
478
478
  return x === y;
479
479
  }
480
- if (x instanceof CalcitKeyword) {
481
- if (y instanceof CalcitKeyword) {
480
+ if (x instanceof CalcitTag) {
481
+ if (y instanceof CalcitTag) {
482
482
  return x === y;
483
483
  }
484
484
  return false;
@@ -1,9 +1,9 @@
1
1
  var _a;
2
2
  // CALCIT VERSION
3
- export const calcit_version = "0.6.30";
3
+ export const calcit_version = "0.7.0-a2";
4
4
  import { parse } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
6
- import { CalcitSymbol, CalcitKeyword, CalcitRef, CalcitRecur, kwd, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
6
+ import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
7
7
  import { CalcitRecord } from "./js-record.mjs";
8
8
  export * from "./calcit-data.mjs";
9
9
  export * from "./js-record.mjs";
@@ -23,53 +23,53 @@ import { to_calcit_data, extract_cirru_edn, CalcitCirruQuote } from "./js-cirru.
23
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";
24
24
  export let type_of = (x) => {
25
25
  if (typeof x === "string") {
26
- return kwd("string");
26
+ return newTag("string");
27
27
  }
28
28
  if (typeof x === "number") {
29
- return kwd("number");
29
+ return newTag("number");
30
30
  }
31
- if (x instanceof CalcitKeyword) {
32
- return kwd("keyword");
31
+ if (x instanceof CalcitTag) {
32
+ return newTag("tag");
33
33
  }
34
34
  if (x instanceof CalcitList || x instanceof CalcitSliceList) {
35
- return kwd("list");
35
+ return newTag("list");
36
36
  }
37
37
  if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
38
- return kwd("map");
38
+ return newTag("map");
39
39
  }
40
40
  if (x == null) {
41
- return kwd("nil");
41
+ return newTag("nil");
42
42
  }
43
43
  if (x instanceof CalcitRef) {
44
- return kwd("ref");
44
+ return newTag("ref");
45
45
  }
46
46
  if (x instanceof CalcitTuple) {
47
- return kwd("tuple");
47
+ return newTag("tuple");
48
48
  }
49
49
  if (x instanceof CalcitSymbol) {
50
- return kwd("symbol");
50
+ return newTag("symbol");
51
51
  }
52
52
  if (x instanceof CalcitSet) {
53
- return kwd("set");
53
+ return newTag("set");
54
54
  }
55
55
  if (x instanceof CalcitRecord) {
56
- return kwd("record");
56
+ return newTag("record");
57
57
  }
58
58
  if (x instanceof CalcitCirruQuote) {
59
- return kwd("cirru-quote");
59
+ return newTag("cirru-quote");
60
60
  }
61
61
  if (x === true || x === false) {
62
- return kwd("bool");
62
+ return newTag("bool");
63
63
  }
64
64
  if (typeof x === "function") {
65
65
  if (x.isMacro) {
66
66
  // this is faked...
67
- return kwd("macro");
67
+ return newTag("macro");
68
68
  }
69
- return kwd("fn");
69
+ return newTag("fn");
70
70
  }
71
71
  if (typeof x === "object") {
72
- return kwd("js-object");
72
+ return newTag("js-object");
73
73
  }
74
74
  throw new Error(`Unknown data ${x}`);
75
75
  };
@@ -354,8 +354,8 @@ export let add_watch = (a, k, f) => {
354
354
  if (!(a instanceof CalcitRef)) {
355
355
  throw new Error("Expected ref for add-watch!");
356
356
  }
357
- if (!(k instanceof CalcitKeyword)) {
358
- throw new Error("Expected watcher key in keyword");
357
+ if (!(k instanceof CalcitTag)) {
358
+ throw new Error("Expected watcher key in tag");
359
359
  }
360
360
  if (!(typeof f === "function")) {
361
361
  throw new Error("Expected watcher function");
@@ -492,7 +492,7 @@ export let recur = (...xs) => {
492
492
  return new CalcitRecur(xs);
493
493
  };
494
494
  export let _$n_get_calcit_backend = () => {
495
- return kwd("js");
495
+ return newTag("js");
496
496
  };
497
497
  export let not = (x) => {
498
498
  return !x;
@@ -670,11 +670,11 @@ export let _$n_merge = (a, b) => {
670
670
  for (let idx = 0; idx < pairs.length; idx++) {
671
671
  let [k, v] = pairs[idx];
672
672
  let field;
673
- if (k instanceof CalcitKeyword) {
673
+ if (k instanceof CalcitTag) {
674
674
  field = k;
675
675
  }
676
676
  else {
677
- field = kwd(getStringName(k));
677
+ field = newTag(getStringName(k));
678
678
  }
679
679
  let position = a.findIndex(field);
680
680
  if (position >= 0) {
@@ -892,18 +892,18 @@ export let get_env = (name, v0) => {
892
892
  }
893
893
  return v !== null && v !== void 0 ? v : v0;
894
894
  };
895
- export let turn_keyword = (x) => {
895
+ export let turn_tag = (x) => {
896
896
  if (typeof x === "string") {
897
- return kwd(x);
897
+ return newTag(x);
898
898
  }
899
- if (x instanceof CalcitKeyword) {
899
+ if (x instanceof CalcitTag) {
900
900
  return x;
901
901
  }
902
902
  if (x instanceof CalcitSymbol) {
903
- return kwd(x.value);
903
+ return newTag(x.value);
904
904
  }
905
905
  console.error(x);
906
- throw new Error("Unexpected data for keyword");
906
+ throw new Error("Unexpected data for tag");
907
907
  };
908
908
  export let turn_symbol = (x) => {
909
909
  if (typeof x === "string") {
@@ -912,7 +912,7 @@ export let turn_symbol = (x) => {
912
912
  if (x instanceof CalcitSymbol) {
913
913
  return x;
914
914
  }
915
- if (x instanceof CalcitKeyword) {
915
+ if (x instanceof CalcitTag) {
916
916
  return new CalcitSymbol(x.value);
917
917
  }
918
918
  console.error(x);
@@ -949,7 +949,7 @@ export let turn_string = (x) => {
949
949
  if (typeof x === "string") {
950
950
  return x;
951
951
  }
952
- if (x instanceof CalcitKeyword) {
952
+ if (x instanceof CalcitTag) {
953
953
  return x.value;
954
954
  }
955
955
  if (x instanceof CalcitSymbol) {
@@ -971,10 +971,10 @@ export let starts_with_$q_ = (xs, y) => {
971
971
  if (typeof xs === "string" && typeof y === "string") {
972
972
  return xs.startsWith(y);
973
973
  }
974
- if (xs instanceof CalcitKeyword && y instanceof CalcitKeyword) {
974
+ if (xs instanceof CalcitTag && y instanceof CalcitTag) {
975
975
  return xs.value.startsWith(y.value);
976
976
  }
977
- throw new Error("expected strings or keywords");
977
+ throw new Error("expected strings or tags");
978
978
  };
979
979
  export let ends_with_$q_ = (xs, y) => {
980
980
  return xs.endsWith(y);
@@ -1025,8 +1025,8 @@ export let bool_$q_ = (x) => {
1025
1025
  export let nil_$q_ = (x) => {
1026
1026
  return x == null;
1027
1027
  };
1028
- export let keyword_$q_ = (x) => {
1029
- return x instanceof CalcitKeyword;
1028
+ export let tag_$q_ = (x) => {
1029
+ return x instanceof CalcitTag;
1030
1030
  };
1031
1031
  export let map_$q_ = (x) => {
1032
1032
  return x instanceof CalcitSliceMap || x instanceof CalcitMap;
@@ -1152,7 +1152,7 @@ export let _$n_js_object = (...xs) => {
1152
1152
  if (typeof k === "string") {
1153
1153
  ret[k] = v;
1154
1154
  }
1155
- else if (k instanceof CalcitKeyword) {
1155
+ else if (k instanceof CalcitTag) {
1156
1156
  ret[turn_string(k)] = v;
1157
1157
  }
1158
1158
  else {
@@ -1161,8 +1161,12 @@ export let _$n_js_object = (...xs) => {
1161
1161
  }
1162
1162
  return ret;
1163
1163
  };
1164
- export let _$o__$o_ = (tag, ...extra) => {
1165
- return new CalcitTuple(tag, extra);
1164
+ export let _$o__$o_ = (tagName, ...extra) => {
1165
+ let klass = new CalcitRecord(newTag("base-class"), [], []);
1166
+ return new CalcitTuple(tagName, extra, klass);
1167
+ };
1168
+ export let _PCT__$o__$o_ = (klass, tag, ...extra) => {
1169
+ return new CalcitTuple(tag, extra, klass);
1166
1170
  };
1167
1171
  // mutable place for core to register
1168
1172
  let calcit_builtin_classes = {
@@ -1192,8 +1196,8 @@ export function invoke_method(p, obj, ...args) {
1192
1196
  klass = calcit_builtin_classes.nil;
1193
1197
  }
1194
1198
  else if (obj instanceof CalcitTuple) {
1195
- if (obj.tag instanceof CalcitRecord) {
1196
- klass = obj.tag;
1199
+ if (obj.klass instanceof CalcitRecord) {
1200
+ klass = obj.klass;
1197
1201
  }
1198
1202
  else {
1199
1203
  throw new Error("Method invoking expected a record as class");
@@ -1322,7 +1326,7 @@ export let _$n_str_$o_pad_right = (s, size, pattern) => {
1322
1326
  return s.padEnd(size, pattern);
1323
1327
  };
1324
1328
  export let _$n_get_os = () => {
1325
- return kwd("js-engine");
1329
+ return newTag("js-engine");
1326
1330
  };
1327
1331
  export let _$n_buffer = (...xs) => {
1328
1332
  let buf = new Uint8Array(xs.length);
@@ -1,4 +1,4 @@
1
- import { CalcitRef, CalcitSymbol, CalcitKeyword } from "./calcit-data.mjs";
1
+ import { CalcitRef, CalcitSymbol, CalcitTag } from "./calcit-data.mjs";
2
2
  import { CalcitRecord } from "./js-record.mjs";
3
3
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
4
4
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
@@ -21,7 +21,7 @@ export let load_console_formatter_$x_ = () => {
21
21
  window["devtoolsFormatters"] = [
22
22
  {
23
23
  header: (obj, config) => {
24
- if (obj instanceof CalcitKeyword) {
24
+ if (obj instanceof CalcitTag) {
25
25
  return ["div", { style: "color: hsl(240, 80%, 60%)" }, obj.toString()];
26
26
  }
27
27
  if (obj instanceof CalcitSymbol) {
package/lib/js-cirru.mjs CHANGED
@@ -4,7 +4,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
4
4
  import { CalcitRecord } from "./js-record.mjs";
5
5
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
6
6
  import { CalcitSet } from "./js-set.mjs";
7
- import { CalcitKeyword, CalcitSymbol, CalcitRecur, CalcitRef, kwd } from "./calcit-data.mjs";
7
+ import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef, newTag } from "./calcit-data.mjs";
8
8
  import { CalcitTuple } from "./js-tuple.mjs";
9
9
  export class CalcitCirruQuote {
10
10
  constructor(value) {
@@ -51,7 +51,7 @@ export let to_cirru_edn = (x) => {
51
51
  if (typeof x === "boolean") {
52
52
  return x.toString();
53
53
  }
54
- if (x instanceof CalcitKeyword) {
54
+ if (x instanceof CalcitTag) {
55
55
  return x.toString();
56
56
  }
57
57
  if (x instanceof CalcitSymbol) {
@@ -138,12 +138,12 @@ export let to_cirru_edn = (x) => {
138
138
  throw new Error("Unexpected data to to-cirru-edn");
139
139
  };
140
140
  /** makes sure we got string */
141
- let extractFieldKwd = (x) => {
141
+ let extractFieldTag = (x) => {
142
142
  if (x[0] === ":") {
143
- return kwd(x.slice(1));
143
+ return newTag(x.slice(1));
144
144
  }
145
145
  else {
146
- return kwd(x);
146
+ return newTag(x);
147
147
  }
148
148
  };
149
149
  export let extract_cirru_edn = (x) => {
@@ -164,7 +164,7 @@ export let extract_cirru_edn = (x) => {
164
164
  return x.slice(1);
165
165
  }
166
166
  if (x[0] === ":") {
167
- return kwd(x.slice(1));
167
+ return newTag(x.slice(1));
168
168
  }
169
169
  if (x[0] === "'") {
170
170
  return new CalcitSymbol(x.slice(1));
@@ -208,7 +208,7 @@ export let extract_cirru_edn = (x) => {
208
208
  }
209
209
  if (pair instanceof Array && pair.length === 2) {
210
210
  if (typeof pair[0] === "string") {
211
- entries.push([extractFieldKwd(pair[0]), extract_cirru_edn(pair[1])]);
211
+ entries.push([extractFieldTag(pair[0]), extract_cirru_edn(pair[1])]);
212
212
  }
213
213
  else {
214
214
  throw new Error("Expected string as field");
@@ -227,7 +227,7 @@ export let extract_cirru_edn = (x) => {
227
227
  fields.push(entries[idx][0]);
228
228
  values.push(entries[idx][1]);
229
229
  }
230
- return new CalcitRecord(extractFieldKwd(name), fields, values);
230
+ return new CalcitRecord(extractFieldTag(name), fields, values);
231
231
  }
232
232
  if (x[0] === "[]") {
233
233
  return new CalcitSliceList(x.slice(1).map(extract_cirru_edn));
@@ -248,7 +248,8 @@ export let extract_cirru_edn = (x) => {
248
248
  if (x.length < 3) {
249
249
  throw new Error("tuple expects at least 2 values");
250
250
  }
251
- return new CalcitTuple(extract_cirru_edn(x[1]), x.slice(2).map(extract_cirru_edn));
251
+ let baseClass = new CalcitRecord(newTag("base-class"), [], []);
252
+ return new CalcitTuple(extract_cirru_edn(x[1]), x.slice(2).map(extract_cirru_edn), baseClass);
252
253
  }
253
254
  }
254
255
  console.error(x);
@@ -270,7 +271,7 @@ export let format_cirru_edn = (data, useInline = true) => {
270
271
  if (data instanceof CalcitSymbol) {
271
272
  return "\ndo " + to_cirru_edn(data) + "\n";
272
273
  }
273
- if (data instanceof CalcitKeyword) {
274
+ if (data instanceof CalcitTag) {
274
275
  return "\ndo " + to_cirru_edn(data) + "\n";
275
276
  }
276
277
  return writeCirruCode([to_cirru_edn(data)], { useInline: useInline });
@@ -282,7 +283,7 @@ export let to_calcit_data = (x, noKeyword = false) => {
282
283
  return x;
283
284
  if (typeof x === "string") {
284
285
  if (!noKeyword && x[0] === ":" && x.slice(1).match(/^[\w\d_\?\!\-]+$/)) {
285
- return kwd(x.slice(1));
286
+ return newTag(x.slice(1));
286
287
  }
287
288
  return x;
288
289
  }
@@ -316,7 +317,7 @@ export let to_calcit_data = (x, noKeyword = false) => {
316
317
  return x;
317
318
  if (x instanceof CalcitRef)
318
319
  return x;
319
- if (x instanceof CalcitKeyword)
320
+ if (x instanceof CalcitTag)
320
321
  return x;
321
322
  if (x instanceof CalcitSymbol)
322
323
  return x;
package/lib/js-primes.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { CalcitKeyword, CalcitSymbol, CalcitRef, CalcitRecur } from "./calcit-data.mjs";
1
+ import { CalcitTag, CalcitSymbol, CalcitRef, CalcitRecur } from "./calcit-data.mjs";
2
2
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
3
3
  import { CalcitRecord } from "./js-record.mjs";
4
4
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
@@ -14,7 +14,7 @@ export let is_literal = (x) => {
14
14
  return true;
15
15
  if (typeof x == "number")
16
16
  return true;
17
- if (x instanceof CalcitKeyword)
17
+ if (x instanceof CalcitTag)
18
18
  return true;
19
19
  if (x instanceof CalcitSymbol)
20
20
  return true;
@@ -26,7 +26,7 @@ var PseudoTypeIndex;
26
26
  PseudoTypeIndex[PseudoTypeIndex["bool"] = 1] = "bool";
27
27
  PseudoTypeIndex[PseudoTypeIndex["number"] = 2] = "number";
28
28
  PseudoTypeIndex[PseudoTypeIndex["symbol"] = 3] = "symbol";
29
- PseudoTypeIndex[PseudoTypeIndex["keyword"] = 4] = "keyword";
29
+ PseudoTypeIndex[PseudoTypeIndex["tag"] = 4] = "tag";
30
30
  PseudoTypeIndex[PseudoTypeIndex["string"] = 5] = "string";
31
31
  PseudoTypeIndex[PseudoTypeIndex["ref"] = 6] = "ref";
32
32
  PseudoTypeIndex[PseudoTypeIndex["tuple"] = 7] = "tuple";
@@ -49,8 +49,8 @@ let typeAsInt = (x) => {
49
49
  return PseudoTypeIndex.number;
50
50
  if (x instanceof CalcitSymbol)
51
51
  return PseudoTypeIndex.symbol;
52
- if (x instanceof CalcitKeyword)
53
- return PseudoTypeIndex.keyword;
52
+ if (x instanceof CalcitTag)
53
+ return PseudoTypeIndex.tag;
54
54
  if (t === "string")
55
55
  return PseudoTypeIndex.string;
56
56
  if (x instanceof CalcitRef)
@@ -98,7 +98,7 @@ export let _$n_compare = (a, b) => {
98
98
  return rawCompare(a, b);
99
99
  case PseudoTypeIndex.number:
100
100
  return rawCompare(a, b);
101
- case PseudoTypeIndex.keyword:
101
+ case PseudoTypeIndex.tag:
102
102
  return rawCompare(a.value, b.value);
103
103
  case PseudoTypeIndex.symbol:
104
104
  return rawCompare(a, b);
package/lib/js-record.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { castKwd, toString, findInFields } from "./calcit-data.mjs";
1
+ import { castTag, toString, findInFields } from "./calcit-data.mjs";
2
2
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
3
3
  export class CalcitRecord {
4
4
  constructor(name, fields, values) {
5
5
  this.name = name;
6
- let fieldNames = fields.map(castKwd);
6
+ let fieldNames = fields.map(castTag);
7
7
  this.fields = fields;
8
8
  if (values != null) {
9
9
  if (values.length !== fields.length) {
@@ -17,7 +17,7 @@ export class CalcitRecord {
17
17
  this.cachedHash = null;
18
18
  }
19
19
  get(k) {
20
- let field = castKwd(k);
20
+ let field = castTag(k);
21
21
  let idx = findInFields(this.fields, field);
22
22
  if (idx >= 0) {
23
23
  return this.values[idx];
@@ -28,7 +28,7 @@ export class CalcitRecord {
28
28
  }
29
29
  assoc(k, v) {
30
30
  let values = new Array(this.fields.length);
31
- let k_id = castKwd(k);
31
+ let k_id = castTag(k);
32
32
  for (let idx = 0; idx < this.fields.length; idx++) {
33
33
  if (this.fields[idx] === k_id) {
34
34
  values[idx] = v;
@@ -41,7 +41,7 @@ export class CalcitRecord {
41
41
  }
42
42
  /** return -1 for missing */
43
43
  findIndex(k) {
44
- let field = castKwd(k);
44
+ let field = castTag(k);
45
45
  let idx = findInFields(this.fields, field);
46
46
  return idx;
47
47
  }
@@ -58,7 +58,7 @@ export class CalcitRecord {
58
58
  }
59
59
  }
60
60
  export let new_record = (name, ...fields) => {
61
- let fieldNames = fields.map(castKwd).sort((x, y) => {
61
+ let fieldNames = fields.map(castTag).sort((x, y) => {
62
62
  if (x.idx < y.idx) {
63
63
  return -1;
64
64
  }
@@ -69,7 +69,7 @@ export let new_record = (name, ...fields) => {
69
69
  throw new Error(`Unexpected duplication in record fields: ${x.toString()}`);
70
70
  }
71
71
  });
72
- return new CalcitRecord(castKwd(name), fieldNames);
72
+ return new CalcitRecord(castTag(name), fieldNames);
73
73
  };
74
74
  export let fieldsEqual = (xs, ys) => {
75
75
  if (xs === ys) {
@@ -98,7 +98,7 @@ export let _$n__PCT__$M_ = (proto, ...xs) => {
98
98
  let idx = -1;
99
99
  let k = proto.fields[i];
100
100
  for (let j = 0; j < proto.fields.length; j++) {
101
- if (k === castKwd(xs[j * 2])) {
101
+ if (k === castTag(xs[j * 2])) {
102
102
  idx = j;
103
103
  break;
104
104
  }
@@ -150,7 +150,7 @@ export let _$n_record_$o_from_map = (proto, data) => {
150
150
  let pairs = data.pairs();
151
151
  for (let i = 0; i < pairs.length; i++) {
152
152
  let [k, v] = pairs[i];
153
- pairs_buffer.push([castKwd(k), v]);
153
+ pairs_buffer.push([castTag(k), v]);
154
154
  }
155
155
  // mutable sort
156
156
  pairs_buffer.sort((pair1, pair2) => pair1[0].cmp(pair2[0]));
@@ -201,8 +201,8 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
201
201
  throw new Error(`Expected 4 arguments, got ${arguments.length}`);
202
202
  if (!(obj instanceof CalcitRecord))
203
203
  throw new Error("Expected record");
204
- let field = castKwd(new_key);
205
- let new_name_kwd = castKwd(new_name);
204
+ let field = castTag(new_key);
205
+ let new_name_tag = castTag(new_name);
206
206
  let new_fields = [];
207
207
  let new_values = [];
208
208
  let inserted = false;
@@ -233,5 +233,5 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
233
233
  new_fields.push(field);
234
234
  new_values.push(new_value);
235
235
  }
236
- return new CalcitRecord(new_name_kwd, new_fields, new_values);
236
+ return new CalcitRecord(new_name_tag, new_fields, new_values);
237
237
  }
package/lib/js-tuple.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { toString } from "./calcit-data.mjs";
2
2
  export class CalcitTuple {
3
- constructor(tag, extra) {
4
- this.tag = tag;
3
+ constructor(tagName, extra, klass) {
4
+ this.tag = tagName;
5
5
  this.extra = extra;
6
+ this.klass = klass;
6
7
  this.cachedHash = null;
7
8
  }
8
9
  get(n) {
@@ -18,12 +19,12 @@ export class CalcitTuple {
18
19
  }
19
20
  assoc(n, v) {
20
21
  if (n === 0) {
21
- return new CalcitTuple(v, this.extra);
22
+ return new CalcitTuple(v, this.extra, this.klass);
22
23
  }
23
24
  else if (n - 1 < this.extra.length) {
24
25
  let next_extra = this.extra.slice();
25
26
  next_extra[n - 1] = v;
26
- return new CalcitTuple(this.tag, next_extra);
27
+ return new CalcitTuple(this.tag, next_extra, this.klass);
27
28
  }
28
29
  else {
29
30
  throw new Error(`Tuple only have ${this.extra.length} elements`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.6.30",
3
+ "version": "0.7.0-a2",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.2.3",