@mwilki7/

VengefulWood

Nodejs

No description

fork
loading
Files
  • index.js
  • stories
  • adjectives.txt
  • nouns.txt
  • package-lock.json
  • package.json
  • verbs.txt

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.2648742623196614","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCi8vIFZlbmdlZnVsV29vZCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyBieSBNaWNoYWVsIFdpbGtpZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vIFRoaXMgcHJvZ3JhbSBpcyB0byBwbGF5IHdpdGggcG9wdWxhciBudXJzZXJ5IHJoeW1lcy9zdG9yaWVzIGFuZCB0dXJuIHRoZW0gaW50byAvLwovLyBpbXByb3Ygc2VnbWVudHMgKGlzIHRoYXQgdGhlIHJpZ2h0IHdvcmRpbmc/KS4gIEl0IHdpbGwgc2NyYW1ibGUgcHJlZGV0ZXJtaW5lZCAgLy8KLy8gbm91bnMsIHZlcmJzLCBhbmQgYWRqZWN0aXZlcyB0byBtYWtlIHRoZSBzdG9yeSBzb3VuZCByaWRpY3Vsb3VzLiAgICAgICAgICAgICAgIC8vCi8vICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyBJZiB5b3Ugd2lzaCB0byBpbXBvcnQgeW91ciBvd24gc3Rvcnk6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgICBDb3B5IHBhc3RlIGEgdGV4dCBmaWxlIGluIHRoZSAic3RvcmllcyIgZm9sZGVyICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICAgUmVwbGFjZSBhbGwgbm91bnMgeW91IHdhbnQgcmVwbGFjZWQgd2l0aCAjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgIFJlcGxhY2UgYWxsIHByZXNlbnQtdGVuc2UgdmVyYnMgeW91IHdhbnQgcmVwbGFjZWQgd2l0aCAkICAgICAgICAgICAgICAgICAgLy8KLy8gICAgICBSZXBsYWNlIGFsbCBhZGplY3RpdmVzIHlvdSB3YW50IHJlcGxhY2VkIHdpdGggQCAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICAgU2VsZWN0IHlvdXIgc3RvcnkgYXQgdGhlIG1haW4gbWVudSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCgovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwovLyBHZXQgdHlwaWNhbCBsaWJyYXJpZXMgZm9yIGZpbGUgcmVhZGluZyAvLwovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwp2YXIgZnMgPSByZXF1aXJlKCJmcyIpOwpjb25zdCByZWFkbGluZSA9IHJlcXVpcmUoJ3JlYWRsaW5lLXN5bmMnKTsKCnZhciBTVE9SSUVTX0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8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwovLyAgICAgICAgICAgICAgICAgIGdldFJhbmRvbUFkamVjdGl2ZSAgICAgICAgICAgICAgICAgICAgIC8vCi8vIEZ1bmN0aW9uOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIFJldHVybiBhIHJhbmRvbSBhZGplY3RpdmUgZnJvbSB0aGUgYWRqZWN0aXZlcyBhcnJheSAvLwovLyBSZXR1cm4gdmFsdWU6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBzdHJpbmcgZnJvbSB0aGUgYWRqZWN0aXZlcyBhcnJheSAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwpmdW5jdGlvbiBnZXRSYW5kb21BZGplY3RpdmUoKQp7CiAgICByZXR1cm4gYWRqZWN0aXZlc1tNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkqYWRqZWN0aXZlcy5sZW5ndGgpXTsKfQovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCi8vICAgICAgICAgICAgICAgICBnZXRSYW5kb21Ob3VuICAgICAgICAgICAgICAgICAgLy8KLy8gRnVuY3Rpb246ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgUmV0dXJucyBhIHJhbmRvbSBub3VuIGZyb20gdGhlIG5vdW5zIGFycmF5IC8vCi8vIFJldHVybiB2YWx1ZTogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIHN0cmluZyBmcm9tIHRoZSBub3VucyBhcnJheSAgICAgICAgICAgICAgICAvLwovLy8vLy8vLy8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Bmcm9tIHRoZSBub3VucyBhcnJheSAgICAgICAgICAgICAgIC8vCi8vICAgICBSZXBsYWNlcyBhbGwgJ0AnIHdpdGggYWRqZWN0aXZlcyBmcm9tIHRoZSBhZGplY3RpdmVzIGFycmF5ICAgICAvLwovLyAgICAgUmVwbGFjZXMgYWxsICckJyB3aXRoIHZlcmJzIGZyb20gdGhlIHZlcmJzIGFycmF5ICAgICAgICAgICAgICAgLy8KLy8gUmV0dXJuIHZhbHVlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBBcnJheSBvZiBzdHJpbmdzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KZnVuY3Rpb24gZmlsbEluQmxhbmtzKHN0b3J5ZmlsZSkKewogICAgdmFyIG5ld3N0b3J5ID0gW107CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHN0b3J5ZmlsZS5sZW5ndGg7IGkrKykKICAgIHsKICAgICAgICB2YXIgbGluZSA9IHN0b3J5ZmlsZVtpXTsKICAgICAgICB3aGlsZSAobGluZS5pbmNsdWRlcygiIyIpIHx8IGxpbmUuaW5jbHVkZXMoIkAiKSB8fCBsaW5lLmluY2x1ZGVzKCIkIikpCiAgICAgICAgewogICAgICAgICAgICBsaW5lID0gbGluZS5yZXBsYWNlKCJAIiwgZ2V0UmFuZG9tQWRqZWN0aXZlKCkpOwogICAgICAgICAgICBsaW5lID0gbGluZS5yZXBsYWNlKCIjIiwgZ2V0UmFuZG9tTm91biAgICAgKCkpOwogICAgICAgICAgICBsaW5lID0gbGluZS5yZXBsYWNlKCIkIiwgZ2V0UmFuZG9tVmVyYiAgICAgKCkpOwogICAgICAgIH0KICAgICAgICBuZXdzdG9yeS5wdXNoKGxpbmUpOwogICAgfQogICAgcmV0dXJuIG5ld3N0b3J5Owp9Ci8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCi8vICAgICAgICAgICAgICAgICBwcmludEFycmF5ICAgICAgICAgICAgICAgIC8vCi8vIEZ1bmN0aW9uOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBQcmludHMgZWFjaCBlbGVtZW50IGluIGFyciB0byBjb25zb2xlIC8vCi8vIFJldHVybiB2YWx1ZTogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBObyByZXR1cm4gdmFsdWUgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCmZ1bmN0aW9uIHByaW50QXJyYXkoYXJyKQp7CiAgICBhcnIuZm9yRWFjaChmdW5jdGlvbihlKQogICAgewogICAgICAgIGNvbnNvbGUubG9nKGUpOwogICAgfSk7Cn0KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gICAgICAgICAgICAgICAgY29udGFpbnNOZXdsaW5lQ2hhcmFjdGVyICAgICAgICAgICAgICAgLy8KLy8gRnVuY3Rpb246ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIFJldHVybnMgdHJ1dGggdmFsdWUgd2hldGhlciBvciBub3Qgc3RyIGNvbnRhaW5zIGEgLy8KLy8gICAgIG5ld2xpbmUgY2hhcmFjdGVyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gUmV0dXJuIHZhbHVlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIGJvb2xlYW4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KZnVuY3Rpb24gY29udGFpbnNOZXdsaW5lQ2hhcmFjdGVyKHN0cikKewogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyBpKyspCiAgICB7CiAgICAgICAgaWYgKHN0cltpXSA9PT0gJ1xuJyB8fCBzdHJbaV0gPT09ICdccicpCiAgICAgICAgewogICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gZmFsc2U7Cn0KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwovLyAgICAgICAgICAgICAgICAgICAgICAgIGdldEZpbGVOYW1lcyAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vIEZ1bmN0aW9uOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIFJldHVybnMgc3RyaW5nIGluIGRpcmVjdG9yeWZpbGVzIGFycmF5IHdpdGggZm9ybWF0dGluZyAvLwovLyBSZXR1cm4gdmFsdWU6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBzdHJpbmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwpmdW5jdGlvbiBnZXRGaWxlTmFtZXMoKQp7CiAgICB2YXIgc3RyID0gJyc7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGRpcmVjdG9yeWZpbGVzLmxlbmd0aDsgaSsrKQogICAgewogICAgICAgIHZhciBmaWxlbmFtZSA9IGRpcmVjdG9yeWZpbGVzW2ldOwogICAgICAgIHN0ciArPSBpICsgIl0gIiArIGZpbGVuYW1lICsgIlxuIjsKICAgIH0KICAgIHJldHVybiBzdHI7Cn0KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gICAgICAgICAgICAgICAgICAgIGxvYWRTdG9yeSAgICAgICAgICAgICAgICAgICAgLy8KLy8gRnVuY3Rpb246ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIEluaXRpYXRlcyBzdG9yeSBhcnJheSB1c2luZyBmcyBhbmQgZmlsZW5hbWUgLy8KLy8gUmV0dXJuIHZhbHVlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIE5vIHJldHVybiB2YWx1ZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8gICAgIGNvbnNvbGUgb3V0cHV0IGdlbmVyYXRlZCAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KZnVuY3Rpb24gbG9hZFN0b3J5KGZpbGVuYW1lKQp7CiAgICBzdG9yeSA9IGZzLnJlYWRGaWxlU3luYyhmaWxlbmFtZSkudG9TdHJpbmcoKS5zcGxpdCgiXG4iKTsKICAgIHN0YXJ0KCk7ICAgIAp9Ci8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcnkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyBGdW5jdGlvbjogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBSZWFkcyB0ZXh0IGZpbGUgYW5kIHBvcHVsYXRlcyAjIGFuZCBAIHdpdGggbm91bnMgYW5kIGFkamVjdGl2ZXMgLy8KLy8gUmV0dXJuIHZhbHVlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgTm8gcmV0dXJuIHZhbHVlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBjb25zb2xlIG91dHB1dCBnZW5lcmF0ZWQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwpmdW5jdGlvbiBzdGFydCgpCnsKICAgIHN0b3J5ID0gZmlsbEluQmxhbmtzKHN0b3J5KTsKICAgIHByaW50QXJyYXkoc3RvcnkpOwp9Ci8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovLwovLyAgICAgICAgICAgICAgICBQcm9ncmFtIGV4ZWN1dGlvbiBiZWdpbnMgaGVyZSogICAgICAgICAgICAgICAgICAgLy8KLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8vCi8vICppZ25vcmluZyBsaWJyYXJ5IGltcG9ydGF0aW9uIGFzIGV4ZWN1dGlvbiAgICAgICAgICAgICAgICAgICAgICAvLwovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KCi8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwovLyBCZWdpbiBmaWxlIHJlYWRpbmcgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCmNvbnNvbGUubG9nKCJGaXJzdCBmaWxlIHJlYWQiKTsKYWRqZWN0aXZlcyA9IGZzLnJlYWRGaWxlU3luYygnYWRqZWN0aXZlcy50eHQnKS50b1N0cmluZygpLnNwbGl0KCJcbiIpOwpjb25zb2xlLmxvZygiU2Vjb25kIGZpbGUgcmVhZCIpOwpub3VucyA9IGZzLnJlYWRGaWxlU3luYygnbm91bnMudHh0JykudG9TdHJpbmcoKS5zcGxpdCgiXG4iKTsKY29uc29sZS5sb2coIlRoaXJkIGZpbGUgcmVhZCIpOwp2ZXJicyA9IGZzLnJlYWRGaWxlU3luYygndmVyYnMudHh0JykudG9TdHJpbmcoKS5zcGxpdCgiXG4iKTsKbWFpbigpOwovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1haW4gICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vIEZ1bmN0aW9uOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgR2F0aGVycyB1c2VyIGlucHV0IHRvIHBpY2sgYSBzdG9yeSB0aGV5IHdhbnQgaW1wcm92J2QgLy8KLy8gUmV0dXJuIHZhbHVlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vCi8vICAgICBObyByZXR1cm4gdmFsdWUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLwovLyAgICAgY29uc29sZSBvdXRwdXQgZ2VuZXJhdGVkICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8KLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCmZ1bmN0aW9uIG1haW4oKQp7CiAgICBjb25zb2xlLmxvZygiRmlsZXMgcmVhZCIpOwoKICAgIC8vIFJlYWQgL3N0b3JpZXMvIGRpcmVjdG9yeSBmb3IgYXZhaWxhYmxlIHRleHQgZmlsZXMgdG8gbW9kaWZ5CiAgICBkaXJlY3RvcnlmaWxlcyA9IGZzLnJlYWRkaXJTeW5jKFJPT1RfRElSICsgU1RPUklFU19ESVIpOwoKICAgIHZhciB1c2VyaW5wdXQgPScnOwoKICAgIHdoaWxlICh1c2VyaW5wdXQudG9Mb3dlckNhc2UoKSAhPSAnZXhpdCcpCiAgICB7CiAgICAgICAgdXNlcmlucHV0ID0gcmVhZGxpbmUucXVlc3Rpb24oYFdoaWNoIHN0b3J5IHdvdWxkIHlvdSBsaWtlIHRvIHJlYWQgYWJvdXQ/XG5gIAogICAgICAgICsgZ2V0RmlsZU5hbWVzKCkKICAgICAgICArICJbRW50ZXJdIHRvIHJlZnJlc2giICsgIlxuIgogICAgICAgICsgIidFeGl0JyB0byBzdG9wIHRoZSBwcm9ncmFtIik7CiAgICAgICAgaWYgKHVzZXJpbnB1dC50b0xvd2VyQ2FzZSgpID09ICJleGl0IikKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgdmFyIHVzZXJpbnB1dF9pbnQgPSBOdW1iZXIodXNlcmlucHV0KTsKICAgICAgICAgICAgaWYgKHVzZXJpbnB1dF9pbnQgPT0gTmFOIAogICAgICAgICAgICAgfHwgdXNlcmlucHV0X2ludCA8ICAwCiAgICAgICAgICAgICB8fCB1c2VyaW5wdXRfaW50ID4gIGRpcmVjdG9yeWZpbGVzLmxlbmd0aCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkludmFsaWQgaW5wdXQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmICh1c2VyaW5wdXQubGVuZ3RoID49IDEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbG9hZFN0b3J5KFNUT1JJRVNfRElSICsgZGlyZWN0b3J5ZmlsZXNbdXNlcmlucHV0X2ludF0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNsZWFyc2NyZWVuKCk7CiAgICB9CiAgICBjb25zb2xlLmxvZygiUHJvZ3JhbSBlbmQiKTsKfQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
////////////////////////////////////////////////////////////////////////////////////
// VengefulWood                                                                   //
// by Michael Wilkie                                                              //
//                                                                                //
// This program is to play with popular nursery rhymes/stories and turn them into //
// improv segments (is that the right wording?).  It will scramble predetermined  //
// nouns, verbs, and adjectives to make the story sound ridiculous.               //
//                                                                                //
// If you wish to import your own story:                                          //
//      Copy paste a text file in the "stories" folder                            //
//      Replace all nouns you want replaced with #                                //
//      Replace all present-tense verbs you want replaced with $                  //
//      Replace all adjectives you want replaced with @                           //
//      Select your story at the main menu                                        //
//                                                                                //
////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////
// Get typical libraries for file reading //
////////////////////////////////////////////
var fs = require("fs");
const readline = require('readline-sync');

var STORIES_DIR = "stories/";
var ROOT_DIR    = process.cwd() + "/";
var directoryfiles = []; // array that will contain files in stories folder
var adjectives = []; // array that will contain all the lines from adjectives.txt
var nouns      = []; // array that will contain all the lines from nouns.txt
var verbs      = []; // array that will contian all the lines from verbs.txt
var story      = []; // array that will contain all the lines from user input story

////////////////////////////////////
//          clearscreen           //
// Function:                      //
//     Clear the linux console    //
// Return value:                  //
//     No return value            //
//     console output generated?  //
////////////////////////////////////
function clearscreen()
{
   // console.log("\033[H\033[J");
}
/////////////////////////////////////////////////////////////
//                  getRandomAdjective                     //
// Function:                                               //
//     Return a random adjective from the adjectives array //
// Return value:                                           //
//     string from the adjectives array                    //
/////////////////////////////////////////////////////////////
function getRandomAdjective()
{
    return adjectives[Math.floor(Math.random()*adjectives.length)];
}
////////////////////////////////////////////////////
//                 getRandomNoun                  //
// Function:                                      //
//     Returns a random noun from the nouns array //
// Return value:                                  //
//     string from the nouns array                //
////////////////////////////////////////////////////
function getRandomNoun()
{
    return nouns[Math.floor(Math.random()*nouns.length)];
}
////////////////////////////////////////////////////
//                 getRandomVerb                  //
// Function:                                      //
//     Returns a random verb from the verbs array //
// Return value:                                  //
//     string from the verbs array                //
////////////////////////////////////////////////////
function getRandomVerb()
{
    return verbs[Math.floor(Math.random()*verbs.length)];
}
////////////////////////////////////////////////////////////////////////
//                         fillInBlanks                               //
// Function:                                                          //
//     Replaces all '#' with nouns from the nouns array               //
//     Replaces all '@' with adjectives from the adjectives array     //
//     Replaces all '$' with verbs from the verbs array               //
// Return value:                                                      //
//     Array of strings                                               //
////////////////////////////////////////////////////////////////////////
function fillInBlanks(storyfile)
{
    var newstory = [];
    for (var i = 0; i < storyfile.length; i++)
    {
        var line = storyfile[i];
        while (line.includes("#") || line.includes("@") || line.includes("$"))
        {
            line = line.replace("@", getRandomAdjective());
            line = line.replace("#", getRandomNoun     ());
            line = line.replace("$", getRandomVerb     ());
        }
        newstory.push(line);
    }
    return newstory;
}
///////////////////////////////////////////////
//                 printArray                //
// Function:                                 //
//     Prints each element in arr to console //
// Return value:                             //
//     No return value                       //
///////////////////////////////////////////////
function printArray(arr)
{
    arr.forEach(function(e)
    {
        console.log(e);
    });
}
///////////////////////////////////////////////////////////
//                containsNewlineCharacter               //
// Function:                                             //
//     Returns truth value whether or not str contains a //
//     newline character                                 //
// Return value:                                         //
//     boolean                                           //
///////////////////////////////////////////////////////////
function containsNewlineCharacter(str)
{
    for (var i = 0; i < str.length; i++)
    {
        if (str[i] === '\n' || str[i] === '\r')
        {
            return true;
        }
    }
    return false;
}
////////////////////////////////////////////////////////////////
//                        getFileNames                        //
// Function:                                                  //
//     Returns string in directoryfiles array with formatting //
// Return value:                                              //
//     string                                                 //
////////////////////////////////////////////////////////////////
function getFileNames()
{
    var str = '';
    for (var i = 0; i < directoryfiles.length; i++)
    {
        var filename = directoryfiles[i];
        str += i + "] " + filename + "\n";
    }
    return str;
}
/////////////////////////////////////////////////////
//                    loadStory                    //
// Function:                                       //
//     Initiates story array using fs and filename //
// Return value:                                   //
//     No return value                             //
//     console output generated                    //
/////////////////////////////////////////////////////
function loadStory(filename)
{
    story = fs.readFileSync(filename).toString().split("\n");
    start();    
}
/////////////////////////////////////////////////////////////////////////
//                               story                                 //
// Function:                                                           //
//     Reads text file and populates # and @ with nouns and adjectives //
// Return value:                                                       //
//     No return value                                                 //
//     console output generated                                        //
/////////////////////////////////////////////////////////////////////////
function start()
{
    story = fillInBlanks(story);
    printArray(story);
}
//*****************************************************************//
//                Program execution begins here*                   //
//*****************************************************************//
// *ignoring library importation as execution                      //
/////////////////////////////////////////////////////////////////////

////////////////////////
// Begin file reading //
////////////////////////
console.log("First file read");
adjectives = fs.readFileSync('adjectives.txt').toString().split("\n");
console.log("Second file read");
nouns = fs.readFileSync('nouns.txt').toString().split("\n");
console.log("Third file read");
verbs = fs.readFileSync('verbs.txt').toString().split("\n");
main();
///////////////////////////////////////////////////////////////
//                             main                          //
// Function:                                                 //
//     Gathers user input to pick a story they want improv'd //
// Return value:                                             //
//     No return value                                       //
//     console output generated                              //
///////////////////////////////////////////////////////////////
function main()
{
    console.log("Files read");

    // Read /stories/ directory for available text files to modify
    directoryfiles = fs.readdirSync(ROOT_DIR + STORIES_DIR);

    var userinput ='';

    while (userinput.toLowerCase() != 'exit')
    {
        userinput = readline.question(`Which story would you like to read about?\n` 
        + getFileNames()
        + "[Enter] to refresh" + "\n"
        + "'Exit' to stop the program");
        if (userinput.toLowerCase() == "exit")
        {
            return;
        }
        else
        {
            var userinput_int = Number(userinput);
            if (userinput_int == NaN 
             || userinput_int <  0
             || userinput_int >  directoryfiles.length)
            {
                console.log("Invalid input");
            }
            else
            {
                if (userinput.length >= 1)
                {
                    loadStory(STORIES_DIR + directoryfiles[userinput_int]);
                }
            }
        }
        clearscreen();
    }
    console.log("Program end");
}
node v10.16.0