3.0.0 • Published 2 months ago

iterable-string-interceptor v3.0.0

Weekly downloads
803
License
BSD-2-Clause
Repository
github
Last release
2 months ago

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

iterable-string-interceptor

Intercept Iterable string - backbone for template engines

import { iterableStringInterceptor } from "iterable-string-interceptor";
import { createReadStream } from "fs";
import { readFile } from "fs/promises";

// double values inside {{}}
// {{7}} -> 14
for await (const chunk of iterableStringInterceptor(createReadStream('aFile', { encoding: "utf8" }),
  expression => expression * 2
)) {
  process.stdout.write(chunk);
}
import { iterableStringInterceptor } from "iterable-string-interceptor";
import { createReadStream } from "fs";
import { readFile } from "fs/promises";

// handle expression as to be included content {{filename}}
for await (const chunk of iterableStringInterceptor(createReadStream('aFile', { encoding: "utf8" }),
  async * (expression) => { yield readFile(expression, { encoding: "utf8" }); }
)) {
  process.stdout.write(chunk);
}

API

Table of Contents

ExpressionTransformer

Type: Function

Parameters

Returns AsyncIterable[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) transformed source

EarlyConsumerCallback

Will be called from the ExpressionTransformer if the given remainder needs to be altered.

Type: Function

Parameters

  • remainder string new remainder to be used by iterableStringInterceptor

iterableStringInterceptor

Intercept into a async iterable string source, detecting lead in/outs like '{{' and '}}' and asking a transformer for a replacement iterable string.

Parameters

Returns AsyncIterable[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) transformed source

install

With npm do:

npm install iterable-string-interceptor

license

BSD-2-Clause

3.0.0

2 months ago

2.3.0

3 months ago

2.3.1

3 months ago

2.2.4

1 year ago

2.2.1

2 years ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

1.0.15

2 years ago

2.0.0

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago