@bablr/bablr-vm 0.20.0 → 0.21.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bablr/bablr-vm",
3
3
  "description": "A VM for parsing using BABLR languages",
4
- "version": "0.20.0",
4
+ "version": "0.21.0",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [
@@ -12,13 +12,13 @@
12
12
  },
13
13
  "sideEffects": false,
14
14
  "dependencies": {
15
- "@bablr/agast-helpers": "0.7.0",
16
- "@bablr/agast-vm": "0.8.0",
17
- "@bablr/agast-vm-helpers": "0.7.0",
15
+ "@bablr/agast-helpers": "0.8.0",
16
+ "@bablr/agast-vm": "0.9.0",
17
+ "@bablr/agast-vm-helpers": "0.8.0",
18
18
  "@bablr/coroutine": "0.1.0",
19
- "@bablr/helpers": "0.22.0",
20
- "@bablr/regex-vm": "0.11.0",
21
- "@bablr/weak-stack": "1.0.0",
19
+ "@bablr/helpers": "0.23.0",
20
+ "@bablr/regex-vm": "0.12.0",
21
+ "@bablr/weak-stack": "1.0.1",
22
22
  "@iter-tools/imm-stack": "1.1.0",
23
23
  "iter-tools-es": "7.5.3"
24
24
  },
@@ -1,13 +0,0 @@
1
- export const isArray = Array;
2
-
3
- export const notEmpty = (arr) => arr != null && arr.length > 0;
4
-
5
- export const nullOr = (arr) => (arr.length === 0 ? null : arr);
6
-
7
- export function* arraySlice(arr, start, end) {
8
- const increment = end > start ? 1 : -1;
9
-
10
- for (let i = start; i < end; i += increment) {
11
- yield arr[i];
12
- }
13
- }
@@ -1,9 +0,0 @@
1
- export const formatType = (type) => {
2
- return typeof type === 'symbol' ? `${type.description.replace(/^@bablr\//y, '')}` : `'${type}'`;
3
- };
4
-
5
- export const formatGraveString = (str) => {
6
- return `\`${str
7
- .replace(/`/g, '\\`')
8
- .replace(/[\r\n\u{00}\u{08}\u{0B}\u{0C}\u{0E}-\u{1F}]/gu, '')}\``;
9
- };
@@ -1,97 +0,0 @@
1
- export const { hasOwn, freeze, isFrozen, seal, isSealed, getOwnPropertySymbols } = Object;
2
- export const { isArray } = Array;
3
-
4
- const intFrom = (str) => {
5
- const value = parseInt(str, 10);
6
- return isNaN(value) ? null : value;
7
- };
8
-
9
- export const has = (obj, property) => {
10
- let value = obj;
11
- for (const part of property.split('.')) {
12
- if (!hasOwn(value, part)) return false;
13
- value = value[part];
14
- }
15
- return true;
16
- };
17
-
18
- export const get = (obj, property) => {
19
- let value = obj;
20
- for (const part of property.split('.')) {
21
- value = value[part];
22
- }
23
- return value;
24
- };
25
-
26
- export const set = (obj, property, value) => {
27
- const parts = property.split('.');
28
- let obj_ = obj;
29
-
30
- let lastKey;
31
- for (let i = 0; i < parts.length; i++) {
32
- const intKey = intFrom(parts[i]);
33
- const key = intKey !== null ? intKey : parts[i];
34
- let value = obj_[key];
35
-
36
- if (parts.length - 1 === i) {
37
- lastKey = key;
38
- } else if (value !== undefined) {
39
- obj_ = value;
40
- } else if (intFrom(parts[i + 1]) !== null) {
41
- obj_ = value = obj_[key] = [];
42
- } else {
43
- throw new Error(`Unable to set {property: '${property}'} in obj`);
44
- }
45
- }
46
-
47
- obj_[lastKey] = value;
48
- };
49
-
50
- export function objectKeys(obj) {
51
- return {
52
- *[Symbol.iterator]() {
53
- for (let key in obj) if (hasOwn(obj, key)) yield key;
54
- yield* getOwnPropertySymbols(obj);
55
- },
56
- };
57
- }
58
-
59
- export function objectValues(obj) {
60
- return {
61
- *[Symbol.iterator]() {
62
- for (let key in obj) if (hasOwn(obj, key)) yield obj[key];
63
- yield* getOwnPropertySymbols(obj).map((sym) => obj[sym]);
64
- },
65
- };
66
- }
67
-
68
- export function objectEntries(obj) {
69
- return {
70
- *[Symbol.iterator]() {
71
- for (let key in obj) if (hasOwn(obj, key)) yield [key, obj[key]];
72
- yield* getOwnPropertySymbols(obj).map((sym) => [sym, obj[sym]]);
73
- },
74
- };
75
- }
76
-
77
- export const isObject = (obj) => obj !== null && typeof obj === 'object';
78
- export const isFunction = (obj) => typeof obj === 'function';
79
- export const isSymbol = (obj) => typeof obj === 'symbol';
80
- export const isString = (obj) => typeof obj === 'string';
81
- export const isType = (obj) => isSymbol(obj) || isString(obj);
82
- export const isRegex = (obj) => obj instanceof RegExp;
83
- export const isPattern = (obj) => isString(obj) || isRegex(obj);
84
-
85
- export const memoize = (fn) => {
86
- const cache = new WeakMap();
87
- return (obj) => {
88
- let result;
89
- if (cache.has(obj)) {
90
- result = cache.get(obj);
91
- } else {
92
- result = fn(obj);
93
- cache.set(obj, result);
94
- }
95
- return result;
96
- };
97
- };
package/lib/utils/pump.js DELETED
@@ -1,20 +0,0 @@
1
- export class Pump {
2
- constructor() {
3
- this.held = [];
4
- }
5
-
6
- queue(value) {
7
- this.held.push(value);
8
- }
9
-
10
- next() {
11
- const held = this.held[0];
12
- if (!held) throw new Error();
13
- this.held.shift();
14
- return { done: false, value: held };
15
- }
16
-
17
- [Symbol.iterator]() {
18
- return this;
19
- }
20
- }
@@ -1,30 +0,0 @@
1
- import { buildLiteralTag, buildGapTag } from '@bablr/agast-helpers/builders';
2
-
3
- export const isNewlineToken = (token) => /^\r|\r\n|\n$/.test(token.value);
4
-
5
- export function* ownChildrenFor(range) {
6
- throw new Error('unimplemented');
7
- }
8
-
9
- export function* allChildrenFor(range) {
10
- throw new Error('unimplemented');
11
- }
12
-
13
- export function* buildTokens(chrs) {
14
- let str = '';
15
- for (const chr of chrs) {
16
- if (chr == null) {
17
- if (str) {
18
- yield buildLiteralTag(str);
19
- str = '';
20
- }
21
- yield buildGapTag();
22
- } else {
23
- str += chr;
24
- }
25
- }
26
-
27
- if (str) {
28
- yield buildLiteralTag(str);
29
- }
30
- }