{"name":"xbytes","version":"1.2.0","description":"Parse bytes to human readable sizes (4747) → ('4.75 KB') and vice versa.","main":"dist/index.js","types":"typings/index.d.ts","scripts":{"test":"jest","build":"babel lib -d dist","preversion":"npm test","version":"npm run build","postversion":"git push && git push --tags"},"engines":{"node":">=1"},"keywords":["convert","size","bytes","bits","parser","iec","binary","decimal","human","humanized","data","filesize","file","readable","utility","convert","converter","pretty"],"author":{"name":"Miraculous Owonubi","email":"omiraculous@gmail.com"},"maintainers":[{"name":"miraclx","email":"omiraculous@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/miraclx/xbytes.git"},"bugs":{"url":"https://github.com/miraclx/xbytes/issues"},"license":"Apache-2.0","babel":{"presets":["airbnb","@babel/preset-env"]},"devDependencies":{"@babel/cli":"^7.2.3","@babel/core":"^7.3.3","@babel/preset-env":"^7.3.1","babel-eslint":"^10.0.1","babel-preset-airbnb":"^3.2.0","eslint":"^5.3.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^4.0.0","eslint-plugin-import":"^2.16.0","eslint-plugin-prettier":"^3.0.1","jest":"^24.1.0","prettier":"^1.16.4"},"homepage":"https://github.com/miraclx/xbytes#readme","directories":{"lib":"lib","test":"test"},"dependencies":{},"gitHead":"b1507af4495331845c3dfe5e2558752b19beb1db","_id":"xbytes@1.2.0","_nodeVersion":"11.10.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-oGUsWErVslbM2fBSI2OZEcL591Sg1q4Cusw5/RUv9zvHK1F/+jPlW+ujX2X4k3esFa5hfIwprPvZa5y/5flGow==","shasum":"882d027d89424cc573d681b02572a5f19a7b4c76","tarball":"http://registry-npm.ywwl.com/xbytes/download/xbytes-1.2.0.tgz","fileCount":10,"unpackedSize":42728,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJchRWICRA9TVsSAnZWagAAvNQP/RZ60dVyZxqb6pG5PjNi\nKyjECdthd+JnKC8obrGwh80p+ZGLvX5zf9Gmp6TnCxs586j+f+NoTlHtpHkm\nFI44+uo7cOoxKHv3y9wt8fKdYF47Nptty6z2iImWa1aR2VNYE77v75bRdj2Q\nfDaC2L8iPXv61W0QsaUfplpK1eFX/nYUfN1/0uMTWMDSV/tG0VRQIoYXeYST\njRYt2wi3tZ8A43maSzO6qr+5tTn5xVwAlrRwyDMlG7ygZ1Lsj+bAGuVAlHQc\nBLe+POsa7ID/D71bKU0OldSM8slAwPNSxao4NCOQqdNCtu45ikTmevV3WSP9\nkM+C0n0B6uGyq2GJQ3aLXTtEh2KmTn4UOgXBzPBLOYW6MW49ULtDa7LdRLww\n7gkul/8VYirBHysiK2HAy7xdfIF7yruE9LmyLZQOXgUEnoJOD0PSTqrs5iAZ\nkLbavKsrzQPkSd/3dAelL53IwP3W0oj9CVUHT+w4yWGBVU3x4DFGo9p8iJWr\nj0s8krChvi00QHNAHwOIzEHoFdqqHXcs2g/0rgfYvtiqDdVFOcjZGzhz17m9\n0ueZ2QY7qOUoOBIVqItwJnLsZ19Rlf2i/moLXqq8UAsIO2tTqiI23ZrMssFi\n4IEpzSfq5ZmK1IdWoHigcvu494mFqeZ00hO4PC4evFCbJz9UJP4nULKMtLgC\npEVx\r\n=J+gn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICOl4WHjzTRaGgvlmeuSlrHkSNHBafYXh5f8B1TrCfYdAiBaW+tt+iB6rdLPj5gdLCUzJrG4828MYxS1bodINFE1SQ=="}],"size":13063,"noattachment":false,"key":"/xbytes/-/xbytes-1.2.0.tgz"},"_npmUser":{"name":"miraclx","email":"omiraculous@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xbytes_1.2.0_1552225671672_0.5524725506968444"},"_hasShrinkwrap":false,"readme":"# ByteParser (xbytes)\n\n> NodeJS Byte Parser\n> Parse bytes to human readable sizes (4747) → ('4.75 KB') and vice versa.\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n\n[![NPM][npm-image-url]][npm-url]\n\n## Installing\n\nVia [NPM][npm]:\n\n``` bash\nnpm install xbytes\n```\n\n## Usage\n\n``` javascript\n// Node CommonJS\nconst xbytes = require('xbytes');\n// Or Node ES6 Modules\nimport xbytes from 'xbytes';\n// Or TypeScript\nimport * as xbytes from 'xbytes';\n```\n\n``` html\n<!-- Or in the Browser -->\n<script src=\"xbytes/dist/index.js\"></script>\n```\n\n## Examples\n\n``` javascript\nxbytes(4747); // '4.75 KB'\nxbytes(-3946); // '-3.95 KB'\nxbytes(34.724e+4); // '347.24 KB'\nxbytes(32000000000); // '32.00 GB'\nxbytes(21474836480, {iec: true}); // '20.00 GiB'\nxbytes.parseSize('10 GB'); // 10000000\nxbytes.parseSize('-50 GiB'); // -53687091200\n```\n\n> *IEC Specification**\n\n``` javascript\nxbytes(5242880, {iec: true}); // '5 MiB'\n\nxbytes.parseSize('10 GiB'); // 10485760\n```\n\n## API\n\n### <a id='fn:xbytes'></a> xbytes(byte[, options])\n\n* `byte`: &lt;[number][]&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#bytestring)&gt;\n\nParse `byte` to human readable size. If `byte` is not a number or an number-like string, return `null` appropriately.\n\n```javascript\nxbytes(2472946)\n// << '2.47 MB'\nxbytes(49392123904, {iec: true})\n// << '46.00 GiB'\n```\n\n### <a id='fn:parsesize'></a> xbytes.parseSize(str[, config])\n\n* `str`: &lt;[ByteString](#bytestring)&gt;\n* `config`: &lt;[ParseOptions](#parseoptions)&gt;\n* Returns: &lt;[number][]&gt;\n\nParse human readable size to bytes\n\n```javascript\nxbytes.parseSize('15.967 MB')\n// << 15967000\nxbytes.parseSize('5.97 PiB')\n// << 6721622443850465\n```\n\n### <a id='fn:parse'></a> xbytes.parse(size)\n\n* `str`: &lt;[HybridByte](#hybridbyte)&gt;\n* Returns: &lt;[ByteUnitObject](#byteunitobject)&gt;\n\nCreate a ByteUnitObject around the specified HybridByte\n\n```javascript\nxbytes.parse('10 MiB')\n// << ByteUnitObject { bytes: 10485760 }\nxbytes.parse('10 MiB').add('20 MiB')\n// << ByteUnitObject { bytes: 31457280 }\nxbytes.parse('10 MiB').add('20 MiB').toIECBytes()\n// << '30.00 MiB'\n```\n\n### <a id='fn:isbytes'></a> xbytes.isBytes(str)\n\n* `str`: &lt;[string][]&gt;\n* Returns: &lt;[boolean][]&gt;\n\nCheck if the provided string is a [ByteString](#bytestring)\n\n``` javascript\nxbytes.isBytes('10 MiB')\n// << true\nxbytes.isBytes('Hello')\n// << false\nxbytes.isBytes('10 iB')\n// << false\nxbytes.isBytes('10b')\n// << true\n```\n\n### <a id='fn:isunit'></a> xbytes.isUnit(str)\n\n* `str`: &lt;[UnitString](#unitstring)&gt;\n* Returns: &lt;[boolean][]&gt;\n\nCheck if the provided string is an [UnitString](#unitstring)\n\n``` javascript\nxbytes.isUnit('GB')\n// << true\nxbytes.isUnit('giB')\n// << true\nxbytes.isUnit('iB')\n// << false\nxbytes.isUnit('BB')\n// << false\n```\n\n### <a id='fn:isparsable'></a> xbytes.isParsable(input)\n\n* `input`: &lt;[HybridByte](#hybridbyte)&gt;\n* Returns: &lt;[boolean][]&gt;\n\nCheck if the provided argument is parsable _i.e_ raw_bytes ([number]) or [ByteString](#bytestring).\n\n### <a id='fn:relative'></a> xbytes.relative(size[, options])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[HybridByteRelations](#hybridbyterelations)&gt;\n\n### <a id='fn:relative:bits'></a> xbytes.relative.bits(size[, options])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#Bytestring)&gt;\n\nShow the input size in relation to its `bit` format\n\n### <a id='fn:relative:bytes'></a> xbytes.relative.bytes(size[, options])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#Bytestring)&gt;\n\nShow the input size in relation to its `byte` format\n\n### <a id='fn:relative:iecBits'></a> xbytes.relative.iecBits(size[, options])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#Bytestring)&gt;\n\nShow the input size in relation to its `bit` format under `IEC Standards`\n\n### <a id='fn:relative:iecBytes'></a> xbytes.relative.iecBytes(size[, options])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#Bytestring)&gt;\n\nShow the input size in relation to its `bytes` format under `IEC Standards`\n\n### <a id='fn:relative:size'></a> xbytes.relative.size(size[, unit[, options]])\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* `unit`: &lt;[UnitString](#unitstring)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteString](#bytestring)&gt;\n\n### <a id='fn:parsestring'></a> xbytes.parseString(str)\n\n* `str`: &lt;[ByteString](#bytestring)&gt;\n* Returns: &lt;[ParsedByteString](#parsedbytestring)&gt;\n\nParse a human readable byte into its components\n\n### <a id='fn:parsebytes'></a> xbytes.parseBytes(str, options)\n\n* `str`: &lt;[HybridByte](#hybridbyte)&gt;\n* `options`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ParsedBytes](#parsedbytes)&gt;\n\nParse a human readable byte into its components.\nExtended from [parseString()](#parsestring), but with a few extra properties.\nAnd flexibility to use parse either an integer byte value or a `ByteString` resulting in the same object.\n\n### <a id='fn:extractbytes'></a> xbytes.extractBytes(str)\n\n* `str`: &lt;[string][]&gt;\n* Returns: &lt;[ByteString](#bytestring)[]&gt;\n\nExtract all [ByteString](#bytestring)s within a string into an array, alternative to `str.match(xbytes.byteFilter)`\n\n### <a id='fn:createbyteparser'></a> xbytes.createByteParser(config)\n\n* `config`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[ByteParser](#byteparser)&gt;\n\nConstruct a static [ByteParser](#byteparser) with predefined configurations\n\n### <a id='fn:createsizeparser'></a> xbytes.createSizeParser(config)\n\n* `config`: &lt;[ParseOptions](#parseoptions)&gt;\n* Returns: &lt;[SizeParser](#sizeparser)&gt;\n\nConstruct a static [SizeParser](#sizeparser) with predefined configurations\n\n### <a id='fn:createrelativesizer'></a> xbytes.createRelativeSizer(unit[, config])\n\n* `unit`: &lt;[UnitString](#unitstring)&gt;\n* `config`: &lt;[ByteOptions](#byteoptions)&gt;\n* Returns: &lt;[RelativeSizer](#relativesizer)&gt;\n\nCreate a [RelativeSizer](#relativesizer) for converting a hybrid byte into any set unit under predefined configuration\n\n### <a id='unitmatcher'></a> xbytes.unitMatcher: [`RegExp`][regexp]\n\nThe raw Regular expression used in scanning all string byte units.\n\n### <a id='genericmatcher'></a> xbytes.genericMatcher: [`RegExp`][regexp]\n\nThe raw regular expression used in scanning all byte containing strings.\n\n### <a id='bytefilter'></a> xbytes.byteFilter: [`RegExp`][regexp]\n\nAn regular expression extension of [`genericMatcher`](#genericmatcher) with the 'i' flag.\n\n### <a id='globalbytefilter'></a> xbytes.globalByteFilter: [`RegExp`][regexp]\n\nAn regular expression extension of [`genericMatcher`](#genericmatcher) with the 'gi' flags.\n\n### <a id='unitstring'></a> UnitString: [`String`][string]\n\n Supported Unit Strings\n\n | Index | Prefix |    Decimal Bits    | Binary Bits ([IEC][]) |    Decimal Bytes    | Binary Bytes ([IEC][]) |\n | :---: | :----: | :----------------: | :-------------------: | :-----------------: | :--------------------: |\n |   0   |   -    | **b (Bits)**       | **b (Bits)**          | **b (Bits)**        | **b (Bits)**           |\n |   0   |   -    | **B (Bytes)**      | **B (Bytes)**         | **B (Bytes)**       | **B (Bytes)**          |\n |   1   |   K    | **Kb (KiloBits)**  | **Kib (KiloBits)**    | **KB (KiloBytes)**  | **KiB (KibiBytes)**    |\n |   2   |   M    | **Mb (MegaBits)**  | **Mib (MebiBits)**    | **MB (MegaBytes)**  | **MiB (MebiBytes)**    |\n |   3   |   G    | **Gb (GigaBits)**  | **Gib (GibiBits)**    | **GB (GigaBytes)**  | **GiB (GibiBytes)**    |\n |   4   |   T    | **Tb (TeraBits)**  | **Tib (TebiBits)**    | **TB (TeraBytes)**  | **TiB (TebiBytes)**    |\n |   5   |   P    | **Pb (PetaBits)**  | **Pib (PebiBits)**    | **PB (PetaBytes)**  | **PiB (PebiBytes)**    |\n |   6   |   E    | **Eb (ExaBits)**   | **Eib (ExbiBits)**    | **EB (ExaBytes)**   | **EiB (ExbiBytes)**    |\n |   7   |   Z    | **Zb (ZettaBits)** | **Zib (ZebiBits)**    | **ZB (ZettaBytes)** | **ZiB (ZebiBytes)**    |\n |   8   |   Y    | **Yb (YottaBits)** | **Yib (YobiBits)**    | **YB (YottaBytes)** | **YiB (YobiBytes)**    |\n\n### <a id='bytestring'></a> ByteString: [`String`][string]\n\nA stringed byte representation. The result of a parsed byte value.\n\n* '5 MB'\n* '10 GiB'\n* '0.67 Tb'\n* '-50 KB'\n* '2e+15 KB'\n* '-9e-4 GB'\n\n### <a id='hybridbyte'></a> HybridByte: [`Number`][number]|[`ByteString`](#bytestring)\n\nUsed to identify a variable thats either a [ByteString](#bytestring) or a [number][]\n\n* '47 MiB'\n* '50kb'\n* 74753\n* '105'\n\n### <a id='byteoptions'></a> ByteOptions: [`Object`][object]\n\n* `iec`: &lt;[boolean][]&gt; Whether or not to parse under the [IEC standard][IEC] i.e in terms of 1024. **Default**: `true`\n* `bits`: &lt;[boolean][]&gt; Whether or not to convert inputed bytes to bits and parse in terms of bits [1 byte = 8 bits]. **Default**: `false`.\n* `fixed`: &lt;[number][]&gt; Number of digits to include after decimal point. **Default**: `2`.\n* `short`: &lt;[boolean][]&gt; Whether or not to shorten unit String [short: 'MB', long: 'MegaBytes']. **Default**: `true`.\n* `space`: &lt;[boolean][]&gt; Whether or not to include a white space inbetween value and unit. **Default**: `true`.\n* `sticky`: &lt;[boolean][]&gt; Whether or not to retain unit on max unit values. e.g `'1024.00 GiB'` instead of `'1.00 TiB'`. **Default**: `false`.\n* `prefixIndex`: &lt;[number][]&gt; The index of unit relativity [See [UnitString](#unitstring)].\n\n### <a id='parseoptions'></a> ParseOptions: [`Object`][object]\n\n* `iec`: &lt;[boolean][]&gt; Whether or not to enforce compliance to [IEC standard][IEC]s. **Default**: `true`.\n* `bits`: &lt;[boolean][]&gt; Whether or not to parse a lower case 'b' in bit format. **Default**: `true`.\n\n### <a id='byteparser'></a> ByteParser: [`Function`][function]\n\n* `size`: &lt;[number][]&gt;\n* Returns: &lt;[ByteString](#bytestring)&gt;\n\nByte parser with predefined configuration. Result of [`createByteParser`](#fn:createbyteparser).\n\n### <a id='sizeparser'></a> SizeParser: [`Function`][function]\n\n* `str`: &lt;[ByteString](#bytestring)[]&gt;\n* Returns: &lt;[number][]&gt;\n\n[ByteString](#bytestring) parser with predefined configuration. Result of [`createSizeParser`](#fn:createsizeparser).\n\n### <a id='relativesizer'></a> RelativeSizer: [`Function`][function]\n\n* `size`: &lt;[HybridByte](#hybridbyte)&gt;\n* Returns: &lt;[ByteString](#bytestring)&gt;\n\n[HybridByte](#hybridbyte) parser with predefined configuration. Result of [`createRelativeSizer`](#fn:createrelativesizer).\n\n### <a id='parsedunit'></a> ParsedUnit: [`Object`][object]\n\n* `iec`: &lt;[boolean][]&gt; Whether or not the byte is represented under the [IEC standard][IEC] i.e in terms of 1024.\n  * `true` in `'7 TiB'`\n  * `false` in `'3 TB'`\n* `type`: &lt;[string][]&gt; Whether the size is represented as bits(b) or bytes(B).\n  * `'b'` in `'499Yb'`\n  * `'B'` in `'7 MB'`\n* `bits`: &lt;[boolean][]&gt; Whether or not the size is specifically represented as a `bit`.\n  * `true` in `84 Yb`\n  * `false` in `278.58 KB`\n* `bytes`: &lt;[boolean][]&gt; Whether or not the size is specifically represented as a `byte`.\n  * `true` in `92 EB`\n  * `false` in `28 Mb`\n* `unit`: &lt;[UnitString](#unitstring)&gt; Re-parsed UnitString of `inputUnit`, fixing formatting.\n  * `'TB'` if `'TB'`\n  * `'Gib'` if `'gib'`\n* `inputUnit`: &lt;[UnitString](#unitstring)&gt; The unparsed String as was provided.\n  * `'47TB'` in `'47TB'`\n* `prefix`: &lt;[string][]&gt; The prefix of the size string.\n  * `'K'` in `'KB'`\n* `prefixIndex`: &lt;[number][]&gt; The index of the size unit [See [UnitString](#unitstring)].\n  * `3` in `'GB'`\n\n### <a id='parsedbytestring'></a> ParsedByteString <sub>`extends`</sub> [ParsedUnit](#parsedunit): [`Object`][object]\n\n* `input`: &lt;[ByteString](#bytestring)&gt; The unparsed String as was provided.\n  * `'47TB'` in `'47TB'`\n* `value`: &lt;[number][]&gt; The value for the size.\n  * `83` in `'83MB'`\n\n### <a id='parsedbytes'></a> ParsedBytes <sub>`extends`</sub> [ParsedByteString](#parsedbytestring): [`Object`][object]\n\n* `input`: &lt;[HybridByte](#hybridbyte)&gt; The unparsed String as was provided.\n  * `1024` in `1024`\n  * `'47TB'` in `'47TB'`\n* `size`: &lt;[ByteString](#bytestring)&gt; The value for the size.\n  * `83` in `'83MB'`\n* `bytes`: &lt;[number][]&gt; The value for the size.\n  * `10485760` from `'10 MiB'`\n\n### <a id='byteunitobject'></a> class ByteUnitObject\n\n* `bytes`: &lt;[number][]&gt; Internal byte value.\n\nWrap a HybridByte in a chainable, transformative object.\n\n```javascript\nnew ByteUnitObject('10 MiB')\n// << ByteUnitObject { bytes: 10485760 }\nnew ByteUnitObject('10 MiB').add('20 MiB')\n// << ByteUnitObject { bytes: 31457280 }\nnew ByteUnitObject('10 MiB').add('20 MiB').toIECBytes()\n// << '30.00 MiB'\n```\n\n#### ByteUnitObject().add(bytes)\n\n* `bytes`: &lt;[HybridByte](#hybridbyte)|[HybridByte](#hybridbyte)[]&gt; Byte(s) to subract from the root byte.\n* Returns: &lt;[ByteUnitObject](#byteunitobject)&gt;\n\nAdd byte(s) to the internal bytes, resulting in a new [`ByteUnitObject`](#byteunitobject) object with the value\n\n#### ByteUnitObject().subtract(bytes)\n\n* `bytes`: &lt;[HybridByte](#hybridbyte)|[HybridByte](#hybridbyte)[]&gt; Subtract byte(s) from the internal bytes, resulting in a new ByteUnitObject object with the value.\n* Returns: &lt;[ByteUnitObject](#byteunitobject)&gt;\n\nSubtract byte(s) from the internal bytes, resulting in a new [`ByteUnitObject`](#byteunitobject) object with the value\n\n#### ByteUnitObject().multiply(bytes)\n\n* `bytes`: &lt;[HybridByte](#hybridbyte)|[HybridByte](#hybridbyte)[]&gt; Multiply byte(s) with the internal bytes, resulting in a new ByteUnitObject object with the value.\n* Returns: &lt;[ByteUnitObject](#byteunitobject)&gt;\n\nMultiply byte(s) with the internal bytes, resulting in a new [`ByteUnitObject`](#byteunitobject) object with the value\n\n#### ByteUnitObject().divide(bytes)\n\n* `bytes`: &lt;[HybridByte](#hybridbyte)|[HybridByte](#hybridbyte)[]&gt; Byte(s) to divide with.\n* Returns: &lt;[ByteUnitObject](#byteunitobject)&gt;\n\nDivide internal bytes by byte(s) specified, resulting in a new [`ByteUnitObject`](#byteunitobject) object with the value\n\n#### ByteUnitObject().convertTo(unit)\n\n* `unit`: &lt;[UnitString](#unitstring)&gt;\n* Returns: &lt;[ByteString](#bytestring)&gt;\n\nParse the internal byte into any unit, following the relativity.\n\n``` javascript\nnew ByteUnitObject('10 MiB')\n// >> ByteUnitObject { bytes: 10485760 }\nnew ByteUnitObject('10 MiB').convertTo('MB')\n// >> '10.49 MB'\nnew ByteUnitObject('10 MiB').add('50 MB').convertTo('KB')\n    '60485.76 KB'\n```\n\n#### ByteUnitObject().objectify(opts)\n\n* `opts`: &lt;[ByteOptions](#byteoptions)&gt;\n\nParse the internal bytes property to a byte object.\n\n#### ByteUnitObject().checkInternalByteVal(bytes)\n\nMethod to check integrity of internal bytes. Throw if there's an error somewhere.\n\n### <a id='hybridbyterelations'></a> HybridByteRelations: [`Object`][object]\n\n* `raw`:<a id='hybridraw'></a> &lt;[HybridByte](#hybridbyte)&gt; The unparsed data\n* `bits`: &lt;[ByteString](#bytestring)&gt; A relative bit parsing of the input [HybridByte](#hybridraw)\n* `size`: &lt;[number][]&gt; The numeric byte format of the input [HybridByte](#hybridraw)\n* `bytes`: &lt;[ByteString](#bytestring)&gt; A relative byte parsing of the input [HybridByte](#hybridraw)\n* `iecBits`: &lt;[ByteString](#bytestring)&gt; A relative bit parsing of the input [HybridByte](#hybridraw) under the IEC Specification\n* `parsed`: &lt;[ByteString](#bytestring)&gt; A relative bit parsing of the input [HybridByte](#hybridraw) under the IEC Specification\n* `iecBytes`: &lt;[ByteString](#bytestring)&gt; A relative byte parsing of the input [HybridByte](#hybridraw) under the IEC Specification\n\n## More Examples\n\nCheck out some examples in the `examples` folder\n\n``` javascript\n$ node examples/index.js 'Hey, its 6GB, but my 8 TB flash drive is better'\n┌─────────┬──────────┬───────────┬────────┬───────────┬────────────┬────────────┬─────────────┐\n│ (index) │  parsed  │   size    │  raw   │   bytes   │  iecBytes  │    bits    │   iecBits   │\n├─────────┼──────────┼───────────┼────────┼───────────┼────────────┼────────────┼─────────────┤\n│    0    │ [Object] │ '6.00 GB' │ '6GB'  │ '6.00 GB' │ '5.59 GiB' │ '48.00 Gb' │ '44.70 Gib' │\n│    1    │ [Object] │ '8.00 TB' │ '8 TB' │ '8.00 TB' │ '7.28 TiB' │ '64.00 Tb' │ '58.21 Tib' │\n└─────────┴──────────┴───────────┴────────┴───────────┴────────────┴────────────┴─────────────┘\n$ node examples/parse.js 'The 10GB file was downloaded in 50MB/s'\nThe 10737418240 file was downloaded in 52428800/s\n$ node examples/relative.js mb '10GiB, 1mb 6   gb'\n85899.35 Mb, 1.00 Mb 6000.00 Mb\n$ node examples/random.js 10 // Parse 10 random bytes\n[tabular data]\n$ node examples/extract.js 'Hey, its 6GB, but my 8 TB flash drive is better'\n┌─────────┬────────┬───────────────┐\n│ (index) │  size  │     bytes     │\n├─────────┼────────┼───────────────┤\n│    0    │ '6GB'  │  6000000000   │\n│    1    │ '8 TB' │ 8000000000000 │\n└─────────┴────────┴───────────────┘\n```\n\n## Features\n\n### Compatible with all versions of NodeJS (tested from v1.8.4)\n\n``` bash\n$ nvm exec v1.8.4 node -pe 'require(\".\")(3748587)'\n\"3.75 MB\"\n$ nvm exec v5.12.0 node -pe 'require(\".\").parseSize(\"476 TiB\")'\n523367534821376\n$ nvm exec v11.10.0 node -e '\n  let xbytes = require(\"./dist\");\n  let str = \"My 10GB drive transmits at 250MiB/sec\"\n  console.log(str.replace(xbytes.globalByteFilter, xbytes.relative.bits))\n'\n\"My 80.00 Gb drive transmits at 2.10 Gb/sec\"\n```\n\n### Decimal parsing\n\n``` javascript\nxbytes(524334545.847775856); // 524.33 MB\nxbytes.parseSize('665.284 TiB'); // 731487493773328.4\n\nxbytes(.24283884748955); // 0.24 B\nxbytes.parseSize('.295 MB'); // 295000\n```\n\n### Parse human readable sizes in binary ([IEC][]) format to bytes\n\n``` javascript\nxbytes.parseSize('1 MiB'); // 1048576\n```\n\n### Parse byte values to extended human readable sizes\n\n``` javascript\nxbytes(50000000, {short: false}); // '50.00 MegaBytes'\n```\n\n### Match or extract [ByteString](#bytestring)s in a string\n\n``` javascript\nlet data = 'My 16GB flash drive has a 4GB Zip Archive and a 5MB JavaScript file';\nxbytes.extractBytes(data);\n  //> [ '16GB', '4GB', '5MB' ]\ndata.match(xbytes.globalByteFilter)\n  //> [ '16GB', '4GB', '5MB' ]\ndata.replace(xbytes.globalByteFilter, xbytes.parseSize)\n  //> 'My 16000000000 flash drive has a 4000000000 Zip Archive and a 5000000 JavaScript file'\ndata.replace(xbytes.globalByteFilter, xbytes.createSizeParser({ iec: false }))\n  //> 'My 17179869184 flash drive has a 4294967296 Zip Archive and a 5242880 JavaScript file'\n```\n\n### Decimal and Binary Unit Relativity\n\n``` javascript\nimport { parseSize, relative } from 'xbytes';\n\nrelative('35 TiB').bits // '307.86 Tb'\nrelative('35 TiB').bytes // '38.48 TB'\nrelative('35 TiB').iecBits // '280.00 Tib'\nrelative('35 TiB').iecBytes // '35.00 TiB'\n\nparseSize(relative('35 TiB', {fixed: 20}).bits);\n  //> 38482906972160\nparseSize(relative('35 TiB', {fixed: 20}).bytes);\n  //> 38482906972160\nparseSize(relative('35 TiB', {fixed: 20}).iecBits);\n  //> 38482906972160\nparseSize(relative('35 TiB', {fixed: 20}).iecBytes);\n  //> 38482906972160\n```\n\n## Development\n\n### Building\n\nFeel free to clone, use in adherance to the [license](#license) and perhaps send pull requests\n\n``` bash\ngit clone https://github.com/miraclx/xbytes.git\ncd xbytes\nnpm install\n# hack on code\nnpm run build\nnpm test\n```\n\n### Testing\n\nTests are executed with [Jest][jest]. To use it, simple run `npm install`, it will install\nJest and its dependencies in your project's `node_modules` directory followed by `npm run build` and finally `npm test`.\n\nTo run the tests:\n\n```bash\nnpm install\nnpm run build\nnpm test\n```\n\n## License\n\n[Apache 2.0][license] © **Miraculous Owonubi** ([@miraclx][author-url]) &lt;omiraculous@gmail.com&gt;\n\n[IEC]: https://en.wikipedia.org/wiki/Units_of_information#Systematic_multiples 'International Electrotechnical Commission'\n[npm]:  https://github.com/npm/cli 'The Node Package Manager'\n[jest]:  https://github.com/facebook/jest 'Delightful JavaScript Testing'\n[license]:  LICENSE 'Apache 2.0 License'\n[author-url]: https://github.com/miraclx\n\n[npm-url]: https://npmjs.org/package/xbytes\n[npm-image]: https://badgen.net/npm/node/xbytes\n[npm-image-url]: https://nodei.co/npm/xbytes.png?stars&downloads\n[downloads-url]: https://npmjs.org/package/xbytes\n[downloads-image]: https://badgen.net/npm/dm/xbytes\n\n[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\n[object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\n[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\n[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\n[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\n[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\n","publish_time":1552225671904,"_cnpm_publish_time":1552225671904,"dist-tags":{"latest":"1.9.1"}}