# iterable-string-interceptor

> Intercept iterable string - backbone for template engines

Latest version **3.1.0** (published 2026-09-18) · 0BSD license · 0 weekly downloads

## Install

```sh
npm install iterable-string-interceptor
pnpm add iterable-string-interceptor
yarn add iterable-string-interceptor
bun add iterable-string-interceptor
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2026-09-18 |
| First published | 2018-12-31 |
| Weekly downloads | 0 |
| License | 0BSD |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=24.21.0 |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Maintainers | arlac77 |
| Keywords | chunk, iterable, template |

## Links

- npm: https://www.npmjs.com/package/iterable-string-interceptor
- Repository: https://github.com/arlac77/iterable-string-interceptor
- Homepage: https://github.com/arlac77/iterable-string-interceptor#readme
- Issues: https://github.com/arlac77/iterable-string-interceptor/issues
- npm.io page: https://npm.io/package/iterable-string-interceptor

## Recent versions

- 3.1.0 (latest) — 2026-09-18
- 3.0.8 — 2026-03-12
- 3.0.7 — 2026-02-17
- 3.0.6 — 2026-01-22
- 3.0.5 — 2026-01-13
- 3.0.4 — 2026-01-13
- 3.0.3 — 2025-11-26
- 3.0.2 — 2025-05-06
- 3.0.1 — 2025-05-06
- 3.0.0 — 2024-03-08
- 2.3.1 — 2024-02-08
- 2.3.0 — 2024-02-08
- 2.2.4 — 2023-05-01
- 2.2.3 — 2022-12-30
- 2.2.2 — 2022-11-22
- … 24 more at https://npm.io/package/iterable-string-interceptor/versions

## README

[![npm](https://img.shields.io/npm/v/iterable-string-interceptor.svg)](https://www.npmjs.com/package/iterable-string-interceptor)
[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
[![bundlejs](https://deno.bundlejs.com/?q=iterable-string-interceptor\&badge=detailed)](https://bundlejs.com/?q=iterable-string-interceptor)
[![downloads](http://img.shields.io/npm/dm/iterable-string-interceptor.svg?style=flat-square)](https://npmjs.org/package/iterable-string-interceptor)
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/iterable-string-interceptor.svg?style=flat-square)](https://github.com/arlac77/iterable-string-interceptor/issues)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fiterable-string-interceptor%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/iterable-string-interceptor/goto)
[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/iterable-string-interceptor/badge.svg)](https://snyk.io/test/github/arlac77/iterable-string-interceptor)

# iterable-string-interceptor

Intercept Iterable string - backbone for template engines

<!-- skip-example -->

```javascript
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);
}
```

```javascript
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

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [ExpressionTransformer](#expressiontransformer)
    *   [Parameters](#parameters)
*   [EarlyConsumerCallback](#earlyconsumercallback)
    *   [Parameters](#parameters-1)
*   [iterableStringInterceptor](#iterablestringinterceptor)
    *   [Parameters](#parameters-2)

## ExpressionTransformer

Type: function ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, [EarlyConsumerCallback](#earlyconsumercallback), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)): AsyncIterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>

### Parameters

*   `expression` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** detected expression without leadIn / leadOut
*   `remainder` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** chunk after leadOut
*   `source` **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** original source
*   `cb` **[EarlyConsumerCallback](#earlyconsumercallback)** to be called if remainder has changed
*   `leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression entry sequence
*   `leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression exit sequence

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 ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)): void

### Parameters

*   `remainder` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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

*   `source` **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
*   `transform` **[ExpressionTransformer](#expressiontransformer)**&#x20;
*   `leadIn` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression entry sequence (optional, default `"{{"`)
*   `leadOut` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** expression exit sequence (optional, default `"}}"`)

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

# install

With [npm](http://npmjs.org) do:

```shell
npm install iterable-string-interceptor
```

# license

BSD-2-Clause

---
_Source: https://npm.io/package/iterable-string-interceptor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
