Skip to content

Commit 2b66c44

Browse files
committed
fix null case
1 parent 00c5afb commit 2b66c44

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/utils/hasValue.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Returns true if specified value is not undefined, null and empty string
3+
* @param v - value to check
4+
*/
5+
export function hasValue<T>(v: T | undefined | null): v is T {
6+
return v !== undefined && v !== null && v !== '';
7+
}

workers/grouper/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import levenshtein from 'js-levenshtein';
1818
import { computeDelta } from './utils/repetitionDiff';
1919
import TimeMs from '../../../lib/utils/time';
2020
import { rightTrim } from '../../../lib/utils/string';
21+
import { hasValue } from '../../../lib/utils/hasValue';
2122

2223
/**
2324
* Error code of MongoDB key duplication error
@@ -252,7 +253,7 @@ export default class GrouperWorker extends Worker {
252253
frame.sourceCode = frame.sourceCode.map((line: SourceCodeLine) => {
253254
return {
254255
line: line.line,
255-
content: line.content !== undefined ? rightTrim(line.content, MAX_CODE_LINE_LENGTH) : line.content,
256+
content: hasValue(line.content) ? rightTrim(line.content, MAX_CODE_LINE_LENGTH) : line.content,
256257
};
257258
});
258259
});

0 commit comments

Comments
 (0)