blake3
Version:
BLAKE3 hashing for JavaScript
1 lines • 1.3 kB
Source Map (JSON)
{"version":3,"file":"set-node-module.cjs","sourceRoot":"","sources":["set-node-module.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AACvE,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAC5C,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC,IAAI,YAAoB,CAAC;AACzB,IAAI;IACF,OAAO,CAAC,YAAY,CAAC,CAAC;IACtB,YAAY,GAAG,YAAY,CAAC;CAC7B;AAAC,MAAM;IACN,YAAY,GAAG,UAAU,CAAC;CAC3B;AAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;IACxB,MAAM,IAAI,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,EAAE;SACf,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC;SAC3B,UAAU,CAAC,YAAY,EAAE,YAAY,CAAC;SACtC,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAExC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;CACjC","sourcesContent":["import * as fs from 'fs';\n\nconst files = ['index.cjs', 'index.d.cts', 'index.mjs', 'index.d.mts'];\nconst nativeModule = '@c4312/blake3-native';\nconst wasmModule = 'blake3-wasm';\n\nlet targetModule: string;\ntry {\n require(nativeModule);\n targetModule = nativeModule;\n} catch {\n targetModule = wasmModule;\n}\n\nfor (const file of files) {\n const path = `${__dirname}/${file}`;\n const content = fs\n .readFileSync(path, 'utf-8')\n .replaceAll(nativeModule, targetModule)\n .replaceAll(wasmModule, targetModule);\n\n fs.writeFileSync(path, content);\n}\n"]}