Update strings.js

This commit is contained in:
Namhyeon Go 2023-01-31 11:51:38 +09:00
parent b3facdcaae
commit c187fa43a0
2 changed files with 31 additions and 2 deletions

6
helloworld.js Normal file
View File

@ -0,0 +1,6 @@
function main(args) {
console.log("Hello world");
console.log(typeof Intl);
}
exports.main = main;

View File

@ -2,7 +2,7 @@
* strings.js * strings.js
*/ */
var number_format = function(number, decimals, decPoint, thousandsSep) { // eslint-disable-line camelcase function numberFormat(number, decimals, decPoint, thousandsSep) { // eslint-disable-line camelcase
// discuss at: https://locutus.io/php/number_format/ // discuss at: https://locutus.io/php/number_format/
// original by: Jonas Raoni Soares Silva (https://www.jsfromhell.com) // original by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
// improved by: Kevin van Zonneveld (https://kvz.io) // improved by: Kevin van Zonneveld (https://kvz.io)
@ -82,4 +82,27 @@ var number_format = function(number, decimals, decPoint, thousandsSep) { // esli
return s.join(dec) return s.join(dec)
} }
exports.number_format = number_format; function splitLines(s) {
return s.split(/\r?\n/);
}
function selectLines(s, lineNumbers) {
var selected_lines = [];
var lines = splitLines(s);
for (var i = 0; i < lines.length; i++) {
if (lineNumbers.indexOf(i) > -1) {
selected_lines.push(lines[i]);
}
}
return selected_lines;
}
exports.numberFormat = numberFormat;
exports.splitLines = splitLines;
exports.selectLines = selectLines;
exports.VERSIONINFO = "Strings Library (strings.js) version 0.1.1";
exports.global = global;
exports.require = global.require;