-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtable.js
79 lines (70 loc) · 3.44 KB
/
table.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const hasOwn = Object.prototype.hasOwnProperty;
const fs = require('fs');
const api = require('./api');
const name = 'TABLE.md';
const icons = {
have: '✔',
dontHave: '✖'
};
const locale = 'pt-BR';
const head = `# Comparative Table
| Template Engine | Version | Escaped time (ms) | Unescaped time (ms) | NPM downloads | Contributors | Last commit | Syntax | Client-side support | Caching | Asynchronous | Content blocks | Partials | Inheritance | Conditionals | Control whitespace | Imports | Helpers | Filters | Special Characters | Debug Mode | Streaming | Auto-escape | Encode |
| :-------------: | :--------: | :---------------: | :-----------------: | :------------: | :----------: | :---------: | :------------: | :-----------------: | :-----: | :----------: | :------------: | :------: | :---------: | :----------: | :----------------: | :-----: | :-----: | :-----: | :----------------: | :--------: | :-------: | :---------: | :----: |`;
// let line = '| {{NAME}} | {{VERSION}} | {{DOWNLOADS}} | {{COLLABORATORS}} | {{ESCAPED}} | {{UNESCAPED}} | {{STATS}} | {{LASTCOMMIT}} | {{ASYNCHRONOUS}} | {{CONTENTBLOCKS}} | {{IMPORTS}} | {{HELPERS}} | {{SYNTAX}} | {{STREAMING}} | {{AUTOESCAPE}} |';
let table;
let samples;
const writeFile = () => {
fs.writeFile(name, table, (error) => {
if (error) {
return console.log(error);
}
console.log(`The ${name} was saved!`);
});
}
// const fetch = (path, callback) => { // '/downloads/point/last-month/'
// let i = samples.length;
// while (i--) {}
// api.npm.get(path, (response) => {
// console.log(response);
// });
// };
const create = (samples) => {
let newLine, required, item, i = 1;
table = head;
samples = samples;
for (required in samples) {
if (hasOwn.call(samples, required)) {
item = samples[required];
newLine = '\r\n';
newLine += `| ${item.name}`;
newLine += ` | ${item.version}`;
newLine += ` | ${item.results.escaped.toLocaleString(locale)}`;
newLine += ` | ${item.results.unescaped.toLocaleString(locale)}`;
newLine += ` | ${item.downloads.toLocaleString(locale)}`;
newLine += ` | ${item.contributors}`;
newLine += ` | ${item.lastCommit}`;
newLine += ` | ${item.syntax}`;
newLine += ` | ${item.clientSide ? icons.have : icons.dontHave}`;
newLine += ` | ${item.caching ? icons.have : icons.dontHave}`;
newLine += ` | ${item.asynchronous ? icons.have : icons.dontHave}`;
newLine += ` | ${item.contentBlocks ? icons.have : icons.dontHave}`;
newLine += ` | ${item.partials ? icons.have : icons.dontHave}`;
newLine += ` | ${item.inheritance ? icons.have : icons.dontHave}`;
newLine += ` | ${item.conditionals ? icons.have : icons.dontHave}`;
newLine += ` | ${item.controlWhitespace ? icons.have : icons.dontHave}`;
newLine += ` | ${item.imports ? icons.have : icons.dontHave}`;
newLine += ` | ${item.helpers ? icons.have : icons.dontHave}`;
newLine += ` | ${item.filters ? icons.have : icons.dontHave}`;
newLine += ` | ${item.specialChars ? icons.have : icons.dontHave}`;
newLine += ` | ${item.debugMode ? icons.have : icons.dontHave}`;
newLine += ` | ${item.streaming ? icons.have : icons.dontHave}`;
newLine += ` | ${item.autoescape ? icons.have : icons.dontHave}`;
newLine += ` | ${item.encode ? icons.have : icons.dontHave}`;
newLine += ` |`;
table += newLine;
i++;
}
}
writeFile();
};
exports.create = create;