Last active
August 25, 2017 13:04
-
-
Save J2D2Development/5b04059f1c74abb8af88611ecb95e622 to your computer and use it in GitHub Desktop.
Custom Node Transform Stream (just removes multi-spaces)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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