@bablr/agast-helpers 0.5.2 → 0.5.3

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.
Files changed (2) hide show
  1. package/lib/stream.js +22 -25
  2. package/package.json +4 -2
package/lib/stream.js CHANGED
@@ -264,7 +264,7 @@ function* __generateAllOutput(tags) {
264
264
  export const generateAllOutput = (tags) => new StreamIterable(__generateAllOutput(tags));
265
265
 
266
266
  export const printCSTML = (tags) => {
267
- return stringFromStream(generateStandardOutput(generateCSTMLStrategy(tags)));
267
+ return stringFromStream(generateCSTML(tags));
268
268
  };
269
269
 
270
270
  function* __emptyStreamIterator() {}
@@ -309,11 +309,11 @@ export const stringFromStream = (stream) => {
309
309
  return str;
310
310
  };
311
311
 
312
- function* __generateCSTMLStrategy(tags, options) {
312
+ function* __generateCSTML(tags, options) {
313
313
  let { emitEffects = false, inline: inlineOption = true } = options;
314
314
 
315
315
  if (!tags) {
316
- yield buildWriteEffect('<//>');
316
+ yield '<//>';
317
317
  return;
318
318
  }
319
319
 
@@ -332,32 +332,32 @@ function* __generateCSTMLStrategy(tags, options) {
332
332
  const tag = co.value;
333
333
 
334
334
  if (tag.type === ReferenceTag && prevTag.type === NullTag) {
335
- yield buildWriteEffect(' ');
335
+ yield ' ';
336
336
  }
337
337
 
338
338
  if (tag.type === 'Effect') {
339
339
  const effect = tag.value;
340
340
  if (emitEffects && effect.verb === 'write') {
341
- yield buildWriteEffect(effect.value.text, effect.value.options);
341
+ yield effect.value.text, effect.value.options;
342
342
  }
343
343
  continue;
344
344
  }
345
345
 
346
346
  if (tag.type === TokenGroup) {
347
347
  const intrinsicValue = getCooked(tag.value);
348
- yield buildWriteEffect(printSelfClosingNodeTag(tag.value[0], intrinsicValue));
348
+ yield printSelfClosingNodeTag(tag.value[0], intrinsicValue);
349
349
  } else {
350
- yield buildWriteEffect(printTag(tag));
350
+ yield printTag(tag);
351
351
  }
352
352
 
353
353
  prevTag = tag;
354
354
  }
355
355
 
356
- yield buildWriteEffect('\n');
356
+ yield '\n';
357
357
  }
358
358
 
359
- export const generateCSTMLStrategy = (tags, options = {}) =>
360
- new StreamIterable(__generateCSTMLStrategy(tags, options));
359
+ export const generateCSTML = (tags, options = {}) =>
360
+ new StreamIterable(__generateCSTML(tags, options));
361
361
 
362
362
  const isToken = (tag) => {
363
363
  return tag.value.flags.token;
@@ -436,11 +436,11 @@ function* __prettyGroupTokens(tags) {
436
436
  }
437
437
  }
438
438
 
439
- function* __generatePrettyCSTMLStrategy(tags, options) {
439
+ function* __generatePrettyCSTML(tags, options) {
440
440
  let { indent = ' ', emitEffects = false, inline: inlineOption = true } = options;
441
441
 
442
442
  if (!tags) {
443
- yield buildWriteEffect('<//>');
443
+ yield '<//>';
444
444
  return;
445
445
  }
446
446
 
@@ -465,10 +465,7 @@ function* __generatePrettyCSTMLStrategy(tags, options) {
465
465
  const effect = tag.value;
466
466
  if (emitEffects && effect.verb === 'write') {
467
467
  const writeEffect = getEmbeddedExpression(effect.value);
468
- yield buildWriteEffect(
469
- (first ? '' : '\n') + writeEffect.text,
470
- getEmbeddedExpression(writeEffect.options),
471
- );
468
+ yield (first ? '' : '\n') + writeEffect.text, getEmbeddedExpression(writeEffect.options);
472
469
 
473
470
  inline = false;
474
471
  first = false;
@@ -486,7 +483,7 @@ function* __generatePrettyCSTMLStrategy(tags, options) {
486
483
  tag.type === TokenGroup);
487
484
 
488
485
  if (!first && !inline) {
489
- yield buildWriteEffect('\n');
486
+ yield '\n';
490
487
  }
491
488
 
492
489
  if (tag.type === CloseNodeTag || tag.type === CloseFragmentTag) {
@@ -499,17 +496,17 @@ function* __generatePrettyCSTMLStrategy(tags, options) {
499
496
  }
500
497
 
501
498
  if (!inline) {
502
- yield buildWriteEffect(indent.repeat(indentLevel));
499
+ yield indent.repeat(indentLevel);
503
500
  } else {
504
- yield buildWriteEffect(' ');
501
+ yield ' ';
505
502
  }
506
503
 
507
504
  if (tag.type === TokenGroup) {
508
505
  ref = null;
509
506
  const intrinsicValue = tag.value[0].value.flags.token ? getCooked(tag.value) : null;
510
- yield buildWriteEffect(printSelfClosingNodeTag(tag.value[0], intrinsicValue));
507
+ yield printSelfClosingNodeTag(tag.value[0], intrinsicValue);
511
508
  } else {
512
- yield buildWriteEffect(printTag(tag));
509
+ yield printTag(tag);
513
510
  }
514
511
 
515
512
  if (tag.type === ReferenceTag) {
@@ -524,15 +521,15 @@ function* __generatePrettyCSTMLStrategy(tags, options) {
524
521
  first = false;
525
522
  }
526
523
 
527
- yield buildWriteEffect('\n');
524
+ yield '\n';
528
525
  }
529
526
 
530
- export const generatePrettyCSTMLStrategy = (tags, options = {}) => {
531
- return new StreamIterable(__generatePrettyCSTMLStrategy(tags, options));
527
+ export const generatePrettyCSTML = (tags, options = {}) => {
528
+ return new StreamIterable(__generatePrettyCSTML(tags, options));
532
529
  };
533
530
 
534
531
  export const printPrettyCSTML = (tags, options = {}) => {
535
- return stringFromStream(generateStandardOutput(generatePrettyCSTMLStrategy(tags, options)));
532
+ return stringFromStream(generatePrettyCSTML(tags, options));
536
533
  };
537
534
 
538
535
  export const getCooked = (tags) => {
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@bablr/agast-helpers",
3
3
  "description": "Helper functions for working with agAST trees",
4
- "version": "0.5.2",
4
+ "version": "0.5.3",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
- "files": ["lib"],
7
+ "files": [
8
+ "lib"
9
+ ],
8
10
  "exports": {
9
11
  "./btree": "./lib/btree.js",
10
12
  "./builders": "./lib/builders.js",