Update analyze.js
This commit is contained in:
@ -22,15 +22,15 @@ let snippetTokens = {data: snippetsData.data.map(snippet => {
|
|||||||
attributes: {
|
attributes: {
|
||||||
codeLength: snippet.attributes.codeBlocks[0].trim().length,
|
codeLength: snippet.attributes.codeBlocks[0].trim().length,
|
||||||
tokenCount: tokens.length,
|
tokenCount: tokens.length,
|
||||||
functionCount: tokens.filter(t => t.type == 'function').length,
|
functionCount: tokens.filter(t => t.type === 'function').length,
|
||||||
operatorCount: tokens.filter(t => t.type == 'operator').length,
|
operatorCount: tokens.filter(t => t.type === 'operator').length,
|
||||||
keywordCount: tokens.filter(t => t.type == 'keyword').length,
|
keywordCount: tokens.filter(t => t.type === 'keyword').length,
|
||||||
distinctFunctionCount: [...new Set(tokens.filter(t => t.type == 'function').map(t => t.content))].length
|
distinctFunctionCount: [...new Set(tokens.filter(t => t.type === 'function').map(t => t.content))].length
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
hash: snippet.meta.hash
|
hash: snippet.meta.hash
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}), meta: { specification: "http://jsonapi.org/format/"}};
|
}), meta: { specification: "http://jsonapi.org/format/"}};
|
||||||
let snippetArchiveTokens = {data: snippetsArchiveData.data.map(snippet => {
|
let snippetArchiveTokens = {data: snippetsArchiveData.data.map(snippet => {
|
||||||
let tokens = prism.tokenize(snippet.attributes.codeBlocks[0], prism.languages.javascript, 'javascript');
|
let tokens = prism.tokenize(snippet.attributes.codeBlocks[0], prism.languages.javascript, 'javascript');
|
||||||
|
|||||||
Reference in New Issue
Block a user