String splicing generator

A generator that given a string generates new strings by cutting out a random part of the original string.

const { stringSplicer } = require("chance-generators");

Let's generate some broken HTML mutations:

const htmlSnippets = stringSplicer("<h1>Hello <em>Beautiful</em> world</h1>");
 
expect(htmlSnippets.take(5), "to equal", [
  "<h1>Hello <em></h1>",
  "<h1>Hello <em>Beautiful</em> world</h1>",
  "<h1>Hello <em>Beautiful</em> 1>",
  "<h1>Hello <em>Beautifuld</h1>",
  "<h1>Heul</em> world</h1>"
]);

You can constrain the length of the strings generated by providing a min option:

const longerHtmlSnippets = stringSplicer("<h1>Hello <em>Beautiful</em> world</h1>", { min: 20 });
 
expect(longerHtmlSnippets.take(5), "to equal", [
  "<h1>Hello <em>world</h1>",
  "<h1>Hello <em>Beautiful</em> world</h1>",
  "<h1>Hello <em>Beautiful</em> 1>",
  "<h1>Hello <em>Beautifuld</h1>",
  "<h1>HeBeautiful</em> world</h1>"
]);