3.0.0 • Published 1 year ago

iterable-string-interceptor v3.0.0

Weekly downloads
803
License
BSD-2-Clause
Repository
github
Last release
1 year 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

1 year ago

2.3.0

1 year ago

2.3.1

1 year ago

2.2.4

2 years ago

2.2.1

3 years ago

2.2.3

2 years ago

2.2.2

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

1.0.15

3 years ago

2.0.0

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago