Skip to content

Instantly share code, notes, and snippets.

@J2D2Development
Last active August 25, 2017 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J2D2Development/5b04059f1c74abb8af88611ecb95e622 to your computer and use it in GitHub Desktop.
Save J2D2Development/5b04059f1c74abb8af88611ecb95e622 to your computer and use it in GitHub Desktop.
Custom Node Transform Stream (just removes multi-spaces)
'use strict';
const { Transform } = require('stream');
class MultiSpaceStrip extends Transform {
constructor(options) {
super(options);
}
_transform(chunk, encoding, callback) {
const text = chunk.toString();
this.push(text.replace(/\s+/g, ''));
callback();
}
}
module.exports = new MultiSpaceStrip();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment