@mlabs-haskell/cardano-serialization-lib-gc-browser
Advanced tools
Comparing version 1.0.0 to 1.0.1
39
index.js
@@ -1,37 +0,4 @@ | ||
const process = (lib) => { | ||
const finRegistry = new FinalizationRegistry((x) => { | ||
try { | ||
x.free(); | ||
} catch (_) {} | ||
}); | ||
const csl = require("@emurgo/cardano-serialization-lib-browser"); | ||
const wrappedCsl = require('@mlabs-haskell/csl-gc-wrapper')(csl); | ||
const classWrap = (classObj) => { | ||
Object.getOwnPropertyNames(classObj).forEach((propName) => { | ||
if (propName === "__wrap") { | ||
const oldMethod = classObj[propName]; | ||
classObj[propName] = function () { | ||
const retVal = oldMethod.apply(classObj, arguments); | ||
if (retVal && retVal.ptr) { | ||
const px = new Proxy(retVal, {}); | ||
finRegistry.register(px, retVal, px); | ||
return px; | ||
} | ||
return retVal; | ||
}; | ||
} | ||
}); | ||
return classObj; | ||
}; | ||
Object.keys(lib).forEach((k) => { | ||
if (k[0].toUpperCase() == k[0] && k[0] != "_") { | ||
classWrap(lib[k]); | ||
} | ||
}); | ||
return lib; | ||
}; | ||
const lib = process(await import("@emurgo/cardano-serialization-lib-browser")); | ||
export default lib; | ||
module.exports = wrappedCsl; |
{ | ||
"name": "@mlabs-haskell/cardano-serialization-lib-gc-browser", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "This is a small library that provides a wrapper for managing garbage collection for cardano-serialization-library (Browser version)", | ||
"main": "index.js", | ||
"module": "index.js", | ||
"scripts": { | ||
@@ -17,4 +16,5 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"dependencies": { | ||
"@emurgo/cardano-serialization-lib-browser": "^11.4.0" | ||
"@emurgo/cardano-serialization-lib-browser": "^11.2.1", | ||
"@mlabs-haskell/csl-gc-wrapper": "^1.0.1" | ||
} | ||
} |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1258
2
3
1
No
+ Added@mlabs-haskell/csl-gc-wrapper@1.0.2(transitive)