a common use-case i have is counting newlines in largish (> 200kb) embedded-js
files, like this real-world example [1]. ultimately meant for
line-number-preservation purposes in auto-lint/auto-prettify tasks (which have
been getting slower due to complexity).
would a new RegExp count-method like ```(/\n/g).count(largeCode)``` be
significantly more efficient than existing ```largeCode.split("\n").length -
1``` or ```largeCode.replace((/[^\n]+/g), "").length```?
-kai
[1] calculating and reproducing line-number offsets when linting/autofixing
files
https://github.com/kaizhu256/node-utility2/blob/2018.12.30/lib.jslint.js#L7377
<https://github.com/kaizhu256/node-utility2/blob/2018.12.30/lib.jslint.js#L7377>
https://github.com/kaizhu256/node-utility2/blob/2018.12.30/lib.jslint.js#L7586
<https://github.com/kaizhu256/node-utility2/blob/2018.12.30/lib.jslint.js#L7586>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss