2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-14 18:42:24 +03:00

add eslint, travis config, test tasks

This commit is contained in:
Nikolay Kostyurin
2018-06-11 22:31:02 +02:00
parent 305643daa2
commit 792e949b6e
36 changed files with 6529 additions and 434 deletions
+3
View File
@@ -0,0 +1,3 @@
package-lock.json
coverage
dist
+5
View File
@@ -0,0 +1,5 @@
package-lock.json
coverage
src
dist
!lib
+2
View File
@@ -0,0 +1,2 @@
# bbob-render
Converts bbob-parser AST tree to html
+35
View File
@@ -0,0 +1,35 @@
function render(tree, options) {
}
function attrs(obj) {
let attr = '';
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'boolean' && obj[key]) {
attr += ` ${key}`;
} else if (typeof obj[key] === 'number') {
attr += ` ${key}="${obj[key]}"`;
} else if (typeof obj[key] === 'string') {
attr += ` ${key}="${obj[key].replace(/"/g, '"')}"`;
}
});
return attr;
}
function traverse(tree, cb) {
if (Array.isArray(tree)) {
let i = 0,
length = tree.length;
for (; i < length; i++) {
traverse(cb(tree[i]), cb);
}
} else if (typeof tree === 'object' && tree.hasOwnProperty('content')) {
traverse(tree.content, cb);
}
return tree;
}
module.exports = render;
View File