@bablr/agast-helpers 0.5.0 → 0.5.2

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/lib/builders.js CHANGED
@@ -45,6 +45,7 @@ export const buildEmbeddedExpression = (expr) => {
45
45
  };
46
46
 
47
47
  export const buildEmbeddedTag = (tag) => {
48
+ if (!isObject(tag)) return tag;
48
49
  return freeze({ type: EmbeddedTag, value: tag });
49
50
  };
50
51
 
@@ -63,6 +64,15 @@ export const buildWriteEffect = (text, options = {}) => {
63
64
  );
64
65
  };
65
66
 
67
+ export const buildYieldEffect = (tag) => {
68
+ return buildEffect(
69
+ freeze({
70
+ verb: 'yield',
71
+ value: buildEmbeddedTag(freeze(tag)),
72
+ }),
73
+ );
74
+ };
75
+
66
76
  export const buildAnsiPushEffect = (spans = '') => {
67
77
  return buildEffect(
68
78
  freeze({
package/lib/tree.js CHANGED
@@ -166,8 +166,8 @@ function* __treeFromStream(tokens) {
166
166
  case OpenFragmentTag: {
167
167
  const { flags } = tag.value;
168
168
 
169
- const language = doctype.value.attributes['bablr-language'];
170
- const attributes = doctype.value.attributes;
169
+ const { attributes } = doctype.value;
170
+ const language = attributes['bablr-language'];
171
171
 
172
172
  const node = freeze({
173
173
  flags,
@@ -552,6 +552,16 @@ export const getRoot = (node) => {
552
552
  return node.type == null ? node.properties['.'] : node;
553
553
  };
554
554
 
555
+ export function* traverseProperties(properties) {
556
+ for (const value of Object.values(properties)) {
557
+ if (isArray(value)) {
558
+ yield* btree.traverse(value);
559
+ } else {
560
+ yield value;
561
+ }
562
+ }
563
+ }
564
+
555
565
  export class Resolver {
556
566
  constructor(
557
567
  states = emptyStack.push({ properties: new Map(), idx: 0 }),
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@bablr/agast-helpers",
3
3
  "description": "Helper functions for working with agAST trees",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
- "files": [
8
- "lib"
9
- ],
7
+ "files": ["lib"],
10
8
  "exports": {
11
9
  "./btree": "./lib/btree.js",
12
10
  "./builders": "./lib/builders.js",
@@ -20,7 +18,7 @@
20
18
  },
21
19
  "sideEffects": false,
22
20
  "dependencies": {
23
- "@bablr/btree": "0.1.0",
21
+ "@bablr/btree": "^0.1.0",
24
22
  "@bablr/coroutine": "0.1.0",
25
23
  "@iter-tools/imm-stack": "1.1.0"
26
24
  },