-
Notifications
You must be signed in to change notification settings - Fork 1
/
temp.js
40 lines (34 loc) · 833 Bytes
/
temp.js
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
var isIterable = function (stuff) {
if(stuff)
{
return typeof stuff[Symbol.iterator] === 'function';
}
return false;
}
var isString = function (stuff) {
return typeof stuff === 'string';
}
var nodeToString = (stuff) =>
{
if (stuff.outerHTML) { return stuff.outerHTML; }
if (isIterable(stuff)) {
if (isString(stuff)) {return stuff;}
var temp_string = '';
stuff = Array.prototype.slice.call(stuff);
stuff.forEach(function(v){
if(v.outerHTML){ temp_string = temp_string + v.outerHTML+"\n";}
else {temp_string = temp_string + v + "\n";}
});
return temp_string;
};
};
var allNodesToString = (...stuffs) =>
{
stuffs = Array.prototype.slice.call(stuffs);
if(!stuffs){return false;}
var s = '';
stuffs.forEach(function(stuff){
s = s + nodeToString(stuff);
});
return s;
}