UNPKG

reg

Version:

`reg` is a package manager for native ES Modules. It's built to enable dependency management for Universal JavaScript (JavaScript that can run in the Browser and in Node.js w/o a compiler).

22 lines (16 loc) 518 B
const path = require('path') const tmp = require('tmp') const CID = require('cids') const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) const store = storage(path.join(__dirname, 'cache')) const cache = new Map() const local = tmp.tmpDirSync() const pull = async cid => { if (!CID.isCID(cid)) cid = new CID(cid) const root = await get(cid) const pkg = root.decode() if (!pkg.type === 'reg') { throw new Error(`CID is not reg package, ${cid.toString()}`) } }