octo-deno/utils/block.js

37 lines
729 B
JavaScript
Raw Normal View History

2017-04-13 13:20:04 +00:00
utils.block = {
block: function(list, optional) {
if (optional == true) {
if (random.chance(6)) {
return '';
}
}
function go_deeper(item) {
if (item == null || item === undefined) {
return "";
}
if (typeof(item) == "function") {
return item();
}
if (typeof(item) == "string") {
return item;
}
if (item instanceof(Array)) {
2017-04-22 19:02:38 +00:00
let s = "";
for (let i = 0; i < item.length; i++) {
2017-04-13 13:20:04 +00:00
s += go_deeper(item[i]);
}
return s;
}
return item;
}
2017-04-22 19:02:38 +00:00
let asString = "";
for (let i = 0; i < list.length; i++) {
2017-04-13 13:20:04 +00:00
asString += go_deeper(list[i]);
}
return asString;
}
};