JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 823
  • Score
    100M100P100Q112899F
  • License BSD-2-Clause

Intercept Iterable string - backbone for templates

Package Exports

  • iterable-string-interceptor

Readme

npm License minified size downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

iterable-string-interceptor

Intercept Iterable string - backbone for templates

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

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

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

API

Table of Contents

ExpressionTransformer

Type: ()

Parameters

  • expression string detected expression without leadIn / leadOut
  • remainder string chunk after leadOut
  • source Iterable<string> original source
  • cb EarlyConsumerCallback to be called if remainder has changed
  • leadIn string expression entry sequence
  • leadOut string expression exit sequence

Returns Iterable<string> transformed source

EarlyConsumerCallback

will be called from the ExpressionTransformer if the given remainder needs to be altered

Type: ()

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 Iterable<string> transformed source

install

With npm do:

npm install iterable-string-interceptor

license

BSD-2-Clause