eliscript 0.0.1
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/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COLLECTION_ASSOC,
|
|
3
|
+
COLLECTION_CONJ,
|
|
4
|
+
COLLECTION_CONTAINS,
|
|
5
|
+
COLLECTION_COUNT,
|
|
6
|
+
COLLECTION_DISSOC,
|
|
7
|
+
COLLECTION_DISJ,
|
|
8
|
+
COLLECTION_EMPTY,
|
|
9
|
+
COLLECTION_GET,
|
|
10
|
+
COLLECTION_REDUCE,
|
|
11
|
+
COLLECTION_REDUCE_KV,
|
|
12
|
+
COLLECTION_RSEQ,
|
|
13
|
+
COLLECTION_SEQ,
|
|
14
|
+
isReducedValue,
|
|
15
|
+
readCollectionEntry,
|
|
16
|
+
reduceIterable,
|
|
17
|
+
sequenceView,
|
|
18
|
+
unreducedValue,
|
|
19
|
+
} from "./collection-internals.mjs";
|
|
20
|
+
import { identifierName, identifierNamespace, isKeyword } from "./identifier.mjs";
|
|
21
|
+
import { METADATA_READ, METADATA_WITH } from "./metadata-internals.mjs";
|
|
22
|
+
import { comparator, compareValues } from "./order.mjs";
|
|
23
|
+
import {
|
|
24
|
+
PERSISTENT_MAP_HAS_VALUE_KEY,
|
|
25
|
+
PERSISTENT_MAP_KIND,
|
|
26
|
+
PERSISTENT_SET_HAS_VALUE,
|
|
27
|
+
PERSISTENT_SET_KIND,
|
|
28
|
+
persistentMapValueEqual,
|
|
29
|
+
persistentSetValueEqual,
|
|
30
|
+
} from "./persistent-kind.mjs";
|
|
31
|
+
import {
|
|
32
|
+
SORTED_MAP_STATE,
|
|
33
|
+
SORTED_SET_STATE,
|
|
34
|
+
sortedAssoc,
|
|
35
|
+
sortedDissoc,
|
|
36
|
+
sortedEntries,
|
|
37
|
+
sortedFind,
|
|
38
|
+
} from "./sorted-internals.mjs";
|
|
39
|
+
import {
|
|
40
|
+
VALUE_EQUAL,
|
|
41
|
+
VALUE_HASH,
|
|
42
|
+
finishHash,
|
|
43
|
+
mixHash,
|
|
44
|
+
unorderedCollectionHash,
|
|
45
|
+
} from "./value-internals.mjs";
|
|
46
|
+
import { equalValues } from "./value.mjs";
|
|
47
|
+
|
|
48
|
+
const SORTED_MAP_TOKEN = Symbol("eliscript.sorted-map.constructor-token");
|
|
49
|
+
const SORTED_SET_TOKEN = Symbol("eliscript.sorted-set.constructor-token");
|
|
50
|
+
const NOT_FOUND = Symbol("eliscript.sorted.not-found");
|
|
51
|
+
const PRESENT = Object.freeze({});
|
|
52
|
+
const MAP_HASH_TAG = 0x6c8e_9cf5;
|
|
53
|
+
const MAP_ENTRY_HASH_TAG = 0x3a91_72eb;
|
|
54
|
+
const SET_HASH_TAG = 0x51e7_b32d;
|
|
55
|
+
const BOUND_TESTS = new Set(["<", "<=", ">", ">="]);
|
|
56
|
+
const DEFAULT_COMPARATOR = comparator(compareValues);
|
|
57
|
+
|
|
58
|
+
function normalizeComparator(comparison) {
|
|
59
|
+
return comparison === compareValues || comparison === DEFAULT_COMPARATOR
|
|
60
|
+
? DEFAULT_COMPARATOR
|
|
61
|
+
: comparator(comparison);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function makeMap(root, comparison, metadata = null) {
|
|
65
|
+
return new PersistentSortedMap(
|
|
66
|
+
SORTED_MAP_TOKEN,
|
|
67
|
+
root,
|
|
68
|
+
comparison,
|
|
69
|
+
metadata,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function makeSet(map, metadata = null) {
|
|
74
|
+
return new PersistentSortedSet(SORTED_SET_TOKEN, map, metadata);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mapPairHash(entry, hash) {
|
|
78
|
+
return finishHash(
|
|
79
|
+
mixHash(mixHash(MAP_ENTRY_HASH_TAG, hash(entry[0])), hash(entry[1])),
|
|
80
|
+
2,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function mapIterator(root, comparison, ascending, start = null, end = null) {
|
|
85
|
+
const nodes = sortedEntries(root, comparison, ascending, start, end);
|
|
86
|
+
return (function* entries() {
|
|
87
|
+
for (const item of nodes) {
|
|
88
|
+
yield Object.freeze([item.key, item.value]);
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function setIterator(root, comparison, ascending, start = null, end = null) {
|
|
94
|
+
const nodes = sortedEntries(root, comparison, ascending, start, end);
|
|
95
|
+
return (function* values() {
|
|
96
|
+
for (const item of nodes) yield item.key;
|
|
97
|
+
})();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function sequenceOrNull(factory) {
|
|
101
|
+
const probe = factory();
|
|
102
|
+
try {
|
|
103
|
+
if (probe.next().done) return null;
|
|
104
|
+
} finally {
|
|
105
|
+
if (typeof probe.return === "function") probe.return();
|
|
106
|
+
}
|
|
107
|
+
return sequenceView(factory);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class PersistentSortedMap {
|
|
111
|
+
constructor(token, root, comparison, metadata = null) {
|
|
112
|
+
if (token !== SORTED_MAP_TOKEN || typeof comparison !== "function") {
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
"PersistentSortedMap values must be created with persistentSortedMap or persistentSortedMapBy",
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
this[SORTED_MAP_STATE] = Object.freeze({ root, comparison, metadata });
|
|
118
|
+
Object.freeze(this);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static empty(comparison = compareValues) {
|
|
122
|
+
return emptySortedMapBy(comparison);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static from(entries, comparison = compareValues) {
|
|
126
|
+
if (entries instanceof PersistentSortedMap && arguments.length === 1) {
|
|
127
|
+
return entries;
|
|
128
|
+
}
|
|
129
|
+
let result = emptySortedMapBy(comparison);
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
const [key, value] = readCollectionEntry(entry);
|
|
132
|
+
result = result.assoc(key, value);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get count() {
|
|
138
|
+
return this[SORTED_MAP_STATE].root?.size ?? 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get size() {
|
|
142
|
+
return this.count;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get comparator() {
|
|
146
|
+
return this[SORTED_MAP_STATE].comparison;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get(key, notFound = null) {
|
|
150
|
+
const state = this[SORTED_MAP_STATE];
|
|
151
|
+
const found = sortedFind(state.root, key, state.comparison);
|
|
152
|
+
return found === null ? notFound : found.value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
has(key) {
|
|
156
|
+
const state = this[SORTED_MAP_STATE];
|
|
157
|
+
return sortedFind(state.root, key, state.comparison) !== null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
assoc(key, value) {
|
|
161
|
+
const state = this[SORTED_MAP_STATE];
|
|
162
|
+
const result = sortedAssoc(state.root, key, value, state.comparison);
|
|
163
|
+
return result.changed
|
|
164
|
+
? makeMap(result.root, state.comparison, state.metadata)
|
|
165
|
+
: this;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
dissoc(key) {
|
|
169
|
+
const state = this[SORTED_MAP_STATE];
|
|
170
|
+
const result = sortedDissoc(state.root, key, state.comparison);
|
|
171
|
+
return result.removed
|
|
172
|
+
? makeMap(result.root, state.comparison, state.metadata)
|
|
173
|
+
: this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
entries(ascending = true) {
|
|
177
|
+
const state = this[SORTED_MAP_STATE];
|
|
178
|
+
return mapIterator(state.root, state.comparison, ascending);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
keys(ascending = true) {
|
|
182
|
+
const entries = this.entries(ascending);
|
|
183
|
+
return (function* keys() {
|
|
184
|
+
for (const entry of entries) yield entry[0];
|
|
185
|
+
})();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
values(ascending = true) {
|
|
189
|
+
const entries = this.entries(ascending);
|
|
190
|
+
return (function* values() {
|
|
191
|
+
for (const entry of entries) yield entry[1];
|
|
192
|
+
})();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[COLLECTION_COUNT]() {
|
|
196
|
+
return this.count;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[COLLECTION_EMPTY]() {
|
|
200
|
+
const state = this[SORTED_MAP_STATE];
|
|
201
|
+
return makeMap(null, state.comparison, state.metadata);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
[COLLECTION_CONJ](entry) {
|
|
205
|
+
const [key, value] = readCollectionEntry(entry);
|
|
206
|
+
return this.assoc(key, value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[COLLECTION_GET](key, notFound = null) {
|
|
210
|
+
return this.get(key, notFound);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[COLLECTION_ASSOC](key, value) {
|
|
214
|
+
return this.assoc(key, value);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
[COLLECTION_CONTAINS](key) {
|
|
218
|
+
return this.has(key);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[COLLECTION_DISSOC](key) {
|
|
222
|
+
return this.dissoc(key);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
[COLLECTION_SEQ]() {
|
|
226
|
+
return this.count === 0
|
|
227
|
+
? null
|
|
228
|
+
: sequenceView(() => this.entries(), this.count);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
[COLLECTION_RSEQ]() {
|
|
232
|
+
return this.count === 0
|
|
233
|
+
? null
|
|
234
|
+
: sequenceView(() => this.entries(false), this.count);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
[COLLECTION_REDUCE](reducer, ...initial) {
|
|
238
|
+
return reduceIterable(this, reducer, ...initial);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
[COLLECTION_REDUCE_KV](reducer, initial) {
|
|
242
|
+
let result = initial;
|
|
243
|
+
for (const [key, value] of this) {
|
|
244
|
+
result = reducer(result, key, value);
|
|
245
|
+
if (isReducedValue(result)) return unreducedValue(result);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
[PERSISTENT_MAP_HAS_VALUE_KEY](key) {
|
|
251
|
+
const state = this[SORTED_MAP_STATE];
|
|
252
|
+
const found = sortedFind(state.root, key, state.comparison);
|
|
253
|
+
return found !== null && equalValues(found.key, key);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
get [PERSISTENT_MAP_KIND]() {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
[VALUE_EQUAL](other, equal) {
|
|
261
|
+
return persistentMapValueEqual(this, other, equal);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
[VALUE_HASH](hash) {
|
|
265
|
+
return unorderedCollectionHash(this, (entry) => mapPairHash(entry, hash), MAP_HASH_TAG);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
[METADATA_READ]() {
|
|
269
|
+
return this[SORTED_MAP_STATE].metadata;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[METADATA_WITH](metadata) {
|
|
273
|
+
const state = this[SORTED_MAP_STATE];
|
|
274
|
+
return metadata === state.metadata
|
|
275
|
+
? this
|
|
276
|
+
: makeMap(state.root, state.comparison, metadata);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
[Symbol.iterator]() {
|
|
280
|
+
return this.entries();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
get [Symbol.toStringTag]() {
|
|
284
|
+
return "EliscriptPersistentSortedMap";
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export class PersistentSortedSet {
|
|
289
|
+
constructor(token, map, metadata = null) {
|
|
290
|
+
if (token !== SORTED_SET_TOKEN || !(map instanceof PersistentSortedMap)) {
|
|
291
|
+
throw new TypeError(
|
|
292
|
+
"PersistentSortedSet values must be created with persistentSortedSet or persistentSortedSetBy",
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
this[SORTED_SET_STATE] = Object.freeze({ map, metadata });
|
|
296
|
+
Object.freeze(this);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
static empty(comparison = compareValues) {
|
|
300
|
+
return emptySortedSetBy(comparison);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static from(values, comparison = compareValues) {
|
|
304
|
+
if (values instanceof PersistentSortedSet && arguments.length === 1) {
|
|
305
|
+
return values;
|
|
306
|
+
}
|
|
307
|
+
let result = emptySortedSetBy(comparison);
|
|
308
|
+
for (const value of values) result = result.conj(value);
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
get count() {
|
|
313
|
+
return this[SORTED_SET_STATE].map.count;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
get size() {
|
|
317
|
+
return this.count;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
get comparator() {
|
|
321
|
+
return this[SORTED_SET_STATE].map.comparator;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
has(value) {
|
|
325
|
+
return this[SORTED_SET_STATE].map.has(value);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
conj(value) {
|
|
329
|
+
const state = this[SORTED_SET_STATE];
|
|
330
|
+
const map = state.map.assoc(value, PRESENT);
|
|
331
|
+
return map === state.map ? this : makeSet(map, state.metadata);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
disj(value) {
|
|
335
|
+
const state = this[SORTED_SET_STATE];
|
|
336
|
+
const map = state.map.dissoc(value);
|
|
337
|
+
return map === state.map ? this : makeSet(map, state.metadata);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
values(ascending = true) {
|
|
341
|
+
const state = this[SORTED_SET_STATE].map[SORTED_MAP_STATE];
|
|
342
|
+
return setIterator(state.root, state.comparison, ascending);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
keys(ascending = true) {
|
|
346
|
+
return this.values(ascending);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
*entries(ascending = true) {
|
|
350
|
+
for (const value of this.values(ascending)) {
|
|
351
|
+
yield Object.freeze([value, value]);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
[COLLECTION_COUNT]() {
|
|
356
|
+
return this.count;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
[COLLECTION_EMPTY]() {
|
|
360
|
+
const state = this[SORTED_SET_STATE];
|
|
361
|
+
return makeSet(state.map[COLLECTION_EMPTY](), state.metadata);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
[COLLECTION_CONJ](value) {
|
|
365
|
+
return this.conj(value);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
[COLLECTION_DISJ](value) {
|
|
369
|
+
return this.disj(value);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
[COLLECTION_GET](value, notFound = null) {
|
|
373
|
+
const state = this[SORTED_SET_STATE].map[SORTED_MAP_STATE];
|
|
374
|
+
const found = sortedFind(state.root, value, state.comparison);
|
|
375
|
+
return found === null ? notFound : found.key;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
[COLLECTION_CONTAINS](value) {
|
|
379
|
+
return this.has(value);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
[COLLECTION_SEQ]() {
|
|
383
|
+
return this.count === 0
|
|
384
|
+
? null
|
|
385
|
+
: sequenceView(() => this.values(), this.count);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
[COLLECTION_RSEQ]() {
|
|
389
|
+
return this.count === 0
|
|
390
|
+
? null
|
|
391
|
+
: sequenceView(() => this.values(false), this.count);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
[COLLECTION_REDUCE](reducer, ...initial) {
|
|
395
|
+
return reduceIterable(this, reducer, ...initial);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
[PERSISTENT_SET_HAS_VALUE](value, equal) {
|
|
399
|
+
const state = this[SORTED_SET_STATE].map[SORTED_MAP_STATE];
|
|
400
|
+
const found = sortedFind(state.root, value, state.comparison);
|
|
401
|
+
return found !== null && equal(found.key, value);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
get [PERSISTENT_SET_KIND]() {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
[VALUE_EQUAL](other, equal) {
|
|
409
|
+
return persistentSetValueEqual(this, other, equal);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
[VALUE_HASH](hash) {
|
|
413
|
+
return unorderedCollectionHash(this, hash, SET_HASH_TAG);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
[METADATA_READ]() {
|
|
417
|
+
return this[SORTED_SET_STATE].metadata;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
[METADATA_WITH](metadata) {
|
|
421
|
+
const state = this[SORTED_SET_STATE];
|
|
422
|
+
return metadata === state.metadata
|
|
423
|
+
? this
|
|
424
|
+
: makeSet(state.map, metadata);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
[Symbol.iterator]() {
|
|
428
|
+
return this.values();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
get [Symbol.toStringTag]() {
|
|
432
|
+
return "EliscriptPersistentSortedSet";
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export const EMPTY_SORTED_MAP = makeMap(null, DEFAULT_COMPARATOR);
|
|
437
|
+
export const EMPTY_SORTED_SET = makeSet(EMPTY_SORTED_MAP);
|
|
438
|
+
|
|
439
|
+
export function emptySortedMapBy(comparison) {
|
|
440
|
+
const normalized = normalizeComparator(comparison);
|
|
441
|
+
return normalized === DEFAULT_COMPARATOR
|
|
442
|
+
? EMPTY_SORTED_MAP
|
|
443
|
+
: makeMap(null, normalized);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export function emptySortedSetBy(comparison) {
|
|
447
|
+
const map = emptySortedMapBy(comparison);
|
|
448
|
+
return map === EMPTY_SORTED_MAP ? EMPTY_SORTED_SET : makeSet(map);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function requireEvenKeyValues(keyValues, label) {
|
|
452
|
+
if (keyValues.length % 2 !== 0) {
|
|
453
|
+
throw new TypeError(`${label} expects an even number of key/value forms`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function populateMap(map, keyValues) {
|
|
458
|
+
let result = map;
|
|
459
|
+
for (let index = 0; index < keyValues.length; index += 2) {
|
|
460
|
+
result = result.assoc(keyValues[index], keyValues[index + 1]);
|
|
461
|
+
}
|
|
462
|
+
return result;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export function persistentSortedMap(...keyValues) {
|
|
466
|
+
requireEvenKeyValues(keyValues, "persistentSortedMap");
|
|
467
|
+
return populateMap(EMPTY_SORTED_MAP, keyValues);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export function persistentSortedMapBy(comparison, ...keyValues) {
|
|
471
|
+
requireEvenKeyValues(keyValues, "persistentSortedMapBy");
|
|
472
|
+
return populateMap(emptySortedMapBy(comparison), keyValues);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export function persistentSortedSet(...values) {
|
|
476
|
+
let result = EMPTY_SORTED_SET;
|
|
477
|
+
for (const value of values) result = result.conj(value);
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export function persistentSortedSetBy(comparison, ...values) {
|
|
482
|
+
let result = emptySortedSetBy(comparison);
|
|
483
|
+
for (const value of values) result = result.conj(value);
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export function isPersistentSortedMap(value) {
|
|
488
|
+
return value instanceof PersistentSortedMap;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function isPersistentSortedSet(value) {
|
|
492
|
+
return value instanceof PersistentSortedSet;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export function isPersistentSortedCollection(value) {
|
|
496
|
+
return isPersistentSortedMap(value) || isPersistentSortedSet(value);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function sortedState(collection) {
|
|
500
|
+
if (collection instanceof PersistentSortedMap) {
|
|
501
|
+
const state = collection[SORTED_MAP_STATE];
|
|
502
|
+
return {
|
|
503
|
+
root: state.root,
|
|
504
|
+
comparison: state.comparison,
|
|
505
|
+
factory: (ascending, start, end) =>
|
|
506
|
+
mapIterator(state.root, state.comparison, ascending, start, end),
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
if (collection instanceof PersistentSortedSet) {
|
|
510
|
+
const state = collection[SORTED_SET_STATE].map[SORTED_MAP_STATE];
|
|
511
|
+
return {
|
|
512
|
+
root: state.root,
|
|
513
|
+
comparison: state.comparison,
|
|
514
|
+
factory: (ascending, start, end) =>
|
|
515
|
+
setIterator(state.root, state.comparison, ascending, start, end),
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
throw new TypeError("operation requires a persistent sorted collection");
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function requireBoolean(value, label) {
|
|
522
|
+
if (typeof value !== "boolean") throw new TypeError(`${label} must be a boolean`);
|
|
523
|
+
return value;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export function sortedComparator(collection) {
|
|
527
|
+
return sortedState(collection).comparison;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export function sortedSequence(collection, ascending = true) {
|
|
531
|
+
requireBoolean(ascending, "sortedSequence ascending");
|
|
532
|
+
const state = sortedState(collection);
|
|
533
|
+
return state.root === null
|
|
534
|
+
? null
|
|
535
|
+
: sequenceView(() => state.factory(ascending, null, null), state.root.size);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export function sortedSequenceFrom(
|
|
539
|
+
collection,
|
|
540
|
+
key,
|
|
541
|
+
ascending = true,
|
|
542
|
+
inclusive = true,
|
|
543
|
+
) {
|
|
544
|
+
requireBoolean(ascending, "sortedSequenceFrom ascending");
|
|
545
|
+
requireBoolean(inclusive, "sortedSequenceFrom inclusive");
|
|
546
|
+
const state = sortedState(collection);
|
|
547
|
+
const start = { key, inclusive };
|
|
548
|
+
return sequenceOrNull(() => state.factory(ascending, start, null));
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function boundTestName(test) {
|
|
552
|
+
const name = isKeyword(test) && identifierNamespace(test) === null
|
|
553
|
+
? identifierName(test)
|
|
554
|
+
: test;
|
|
555
|
+
if (typeof name !== "string" || !BOUND_TESTS.has(name)) {
|
|
556
|
+
throw new TypeError("sorted bound test must be one of :<, :<=, :>, or :>=");
|
|
557
|
+
}
|
|
558
|
+
return name;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function rangeBounds(bounds) {
|
|
562
|
+
if (bounds.length !== 2 && bounds.length !== 4) {
|
|
563
|
+
throw new TypeError("subsequence expects one or two test/key bounds");
|
|
564
|
+
}
|
|
565
|
+
const firstTest = boundTestName(bounds[0]);
|
|
566
|
+
const first = { key: bounds[1], inclusive: firstTest.includes("=") };
|
|
567
|
+
if (bounds.length === 2) {
|
|
568
|
+
return firstTest.startsWith(">")
|
|
569
|
+
? { lower: first, upper: null }
|
|
570
|
+
: { lower: null, upper: first };
|
|
571
|
+
}
|
|
572
|
+
const secondTest = boundTestName(bounds[2]);
|
|
573
|
+
if (!firstTest.startsWith(">") || !secondTest.startsWith("<")) {
|
|
574
|
+
throw new TypeError(
|
|
575
|
+
"two-bound subsequence requires a lower :>/:>= bound then an upper :</:<= bound",
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
lower: first,
|
|
580
|
+
upper: { key: bounds[3], inclusive: secondTest.includes("=") },
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function rangeSequence(collection, ascending, bounds) {
|
|
585
|
+
const state = sortedState(collection);
|
|
586
|
+
const normalized = rangeBounds(bounds);
|
|
587
|
+
const start = ascending ? normalized.lower : normalized.upper;
|
|
588
|
+
const end = ascending ? normalized.upper : normalized.lower;
|
|
589
|
+
return sequenceOrNull(() => state.factory(ascending, start, end));
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function subsequence(collection, ...bounds) {
|
|
593
|
+
return rangeSequence(collection, true, bounds);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export function reverseSubsequence(collection, ...bounds) {
|
|
597
|
+
return rangeSequence(collection, false, bounds);
|
|
598
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
3
|
+
|
|
4
|
+
import * as Collection from "../../runtime/core/collection.mjs";
|
|
5
|
+
function empty_QMARK_(text) {
|
|
6
|
+
return (Collection.count(text) === 0);
|
|
7
|
+
}
|
|
8
|
+
function slice(start, end, text) {
|
|
9
|
+
return ((result, index, limit) => {
|
|
10
|
+
(() => {
|
|
11
|
+
while (__eliscript_truthy((index < limit))) {
|
|
12
|
+
((result = (String(result) + String(Collection.nth(text, index)))), (index = (index + 1)));
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
})();
|
|
16
|
+
return result;
|
|
17
|
+
})("", (__eliscript_truthy((start < 0)) ? 0 : start), (__eliscript_truthy((end > Collection.count(text))) ? Collection.count(text) : end));
|
|
18
|
+
}
|
|
19
|
+
function starts_at_QMARK_(prefix, offset, text) {
|
|
20
|
+
return ((matched, index) => {
|
|
21
|
+
(() => {
|
|
22
|
+
while (__eliscript_truthy(((__eliscript_value_2) => (__eliscript_truthy(__eliscript_value_2) ? (index < Collection.count(prefix)) : __eliscript_value_2))(matched))) {
|
|
23
|
+
(__eliscript_truthy((!__eliscript_truthy((Collection.nth(prefix, index) === Collection.nth(text, (offset + index)))))) ? ((matched = false)) : null);
|
|
24
|
+
((index = (index + 1)));
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
})();
|
|
28
|
+
return matched;
|
|
29
|
+
})(((__eliscript_value_1) => (__eliscript_truthy(__eliscript_value_1) ? ((offset + Collection.count(prefix)) <= Collection.count(text)) : __eliscript_value_1))((offset >= 0)), 0);
|
|
30
|
+
}
|
|
31
|
+
function starts_with_QMARK_(prefix, text) {
|
|
32
|
+
return starts_at_QMARK_(prefix, 0, text);
|
|
33
|
+
}
|
|
34
|
+
function ends_with_QMARK_(suffix, text) {
|
|
35
|
+
return starts_at_QMARK_(suffix, (Collection.count(text) - Collection.count(suffix)), text);
|
|
36
|
+
}
|
|
37
|
+
function contains_QMARK_(needle, text) {
|
|
38
|
+
return ((found, offset, last_offset) => {
|
|
39
|
+
(() => {
|
|
40
|
+
while (__eliscript_truthy(((__eliscript_value_3) => (__eliscript_truthy(__eliscript_value_3) ? (offset <= last_offset) : __eliscript_value_3))((!__eliscript_truthy(found))))) {
|
|
41
|
+
(__eliscript_truthy(starts_at_QMARK_(needle, offset, text)) ? ((found = true)) : null);
|
|
42
|
+
((offset = (offset + 1)));
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
})();
|
|
46
|
+
return found;
|
|
47
|
+
})(false, 0, (Collection.count(text) - Collection.count(needle)));
|
|
48
|
+
}
|
|
49
|
+
function strip_prefix(prefix, text) {
|
|
50
|
+
return (__eliscript_truthy(starts_with_QMARK_(prefix, text)) ? slice(Collection.count(prefix), Collection.count(text), text) : text);
|
|
51
|
+
}
|
|
52
|
+
function strip_suffix(suffix, text) {
|
|
53
|
+
return (__eliscript_truthy(ends_with_QMARK_(suffix, text)) ? slice(0, (Collection.count(text) - Collection.count(suffix)), text) : text);
|
|
54
|
+
}
|
|
55
|
+
function whitespace_QMARK_(character) {
|
|
56
|
+
return ((__eliscript_value_4) => (__eliscript_truthy(__eliscript_value_4) ? __eliscript_value_4 : ((__eliscript_value_5) => (__eliscript_truthy(__eliscript_value_5) ? __eliscript_value_5 : ((__eliscript_value_6) => (__eliscript_truthy(__eliscript_value_6) ? __eliscript_value_6 : (character === "\r")))((character === "\n"))))((character === "\t"))))((character === " "));
|
|
57
|
+
}
|
|
58
|
+
function trim(text) {
|
|
59
|
+
return ((start, end) => {
|
|
60
|
+
(() => {
|
|
61
|
+
while (__eliscript_truthy(((__eliscript_value_7) => (__eliscript_truthy(__eliscript_value_7) ? whitespace_QMARK_(Collection.nth(text, start)) : __eliscript_value_7))((start <= end)))) {
|
|
62
|
+
((start = (start + 1)));
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
})();
|
|
66
|
+
(() => {
|
|
67
|
+
while (__eliscript_truthy(((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? whitespace_QMARK_(Collection.nth(text, end)) : __eliscript_value_8))((end >= start)))) {
|
|
68
|
+
((end = (end - 1)));
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
})();
|
|
72
|
+
return slice(start, (end + 1), text);
|
|
73
|
+
})(0, (Collection.count(text) - 1));
|
|
74
|
+
}
|
|
75
|
+
function blank_QMARK_(text) {
|
|
76
|
+
return empty_QMARK_(trim(text));
|
|
77
|
+
}
|
|
78
|
+
function join(separator, values) {
|
|
79
|
+
return (Collection.reduce(values, (state, value) => {
|
|
80
|
+
return ({"first": false, "text": (String((state)["text"]) + String((__eliscript_truthy((state)["first"]) ? "" : separator)) + String(value))});
|
|
81
|
+
}, ({"first": true, "text": ""})))["text"];
|
|
82
|
+
}
|
|
83
|
+
function repeat(count, text) {
|
|
84
|
+
return ((result, index) => {
|
|
85
|
+
(() => {
|
|
86
|
+
while (__eliscript_truthy((index < count))) {
|
|
87
|
+
((result = (String(result) + String(text))), (index = (index + 1)));
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
})();
|
|
91
|
+
return result;
|
|
92
|
+
})("", 0);
|
|
93
|
+
}
|
|
94
|
+
export {blank_QMARK_, contains_QMARK_, empty_QMARK_, ends_with_QMARK_, join, repeat, slice, starts_at_QMARK_, starts_with_QMARK_, strip_prefix, strip_suffix, trim, whitespace_QMARK_};
|
|
95
|
+
//# sourceMappingURL=text-impl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-impl.mjs","sources":["../../stdlib/core/text.eli"],"sourcesContent":["(module eliscript.core.text\n (import \"../../runtime/core/collection.mjs\" :as Collection)\n\n (defun empty? (text)\n (= (Collection/count text) 0))\n\n (defun slice (start end text)\n (let ((result \"\")\n (index (if (< start 0) 0 start))\n (limit\n (if (> end (Collection/count text))\n (Collection/count text)\n end)))\n (while (< index limit)\n (setq result (str result (Collection/nth text index))\n index (1+ index)))\n result))\n\n (defun starts-at? (prefix offset text)\n (let ((matched\n (and (>= offset 0)\n (<= (+ offset (Collection/count prefix))\n (Collection/count text))))\n (index 0))\n (while (and matched (< index (Collection/count prefix)))\n (unless (= (Collection/nth prefix index)\n (Collection/nth text (+ offset index)))\n (setq matched false))\n (setq index (1+ index)))\n matched))\n\n (defun starts-with? (prefix text)\n (starts-at? prefix 0 text))\n\n (defun ends-with? (suffix text)\n (starts-at? suffix\n (- (Collection/count text) (Collection/count suffix))\n text))\n\n (defun contains? (needle text)\n (let ((found false)\n (offset 0)\n (last-offset\n (- (Collection/count text) (Collection/count needle))))\n (while (and (not found) (<= offset last-offset))\n (when (starts-at? needle offset text)\n (setq found t))\n (setq offset (1+ offset)))\n found))\n\n (defun strip-prefix (prefix text)\n (if (starts-with? prefix text)\n (slice (Collection/count prefix) (Collection/count text) text)\n text))\n\n (defun strip-suffix (suffix text)\n (if (ends-with? suffix text)\n (slice 0 (- (Collection/count text) (Collection/count suffix)) text)\n text))\n\n (defun whitespace? (character)\n (or (= character \" \")\n (= character \"\\t\")\n (= character \"\\n\")\n (= character \"\\r\")))\n\n (defun trim (text)\n (let ((start 0)\n (end (1- (Collection/count text))))\n (while (and (<= start end)\n (whitespace? (Collection/nth text start)))\n (setq start (1+ start)))\n (while (and (>= end start)\n (whitespace? (Collection/nth text end)))\n (setq end (1- end)))\n (slice start (1+ end) text)))\n\n (defun blank? (text)\n (empty? (trim text)))\n\n (defun join (separator values)\n (get\n (Collection/reduce\n values\n (lambda (state value)\n (js-object\n :first false\n :text (str (get state :text)\n (if (get state :first) \"\" separator)\n value)))\n (js-object :first t :text \"\"))\n :text))\n\n (defun repeat (count text)\n (let ((result \"\")\n (index 0))\n (while (< index count)\n (setq result (str result text)\n index (1+ index)))\n result))\n\n (export blank? contains? empty? ends-with? join repeat slice starts-at?\n starts-with? strip-prefix strip-suffix trim whitespace?))\n"],"names":[],"mappings":";;;AACE,YAAgD;AAEhD,sBAAe;SACb,CAAI,iBAAiB,UAAM;;AAE7B,eAAc,OAAM,KAAI;SACtB,EAAM,QACA,OACA;IAIJ;gCAAO,CAAG,QAAM;QACd,CAAM,CAAA,SAAO,QAAK,iBAAQ,eAAe,MAAK,WACxC,CAAA,QAAM,CAAI;;;;WAClB;KATY,IACD,oBAAI,CAAG,QAAM,MAAG,IAAE,QAExB,oBAAI,CAAG,MAAK,iBAAiB,UACxB,iBAAiB,QACpB;;AAMX,0BAAmB,QAAO,QAAO;SAC/B,EAAM,SAIA;IACJ;gCAAO,qEAAa,CAAG,QAAO,iBAAiB,iCAAnC;QACV,yCAAQ,CAAI,eAAe,QAAO,WACtB,eAAe,MAAK,CAAG,SAAO,cACxC,CAAM,CAAA,UAAQ;QAChB,CAAM,CAAA,QAAM,CAAI;;;;WAClB;KATK,qEACK,CAAI,CAAG,SAAQ,iBAAiB,YAC3B,iBAAiB,+BAFtB,CAAI,UAAO,KAGV;;AAQf,4BAAqB,QAAO;SACzB,iBAAW,QAAO,GAAE;;AAEvB,0BAAmB,QAAO;SACvB,iBAAW,QACA,CAAI,iBAAiB,QAAO,iBAAiB,UAC7C;;AAEd,yBAAkB,QAAO;SACvB,EAAM,OACA,QACA;IAEJ;gCAAO,qEAAiB,CAAI,UAAO,qCAAvB,qBAAK;QACf,oBAAO,iBAAW,QAAO,QAAO,SAC9B,CAAM,CAAA,QAAM;QACd,CAAM,CAAA,SAAO,CAAI;;;;WACnB;KARW,OACC,GAEP,CAAI,iBAAiB,QAAO,iBAAiB;;AAOtD,sBAAqB,QAAO;SAC1B,oBAAK,mBAAa,QAAO,SACpB,MAAO,iBAAiB,SAAS,iBAAiB,OAAM,QAC3D;;AAEJ,sBAAqB,QAAO;SAC1B,oBAAK,iBAAW,QAAO,SAClB,MAAM,GAAE,CAAI,iBAAiB,QAAO,iBAAiB,UAAS,QACjE;;AAEJ,2BAAoB;SAClB,iRAGI,CAAG,cAAU,QADb,CAAG,cAAU,SADb,CAAG,cAAU,SADb,CAAG,cAAU;;AAKnB,cAAa;SACX,EAAM,OACA;IACJ;gCAAO,qEACM,kBAAa,eAAe,MAAK,gCADlC,CAAI,SAAM;QAEpB,CAAM,CAAA,QAAM,CAAI;;;;IAClB;gCAAO,qEACM,kBAAa,eAAe,MAAK,8BADlC,CAAI,OAAI;QAElB,CAAM,CAAA,MAAI,CAAI;;;;WACf,MAAM,OAAM,CAAI,UAAK;KARX,GACF,CAAK,iBAAiB;;AASnC,sBAAe;SACZ,aAAQ,KAAK;;AAEhB,cAAa,WAAU;SACrB,CACG,kBACC,QACA,CAAS,OAAM;WACb,EACE,SAAO,OACP,QAAM,QAAK,CAAK,OAAM,kBACX,oBAAI,CAAK,OAAM,YAAQ,KAAG,qBAC1B;KACf,EAAW,SAAO,MAAE,QAAM,OAC5B;;AAEJ,gBAAe,OAAM;SACnB,EAAM,QACA;IACJ;gCAAO,CAAG,QAAM;QACd,CAAM,CAAA,SAAO,QAAK,iBAAO,SACnB,CAAA,QAAM,CAAI;;;;WAClB;KALY,IACD;;AAMf,QAAQ,cAAO,iBAAU,cAAO,kBAAW,MAAK,QAAO,OAAM,kBACrD,oBAAa,cAAa,cAAa,MAAK"}
|