CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/jupyter-api/compute-hash.ts
Views: 687
1
import { sha1 } from "@cocalc/util/misc";
2
3
export default function computeHash({
4
history,
5
input,
6
kernel,
7
project_id,
8
path,
9
}: {
10
history?: string[];
11
input: string;
12
kernel: string;
13
project_id?: string;
14
path?: string;
15
}): string {
16
return sha1(
17
JSON.stringify([
18
(history ?? []).map((x) => x.trim()),
19
input.trim(),
20
kernel.toLowerCase().trim(),
21
project_id,
22
path,
23
])
24
);
25
}
26
27