Commit 42f8116 1 parent 71f0096 commit 42f8116 Copy full SHA for 42f8116
File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
- import { juxt , pairRight , stack } from "./juxt.ts" ;
2
- import { prop , spread } from "./operator.ts" ;
3
-
1
+ import crypto from "node:crypto" ;
2
+ import stableHash from "npm:stable-hash" ;
4
3
import { pipe } from "./composition.ts" ;
4
+ import { juxt , pairRight , stack } from "./juxt.ts" ;
5
5
import { map } from "./map.ts" ;
6
6
import { applySpec } from "./mapping.ts" ;
7
+ import { prop , spread } from "./operator.ts" ;
7
8
import { sleep } from "./time.ts" ;
8
9
import { AsyncFunction , ElementOf } from "./typing.ts" ;
9
10
@@ -173,3 +174,10 @@ export const retry = <F extends AsyncFunction>(
173
174
times : number ,
174
175
f : F ,
175
176
) => conditionalRetry ( ( ) => true ) ( waitMs , times , f ) ;
177
+
178
+ export const hash = < T > ( x : T , maxLength : number ) =>
179
+ // @ts -expect-error not sure why
180
+ crypto . createHash ( "MD5" ) . update ( stableHash ( x ) ) . digest ( "hex" ) . substring (
181
+ 0 ,
182
+ maxLength ,
183
+ ) ;
You can’t perform that action at this time.
0 commit comments