Skip to content

Commit d41550e

Browse files
committed
skip empty function tokens
1 parent bd4272b commit d41550e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tokenizers/javascript/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ const processFile = function(fileName, data) {
6363
const functionAstShallow = node
6464
const functionCode = regenerateFunctionCode(functionAstShallow)
6565
functions = functions.push(functionCode)
66+
6667
const tokenizedFunction = tokenizer(functionCode, parentId, blockId++)
67-
functionTokens = functionTokens.push(tokenizedFunction)
68+
if (tokenizedFunction)
69+
functionTokens = functionTokens.push(tokenizedFunction)
6870
}
6971
})
7072

tokenizers/javascript/tokenizer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ const tokenizer = function(code, parentId, blockId) {
9696
return `${token}${COUNT_DELIMITER}${count}`
9797
})
9898

99+
if (tokenPairs.size == 0)
100+
return ''
101+
99102
const lhs = `${parentId},${blockId},`
100103
const rhs = tokenPairs.join(TOKEN_DELIMITER)
101104
const output = `${lhs}${MAIN_DELIMITER}${rhs}`

0 commit comments

Comments
 (0)