Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should support null for the previous commit', () => {
const commit = repoCommit(
'message',
new Date(2019, 9, 4, 9, 0, 0),
'hash',
null
);
expect(commit.hash).toEqual(
getHash([
'message',
new Date(2019, 9, 4, 9, 0, 0),
'hash',
null,
])
);
});
});
export function repoCommit(
message: string,
time: Date,
indexHash: string,
previousCommit: string
): CausalRepoCommit {
return {
type: 'commit',
message: message,
time: time,
index: indexHash,
previousCommit: previousCommit,
hash: getHash([message, time.toISOString(), indexHash, previousCommit]),
};
}
export function hashAtoms(atoms: Atom[]): string {
let hashes: string[] = [];
for (let atom of atoms) {
hashes.push(atom.hash);
}
hashes.sort();
return getHash(hashes);
}
export function atomHash(
id: AtomId,
causeHash: string | null,
value: T
): string {
return getHash([
causeHash || null,
id.site,
id.timestamp,
id.priority,
value,
]);
}