UNPKG

3.09 kBSource Map (JSON)View Raw
1{"version":3,"file":"parseVhdToBlocks.js","names":["_assert","_interopRequireDefault","require","_parseVhdStream","obj","__esModule","default","next","iterator","type","skipableType","item","cursor","assert","strictEqual","done","value","onlyBlocks","iterable","blockSize","id","data","lba","block","parseVhdToBlocks","vhdStream","parseVhdStream","footer","header","blockCount","diskSize","currentSize","geometry","diskGeometry","blocks"],"sources":["../src/parseVhdToBlocks.js"],"sourcesContent":["import assert from 'assert'\nimport { parseVhdStream } from 'vhd-lib/parseVhdStream.js'\n\nasync function next(iterator, type, skipableType) {\n let item\n do {\n const cursor = await iterator.next()\n assert.strictEqual(cursor.done, false, 'iterator is done')\n\n item = cursor.value\n } while (item.type === skipableType)\n assert.strictEqual(item.type, type)\n return item\n}\n\nasync function* onlyBlocks(iterable, blockSize) {\n for await (const item of iterable) {\n if (item.type === 'block') {\n // transform to blocks expected by generateVmdkData\n // rename the property and remove the block bitmap\n const { id, data } = item\n yield { lba: id * blockSize, block: data }\n }\n }\n}\n\nexport async function parseVhdToBlocks(vhdStream) {\n const iterator = parseVhdStream(vhdStream)\n\n const { footer } = await next(iterator, 'footer')\n const { header } = await next(iterator, 'header')\n\n // ignore all parent locators that could be before the BAT\n const { blockCount } = await next(iterator, 'bat', 'parentLocator')\n\n return {\n blockSize: header.blockSize,\n blockCount,\n diskSize: footer.currentSize,\n geometry: footer.diskGeometry,\n blocks: onlyBlocks(iterator, header.blockSize),\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAA0D,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1D,eAAeG,IAAIA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;EAChD,IAAIC,IAAI;EACR,GAAG;IACD,MAAMC,MAAM,GAAG,MA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