diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /cli/tests/hash.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'cli/tests/hash.ts')
-rw-r--r-- | cli/tests/hash.ts | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/cli/tests/hash.ts b/cli/tests/hash.ts deleted file mode 100644 index 1215b8b95..000000000 --- a/cli/tests/hash.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -const { args } = Deno; -import { createHash, SupportedAlgorithm } from "../../std/hash/mod.ts"; -import { Md5 } from "../../std/hash/md5.ts"; -import { Sha1 } from "../../std/hash/sha1.ts"; -import { Sha256 } from "../../std/hash/sha256.ts"; -import { Sha512 } from "../../std/hash/sha512.ts"; -// deno-lint-ignore camelcase -import { Sha3_224, Sha3_256, Sha3_384, Sha3_512 } from "../../std/hash/sha3.ts"; - -if (args.length < 3) Deno.exit(0); - -const method = args[0]; -const alg = args[1]; -const inputFile = args[2]; - -// deno-lint-ignore no-explicit-any -function getJsHash(alg: string): any { - switch (alg) { - case "md5": - return new Md5(); - case "sha1": - return new Sha1(); - case "sha224": - return new Sha256(true); - case "sha256": - return new Sha256(); - case "sha3-224": - return new Sha3_224(); - case "sha3-256": - return new Sha3_256(); - case "sha3-384": - return new Sha3_384(); - case "sha3-512": - return new Sha3_512(); - case "sha512": - return new Sha512(); - default: - return null; - } -} - -const f = Deno.openSync(inputFile, { read: true }); -const buffer = Deno.readAllSync(f); -f.close(); - -let hash = null; - -console.time("hash"); -if (method === "rust") { - hash = createHash(alg as SupportedAlgorithm); -} else if (method === "js") { - hash = getJsHash(alg); -} - -if (hash === null) { - console.log(`unknown hash: ${alg}`); - Deno.exit(1); -} - -hash.update(buffer); -hash.digest(); -console.timeEnd("hash"); |