Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including deliedit with all npm packages installed. Try it out:

var deliedit = require("deliedit")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

deliedit v1.1.1

Node js delimited text editing library.

node-deliedit

Node js delimited text editing library.

npm version Build Status

Node js library for editing stream of text based on delimiters.

For example:

...
<html lang="en">
...
    before delimiter

    <!-- startedit: html -->

    in delimiter

    <!-- endedit: html -->

    after delimiter
...
</html>

with:

var Deliedit = require('deliedit').Deliedit;
var uppercase = function(char) { return char.toUpperCase(); };

var deliedit = new Deliedit({
  delimiters: {
    start: '<!-- startedit: html -->',
    end: '<!-- endedit: html -->'
  },
  invert: false,
  withDelimiters: true,
  transformFunc: uppercase
});

fs.createReadStream('in.html').pipe(deliedit).pipe(process.stdout);

results in:

...
<html lang="en">
...
    before delimiter

    <!-- startedit: html -->

    IN DELIMITER

    <!-- endedit: html -->

    after delimiter
...
</html>

Options

var deliedit = new Delimiter(opts);

where:

  • opts.delimiter.start - start delimiter

  • opts.delimiter.end - end delimiter

  • opts.invert - apply transformation function to inside delimiter (if false) or outside delimiter (if true)

  • opts.withDelimiters - include delimiters themselves in output

  • opts.transformFunc - transformation function: passthrough, ignorechar, uppercase available - defaults to passthrough

  • opts.transform - DEPRECATED

TODO

  • Add support for some other internal transformations eg. html comment / uncomment js comment / uncomment
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free