Vanilla JavaScript (IIFE) for older browsers
The IIFE distribution targets browsers which don't support ECMAScript modules.
The files are located inside the packages/stream-transform/dist/iife
folder. Import them inside your project or use NPM to download the package and to reference them.
It is globally available in the page context with:
- Stream and callback API:
stream_transform.transform(/* arguments */);
- Sync API:
stream_transform_sync.transform(/* arguments */);
Example
A working demo is available in the demo/browser
directory:
With Express, expose the files with:
const app = express();
app.use('/lib/transform/',
express.static(`node_modules/stream-transform/dist/iife/`));
app.listen(3000);
The HTML code looks like:
<script src="/lib/transform/index.js"></script>
<script>
stream_transform.transform(input, handler, options, (err, data) => {
console.info(data)
});
</script>
If you wish to use the sync API, use:
<script src="/lib/transform/sync.js"></script>
<script>
const data = stream_transform_sync.transform(input, handler, options);
</script>