Package Exports
- iterable-string-interceptor
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (iterable-string-interceptor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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
expressionstring detected expression without leadIn / leadOutremainderstring chunk after leadOutsourceIterable<string> original sourcecbEarlyConsumerCallback to be called if remainder has changedleadInstring expression entry sequenceleadOutstring 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
remainderstring 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
sourceIterable<string>transformExpressionTransformerleadInstring expression entry sequence (optional, default"{{")leadOutstring expression exit sequence (optional, default"}}")
Returns Iterable<string> transformed source
install
With npm do:
npm install iterable-string-interceptorlicense
BSD-2-Clause
