diff --git a/build_npm.ts b/build_npm.ts index 7be7d57..cc77273 100644 --- a/build_npm.ts +++ b/build_npm.ts @@ -9,7 +9,6 @@ await build({ outDir, shims: { deno: true }, package: { - dependencies: { "@types/sjcl": "1.0.34" }, name: "gamla", version: Deno.args[0], description: "Functional programming with async and type safety", diff --git a/deno.json b/deno.json index 43a92a4..7c24207 100644 --- a/deno.json +++ b/deno.json @@ -2,7 +2,5 @@ "tasks": { "build": "deno run --allow-env --allow-read --allow-write --allow-net --allow-run build_npm.ts" }, - "imports": { - "std-assert": "https://deno.land/std@0.213.0/assert/mod.ts" - } + "imports": { "std-assert": "https://deno.land/std@0.213.0/assert/mod.ts" } } diff --git a/deno.lock b/deno.lock index 150fa35..9aba92b 100644 --- a/deno.lock +++ b/deno.lock @@ -20,6 +20,7 @@ "jsr:@std/path@~0.225.2": "0.225.2", "jsr:@ts-morph/bootstrap@0.24": "0.24.0", "jsr:@ts-morph/common@0.24": "0.24.0", + "npm:js-sha256@*": "0.11.0", "npm:sjcl@*": "1.0.8", "npm:stable-hash@*": "0.0.4" }, @@ -117,6 +118,9 @@ } }, "npm": { + "js-sha256@0.11.0": { + "integrity": "sha512-6xNlKayMZvds9h1Y1VWc0fQHQ82BxTXizWPEtEeGvmOUYpBRy4gbWroHLpzowe6xiQhHpelCQiE7HEdznyBL9Q==" + }, "sjcl@1.0.8": { "integrity": "sha512-LzIjEQ0S0DpIgnxMEayM1rq9aGwGRG4OnZhCdjx7glTaJtf4zRfpg87ImfjSJjoW9vKpagd82McDOwbRT5kQKQ==" }, @@ -124,6 +128,9 @@ "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==" } }, + "redirects": { + "https://denopkg.com/chiefbiiko/std-encoding/mod.ts": "https://denopkg.com/chiefbiiko/std-encoding@master/mod.ts" + }, "remote": { "https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", "https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49", @@ -194,6 +201,9 @@ "https://deno.land/std@0.213.0/assert/unreachable.ts": "38cfecb95d8b06906022d2f9474794fca4161a994f83354fd079cac9032b5145", "https://deno.land/std@0.213.0/fmt/colors.ts": "aeaee795471b56fc62a3cb2e174ed33e91551b535f44677f6320336aabb54fbb", "https://deno.land/std@0.213.0/testing/mock.ts": "4c35c9bc7d63cabceadf8fa1d0771104d754352c54054e11e068f9af08821234", + "https://deno.land/x/base64@v0.2.1/base.ts": "47dc8d68f07dc91524bdd6db36eccbe59cf4d935b5fc09f27357a3944bb3ff7b", + "https://deno.land/x/base64@v0.2.1/base64url.ts": "18bbf879b31f1f32cca8adaa2b6885ae325c2cec6a66c5817b684ca12c46ad5e", + "https://deno.land/x/base64@v0.2.1/mod.ts": "1cbdc4ba7229d3c6d1763fecdb9d46844777c7e153abb6dabea8b0dd01448db4", "https://deno.land/x/code_block_writer@12.0.0/mod.ts": "2c3448060e47c9d08604c8f40dee34343f553f33edcdfebbf648442be33205e5", "https://deno.land/x/code_block_writer@12.0.0/utils/string_utils.ts": "60cb4ec8bd335bf241ef785ccec51e809d576ff8e8d29da43d2273b69ce2a6ff", "https://deno.land/x/deno_cache@0.6.2/auth_tokens.ts": "5d1d56474c54a9d152e44d43ea17c2e6a398dd1e9682c69811a313567c01ee1e", @@ -237,6 +247,8 @@ "https://deno.land/x/wasmbuild@0.14.1/cache.ts": "89eea5f3ce6035a1164b3e655c95f21300498920575ade23161421f5b01967f4", "https://deno.land/x/wasmbuild@0.14.1/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02", "https://deno.land/x/wasmbuild@0.15.1/cache.ts": "9d01b5cb24e7f2a942bbd8d14b093751fa690a6cde8e21709ddc97667e6669ed", - "https://deno.land/x/wasmbuild@0.15.1/loader.ts": "8c2fc10e21678e42f84c5135d8ab6ab7dc92424c3f05d2354896a29ccfd02a63" + "https://deno.land/x/wasmbuild@0.15.1/loader.ts": "8c2fc10e21678e42f84c5135d8ab6ab7dc92424c3f05d2354896a29ccfd02a63", + "https://denopkg.com/chiefbiiko/sha256@v1.0.0/mod.ts": "eca3d13a2cd11839e451055737ccde0c7c6cdbd331fcd0a8f7e954ee857bb13a", + "https://denopkg.com/chiefbiiko/std-encoding@master/mod.ts": "e61017da4cef146863d614a961b4e61f1df14b72c906092bd02161f913e76522" } } diff --git a/src/io.ts b/src/io.ts index f1c78a2..b27e4ce 100644 --- a/src/io.ts +++ b/src/io.ts @@ -1,4 +1,4 @@ -import sjcl from "npm:sjcl"; +import { sha256 } from "npm:js-sha256"; import stableHash from "npm:stable-hash"; import { pipe } from "./composition.ts"; import { juxt, pairRight, stack } from "./juxt.ts"; @@ -169,8 +169,6 @@ export const retry = ( f: F, ) => conditionalRetry(() => true)(waitMs, times, f); -const sha256 = (x: string) => sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(x)); - export const hash = (x: T, maxLength: number) => // @ts-ignore-error error in deno but not in node - sha256(stableHash(x)).substring(0, maxLength); + sha256.hex(stableHash(x)).substring(0, maxLength);