@calcit/procs 0.8.56 → 0.8.58

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/README.md CHANGED
@@ -35,7 +35,7 @@ cargo install calcit
35
35
  - `caps`, for downloading dependencies declared in `deps.cirru`
36
36
  - `bundle_calcit`, bundle code if you don't want to use Calcit Editor
37
37
 
38
- For Ubuntu latest, try binaries from [Releases](https://github.com/calcit-lang/calcit/releases), which are provided for [CI usages](https://github.com/calcit-lang/respo-calcit-workflow/blob/main/.github/workflows/upload.yaml#L28-L37).
38
+ To use Calcit in GitHub Actions, try [setup-cr](https://github.com/calcit-lang/setup-cr).
39
39
 
40
40
  ### Usage
41
41
 
package/lib/js-cirru.mjs CHANGED
@@ -219,9 +219,8 @@ export let extract_cirru_edn = (x, options) => {
219
219
  if (x.match(/^(-?)\d+(\.\d*$)?/)) {
220
220
  return parseFloat(x);
221
221
  }
222
- // allow things cannot be parsed accepted as raw strings
223
- // turned on since Cirru nodes passed from macros uses this
224
- return x;
222
+ // strict behavior as Rust semantics
223
+ throw new Error("unknown syntax for EDN");
225
224
  }
226
225
  if (x instanceof Array) {
227
226
  if (x.length === 0) {
package/lib/js-record.mjs CHANGED
@@ -150,6 +150,28 @@ export let _$n__PCT__$M_ = (proto, ...xs) => {
150
150
  throw new Error("Expected prototype to be a record");
151
151
  }
152
152
  };
153
+ /// update record with new values
154
+ export let _$n_record_$o_with = (proto, ...xs) => {
155
+ if (proto instanceof CalcitRecord) {
156
+ if (xs.length % 2 !== 0) {
157
+ throw new Error("Expected even number of key/value");
158
+ }
159
+ let values = proto.values.slice();
160
+ for (let i = 0; i < xs.length; i += 2) {
161
+ let k = castTag(xs[i]);
162
+ let v = xs[i + 1];
163
+ let idx = findInFields(proto.fields, k);
164
+ if (idx < 0) {
165
+ throw new Error(`Cannot find field ${k} among ${proto.fields}`);
166
+ }
167
+ values[idx] = v;
168
+ }
169
+ return new CalcitRecord(proto.name, proto.fields, values, proto.klass);
170
+ }
171
+ else {
172
+ throw new Error("Expected prototype to be a record");
173
+ }
174
+ };
153
175
  export let _$n_record_$o_get_name = (x) => {
154
176
  if (x instanceof CalcitRecord) {
155
177
  return x.name;
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.8.56",
3
+ "version": "0.8.58",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.11.28",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.8.56",
3
+ "version": "0.8.58",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.11.28",
@@ -216,9 +216,8 @@ export let extract_cirru_edn = (x: CirruEdnFormat, options: CalcitValue): Calcit
216
216
  if (x.match(/^(-?)\d+(\.\d*$)?/)) {
217
217
  return parseFloat(x);
218
218
  }
219
- // allow things cannot be parsed accepted as raw strings
220
- // turned on since Cirru nodes passed from macros uses this
221
- return x;
219
+ // strict behavior as Rust semantics
220
+ throw new Error("unknown syntax for EDN");
222
221
  }
223
222
  if (x instanceof Array) {
224
223
  if (x.length === 0) {
@@ -158,6 +158,28 @@ export let _$n__PCT__$M_ = (proto: CalcitValue, ...xs: Array<CalcitValue>): Calc
158
158
  }
159
159
  };
160
160
 
161
+ /// update record with new values
162
+ export let _$n_record_$o_with = (proto: CalcitValue, ...xs: Array<CalcitValue>): CalcitValue => {
163
+ if (proto instanceof CalcitRecord) {
164
+ if (xs.length % 2 !== 0) {
165
+ throw new Error("Expected even number of key/value");
166
+ }
167
+ let values = proto.values.slice();
168
+ for (let i = 0; i < xs.length; i += 2) {
169
+ let k = castTag(xs[i]);
170
+ let v = xs[i + 1];
171
+ let idx = findInFields(proto.fields, k);
172
+ if (idx < 0) {
173
+ throw new Error(`Cannot find field ${k} among ${proto.fields}`);
174
+ }
175
+ values[idx] = v;
176
+ }
177
+ return new CalcitRecord(proto.name, proto.fields, values, proto.klass);
178
+ } else {
179
+ throw new Error("Expected prototype to be a record");
180
+ }
181
+ };
182
+
161
183
  export let _$n_record_$o_get_name = (x: CalcitRecord): CalcitTag => {
162
184
  if (x instanceof CalcitRecord) {
163
185
  return x.name;