We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
doc.version
1 parent 0ddc451 commit c4c4df5Copy full SHA for c4c4df5
1 file changed
src/utils/parse.ts
@@ -1,17 +1,12 @@
1
import type { ValidNode } from '#types/extractor'
2
import type { TextDocument } from 'vscode'
3
-import { createHash } from 'node:crypto'
4
import { memoize } from './memoize'
5
6
-function computeHash(text: string) {
7
- return createHash('sha1').update(text).digest('hex')
8
-}
9
-
10
export function createCachedParse<T extends ValidNode>(
11
parse: (text: string) => T | null,
12
) {
13
return memoize(
14
(doc: TextDocument) => parse(doc.getText()),
15
- { getKey: (doc) => `${doc.uri}:${computeHash(doc.getText())}` },
+ { getKey: (doc) => `${doc.uri}:${doc.version}` },
16
)
17
}
0 commit comments