@calcit/procs 0.5.39 → 0.5.40

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,6 @@
1
1
  var _a;
2
2
  // CALCIT VERSION
3
- export const calcit_version = "0.5.39";
3
+ export const calcit_version = "0.5.40";
4
4
  import { parse } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
6
6
  import "./js-primes.mjs";
package/lib/js-list.mjs CHANGED
@@ -110,7 +110,10 @@ export class CalcitSliceList {
110
110
  return this.end - this.start;
111
111
  }
112
112
  get(idx) {
113
- return this.value[this.start + idx];
113
+ if (idx >= 0 && this.start + idx < this.end) {
114
+ return this.value[this.start + idx];
115
+ }
116
+ return null;
114
117
  }
115
118
  assoc(idx, v) {
116
119
  return this.turnListMode().assoc(idx, v);
@@ -147,6 +150,10 @@ export class CalcitSliceList {
147
150
  if (to < from) {
148
151
  throw new Error("end index too small");
149
152
  }
153
+ if (from === to) {
154
+ // when it's empty, just return empty list
155
+ return new CalcitSliceList([]);
156
+ }
150
157
  let result = new CalcitSliceList(this.value);
151
158
  result.start = this.start + from;
152
159
  result.end = this.start + to;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.5.39",
3
+ "version": "0.5.40",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^17.0.29",
@@ -1,5 +1,5 @@
1
1
  // CALCIT VERSION
2
- export const calcit_version = "0.5.39";
2
+ export const calcit_version = "0.5.40";
3
3
 
4
4
  import { parse, ICirruNode } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
@@ -132,7 +132,10 @@ export class CalcitSliceList {
132
132
  return this.end - this.start;
133
133
  }
134
134
  get(idx: number) {
135
- return this.value[this.start + idx];
135
+ if (idx >= 0 && this.start + idx < this.end) {
136
+ return this.value[this.start + idx];
137
+ }
138
+ return null;
136
139
  }
137
140
  assoc(idx: number, v: CalcitValue) {
138
141
  return this.turnListMode().assoc(idx, v);
@@ -166,6 +169,10 @@ export class CalcitSliceList {
166
169
  if (to < from) {
167
170
  throw new Error("end index too small");
168
171
  }
172
+ if (from === to) {
173
+ // when it's empty, just return empty list
174
+ return new CalcitSliceList([]);
175
+ }
169
176
  let result = new CalcitSliceList(this.value);
170
177
  result.start = this.start + from;
171
178
  result.end = this.start + to;