a zip code crypto-currency system good for red ONLY

helpers.js 487B

123456789101112131415161718192021222324
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. exports.getNumberOfLines = function getNumberOfLines(str) {
  7. let nr = -1;
  8. let idx = -1;
  9. do {
  10. nr++
  11. idx = str.indexOf("\n", idx + 1);
  12. } while(idx >= 0);
  13. return nr;
  14. };
  15. exports.getUnfinishedLine = function getUnfinishedLine(str) {
  16. const idx = str.lastIndexOf("\n");
  17. if(idx === -1)
  18. return str.length;
  19. else
  20. return str.length - idx - 1;
  21. };