{"_id":"@3xpo/bufferpack","_rev":"2-1f941f56bb8b3f57b31ce96f114fc89d","name":"@3xpo/bufferpack","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.6":{"name":"@3xpo/bufferpack","description":"Module to pack/unpack primitives and c strings into/out of a Node.js buffer","version":"0.0.6","keywords":["jspack","buffer","octet","primitive","string"],"homepage":"https://github.com/Exponential-Workload/bufferpack","repository":{"type":"git","url":"git://github.com/Exponential-Workload/bufferpack.git"},"main":"./dist/bufferpack.bundle.min.cjs","module":"./dist/bufferpack.bundle.min.mjs","types":"./dist/bufferpack.d.ts","typings":"./dist/bufferpack.d.ts","exports":{".":{"types":"./dist/bufferpack.d.ts","import":"./dist/bufferpack.bundle.min.mjs","require":"./dist/bufferpack.bundle.min.cjs","node":"./dist/bufferpack.bundle.min.mjs","default":"./dist/bufferpack.bundle.min.mjs"}},"sideEffects":false,"author":{"name":"Expo"},"maintainers":[{"name":"exponentialworkload","email":"cc@aaathats3as.com"}],"devDependencies":{"@3xpo/es-many":"^0.2.5","@changesets/cli":"^2.27.1","@types/jest":"^29.5.11","@types/node":"^20.10.6","concurrently":"^8.2.2","esbuild":"^0.19.11","jest":"^29.7.0","prettier":"^3.1.1","publint":"^0.2.7","should":"~13.2.3","ts-jest":"^29.1.1","typescript":"^5.3.3"},"type":"module","scripts":{"test":"jest","lint":"prettier . -c","build":"concurrently \"npm:build:*\"","build:es":"esmany --args \"src/bufferpack.ts --sourcemap --packages=external\" --output dist/bufferpack --minify true --platform node,browser,neutral --format cjs,esm --bundle true","build:ts":"tsc --emitDeclarationOnly --declaration --declarationMap"},"bugs":{"url":"https://github.com/Exponential-Workload/bufferpack/issues"},"_id":"@3xpo/bufferpack@0.0.6","_integrity":"sha512-rWDd8kaXWVibUY12DuD+2rwyqxrCxnuIu2AzXZim8otvqkPmvgsnmhjQ8PD8ljbXVdX9Y0AJXSvJVMsT/0GPiQ==","_resolved":"/tmp/482bc5c5f76caa1fcbf7a0c87721480f/3xpo-bufferpack-0.0.6.tgz","_from":"file:3xpo-bufferpack-0.0.6.tgz","_nodeVersion":"21.5.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-rWDd8kaXWVibUY12DuD+2rwyqxrCxnuIu2AzXZim8otvqkPmvgsnmhjQ8PD8ljbXVdX9Y0AJXSvJVMsT/0GPiQ==","shasum":"9e27a2f5ab28ba44f2ddd720894a8ba90a05019f","tarball":"https://registry.npmjs.org/@3xpo/bufferpack/-/bufferpack-0.0.6.tgz","fileCount":31,"unpackedSize":236138,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICJlNZv0RInF1lra1un4diNbrdSxnp3E5r/vHDfO+hJbAiEAulAe3WzcabQOpfLwV7Fm2wkxTyyFA7Sm0na3f9r9kCE="}]},"_npmUser":{"name":"exponentialworkload","email":"cc@aaathats3as.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bufferpack_0.0.6_1704405571878_0.50862691890269"},"_hasShrinkwrap":false},"0.0.7":{"name":"@3xpo/bufferpack","description":"Module to pack/unpack primitives and c strings into/out of a Node.js buffer","version":"0.0.7","keywords":["jspack","buffer","octet","primitive","string"],"homepage":"https://github.com/Exponential-Workload/bufferpack","repository":{"type":"git","url":"git://github.com/Exponential-Workload/bufferpack.git"},"main":"./dist/bufferpack.bundle.min.cjs","module":"./dist/bufferpack.bundle.min.mjs","types":"./dist/bufferpack.d.ts","typings":"./dist/bufferpack.d.ts","exports":{".":{"types":"./dist/bufferpack.d.ts","import":"./dist/bufferpack.bundle.min.mjs","require":"./dist/bufferpack.bundle.min.cjs","node":"./dist/bufferpack.bundle.min.mjs","default":"./dist/bufferpack.bundle.min.mjs"}},"sideEffects":false,"author":{"name":"Expo"},"maintainers":[{"name":"exponentialworkload","email":"cc@aaathats3as.com"}],"devDependencies":{"@3xpo/es-many":"^0.2.5","@changesets/cli":"^2.27.1","@types/jest":"^29.5.11","@types/node":"^20.10.6","concurrently":"^8.2.2","esbuild":"^0.19.11","jest":"^29.7.0","prettier":"^3.1.1","publint":"^0.2.7","should":"~13.2.3","ts-jest":"^29.1.1","typescript":"^5.3.3"},"type":"module","scripts":{"test":"jest","lint":"prettier . -c","build":"concurrently \"npm:build:*\"","build:es":"esmany --args \"src/bufferpack.ts --sourcemap --packages=external\" --output dist/bufferpack --minify true --platform node,browser,neutral --format cjs,esm --bundle true","build:ts":"tsc --emitDeclarationOnly --declaration --declarationMap"},"bugs":{"url":"https://github.com/Exponential-Workload/bufferpack/issues"},"_id":"@3xpo/bufferpack@0.0.7","_integrity":"sha512-SmlopXd9B5SkVmBCzk7rBGwGrNPBkUYUn3G567HYEN3chAp7novsns/fV5O9+XnX/+DLhk9xPKRwxDQDkHYnTw==","_resolved":"/tmp/25624ba7406b5c9c35f5ad638aa205dc/3xpo-bufferpack-0.0.7.tgz","_from":"file:3xpo-bufferpack-0.0.7.tgz","_nodeVersion":"21.5.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-SmlopXd9B5SkVmBCzk7rBGwGrNPBkUYUn3G567HYEN3chAp7novsns/fV5O9+XnX/+DLhk9xPKRwxDQDkHYnTw==","shasum":"d9cbc011776db6582c2c05b758aafa1a08ae6404","tarball":"https://registry.npmjs.org/@3xpo/bufferpack/-/bufferpack-0.0.7.tgz","fileCount":33,"unpackedSize":238236,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFZw0dyUQCP47mTyacoVrOGUNGGu14rXuE0Zx2w73plhAiEAuoPBGzvdREXFwbigCCvTlBgG8n6Ggfys26s/+0SdTQ8="}]},"_npmUser":{"name":"exponentialworkload","email":"cc@aaathats3as.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bufferpack_0.0.7_1704407144975_0.7413786964185431"},"_hasShrinkwrap":false},"0.0.8":{"name":"@3xpo/bufferpack","description":"Module to pack/unpack primitives and c strings into/out of a Node.js buffer","version":"0.0.8","keywords":["jspack","buffer","octet","primitive","string"],"homepage":"https://github.com/Exponential-Workload/bufferpack","repository":{"type":"git","url":"git://github.com/Exponential-Workload/bufferpack.git"},"main":"./dist/bufferpack.bundle.min.cjs","module":"./dist/bufferpack.bundle.min.mjs","types":"./dist/bufferpack.d.ts","typings":"./dist/bufferpack.d.ts","exports":{".":{"types":"./dist/bufferpack.d.ts","import":"./dist/bufferpack.bundle.min.mjs","require":"./dist/bufferpack.bundle.min.cjs","node":"./dist/bufferpack.bundle.min.mjs","default":"./dist/bufferpack.bundle.min.mjs"}},"sideEffects":false,"author":{"name":"Expo"},"maintainers":[{"name":"exponentialworkload","email":"cc@aaathats3as.com"}],"devDependencies":{"@3xpo/es-many":"^0.2.5","@changesets/cli":"^2.27.1","@types/jest":"^29.5.11","@types/node":"^20.10.6","concurrently":"^8.2.2","esbuild":"^0.19.11","jest":"^29.7.0","prettier":"^3.1.1","publint":"^0.2.7","should":"~13.2.3","ts-jest":"^29.1.1","typescript":"^5.3.3"},"type":"module","scripts":{"test":"jest","lint":"prettier . -c","build":"concurrently \"npm:build:*\"","build:es":"esmany --args \"src/bufferpack.ts --sourcemap --packages=external\" --output dist/bufferpack --minify true --platform node,browser,neutral --format cjs,esm --bundle true","build:ts":"tsc --emitDeclarationOnly --declaration --declarationMap"},"bugs":{"url":"https://github.com/Exponential-Workload/bufferpack/issues"},"_id":"@3xpo/bufferpack@0.0.8","_integrity":"sha512-oW7So7uANyPwwjVSwRABHR/Rwdiegxmc7Dfeb1bNwTimW4TmJhBEDAMG/hK4/120jIgSNfR4IMIv0tdEFzVLAw==","_resolved":"/tmp/27c2bf7a0bc56327b3b526131762d701/3xpo-bufferpack-0.0.8.tgz","_from":"file:3xpo-bufferpack-0.0.8.tgz","_nodeVersion":"21.5.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-oW7So7uANyPwwjVSwRABHR/Rwdiegxmc7Dfeb1bNwTimW4TmJhBEDAMG/hK4/120jIgSNfR4IMIv0tdEFzVLAw==","shasum":"f8eccac147dd046eef233fd82ed6c09116d6fd0f","tarball":"https://registry.npmjs.org/@3xpo/bufferpack/-/bufferpack-0.0.8.tgz","fileCount":33,"unpackedSize":238137,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGwM3m1Gfig46YeWSYRZPih+tjfRVo4Wa89M1LqvzfVQAiBCTBsPm6yCk9AIoyymGKkv4ofAJSPzUM8mXsTxJcoOag=="}]},"_npmUser":{"name":"exponentialworkload","email":"cc@aaathats3as.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bufferpack_0.0.8_1704407424032_0.12408420384626373"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-04T21:59:31.756Z","0.0.6":"2024-01-04T21:59:32.126Z","modified":"2024-01-04T22:30:24.455Z","0.0.7":"2024-01-04T22:25:45.176Z","0.0.8":"2024-01-04T22:30:24.241Z"},"maintainers":[{"name":"exponentialworkload","email":"cc@aaathats3as.com"}],"description":"Module to pack/unpack primitives and c strings into/out of a Node.js buffer","homepage":"https://github.com/Exponential-Workload/bufferpack","keywords":["jspack","buffer","octet","primitive","string"],"repository":{"type":"git","url":"git://github.com/Exponential-Workload/bufferpack.git"},"author":{"name":"Expo"},"bugs":{"url":"https://github.com/Exponential-Workload/bufferpack/issues"},"readme":"# bufferpack - Module to pack primitives and C strings to buffers\n\n## Disclaimer\n\nThe jspack module and documentation are essentially ports of the\nPython struct module and documentation, with such changes as were necessary. The port\nwas originaly made by Fair Oaks Labs, Inc. and published at http://code.google.com/p/jspack/\nIf any Python people are miffed that their documentation got ripped off, let me know,\nand I'll gladly revise them. The original port to Node.js was done by pgriess. This\nis a fork of node-jspack (https://github.com/pgriess/node-jspack && https://github.com/birchroad/node-jspack).\n\nThis module performs conversions between JavaScript values and C structs\nrepresented as octet arrays (i.e. JavaScript arrays of integral numbers\nbetween 0 and 255, inclusive). It uses format strings (explained below) as\ncompact descriptions of the layout of the C structs and the intended conversion\nto/from JavaScript values. This can be used to handle binary data stored in\nfiles, or received from network connections or other sources.\n\nThis library has been somewhat \"cleaned up\" by someone who is getting a headache\nstaring at this abysmal code, and as such may not work perfectly. The previous test\nsuite still passes, so :shrug: you're on your own if shit dies.\n\n## Install\n\n    pnpm i @3xpo/bufferpack\n\n## Reference\n\nThe module defines the following functions:\n\n### unpack(format, buffer, position)\n\nReturn an array or object containing values unpacked from the octet array a,\nbeginning at position p, according to the supplied format string. If there\nare more octets in a than required by the format string, the excess is\nignored. If there are fewer octets than required, unpack() will return\nundefined. If no value is supplied for the p argument, zero is assumed. By default\nan array of values is returned. However, if all format characters are assigned\na name/key an object containing all key/value pairs will returned.\n\n### packTo(format, buffer, position, values)\n\nPack and store the values array into the supplied octet array a, beginning\nat position p. If there are more values supplied than are specified in the\nformat string, the excess is ignored. If there are fewer values supplied,\npackTo() will return false. If there is insufficient space in a to store\nthe packed values, packTo() will return false. On success, packTo() returns\nthe a argument. If any value is of an inappropriate type, the results are\nundefined.\n\n### pack(format, values)\n\nReturn an octet array containing the packed values array. If there are\nmore values supplied than are specified in the format string, the excess is\nignored. If there are fewer values supplied, pack() will return false. If\nany value is of an inappropriate type, the results are undefined.\n\n### calcLength(format, values)\n\nReturn the number of octets required to store the given format string.\n\n## Formats\n\nFormat characters have the following meanings; the conversion between C and\nJavaScript values should be obvious given their types:\n\n    Format | C Type         | JavaScript Type   | Size (octets) | Notes\n    -------------------------------------------------------------------\n       A   | char[]         | Array             |     Length     |  (1)\n       x   | pad byte       | N/A               |        1       |\n       c   | char           | string (length 1) |        1       |  (2)\n       b   | signed char    | number            |        1       |  (3)\n       B   | unsigned char  | number            |        1       |  (3)\n       h   | signed short   | number            |        2       |  (3)\n       H   | unsigned short | number            |        2       |  (3)\n       i   | signed long    | number            |        4       |  (3)\n       I   | unsigned long  | number            |        4       |  (3)\n       l   | signed long    | number            |        4       |  (3)\n       L   | unsigned long  | number            |        4       |  (3)\n       S   | C string       | string            |        *       |  (6)\n       s   | char[]         | string            |     Length     |  (2)\n       f   | float          | number            |        4       |  (4)\n       d   | double         | number            |        8       |  (5)\n\nNotes:\n\n(1) The \"A\" code simply returns a slice of the source octet array. This is\nprimarily useful when a data structure contains bytes which are subject to\nmultiple intepretations (e.g. unions), and the data structure is being\ndecoded in multiple passes.\n\n(2) The \"c\" and \"s\" codes handle strings with codepoints between 0 and 255,\ninclusive. The data are not bounds-checked, so strings containing characters\nwith codepoints outside this range will encode to \"octet\" arrays that contain\nvalues outside the range of an octet. Furthermore, since these codes decode\noctet arrays by assuming the octets represent UNICODE codepoints, they may\nnot \"correctly\" decode bytes in the range 128-255, since that range is subject\nto multiple interpretations. Caveat coder!\n\n(3) The 8 \"integer\" codes clip their encoded values to the minima and maxmima\nof their respective types: If you invoke Struct.pack('b', [-129]), for\ninstance, the result will be [128], which is the octet encoding of -128,\nwhich is the minima of a signed char. Similarly, Struct.pack('h', [-32769])\nreturns [128, 0]. Fractions are truncated.\n\n(4) Since JavaScript doesn't natively support 32-bit floats, whenever a float\nis stored, the source JavaScript number must be rounded. This module applies\ncorrect rounding during this process. Numbers with magnitude greater than or\nequal to 2^128-2^103 round to either positive or negative Infinity. The\nrounding algorithm assumes that JavsScript is using exactly 64 bits of\nfloating point precision; 128-bit floating point will result in subtle errors.\n\n(5) This module assumes that JavaScript is using 64 bits of floating point\nprecision, so the \"d\" code performs no rounding. 128-bit floating point will\ncause the \"d\" code to simply truncate significands to 52 bits.\n\n(6) Same handling as (2), but with varible length. Length of c strings is\nvariable, C strings are length + 1 (null byte).\n\nA format character may be preceded by an integral repeat count. For example,\nthe format string \"4h\" means exactly the same thing as \"hhhh\".\n\nWhitespace characters between formats are ignored; a count and its format must\nnot be separated by whitespace, however.\n\nFor the \"A\" format character, the count is interpreted as the size of the\narray, not a repeat count as for the other format characters; for example, \"10A\"\nmeans a single 10-octet array. When packing, the Array is truncated or padded\nwith 0 bytes as appropriate to make it conform to the specified length. When\nunpacking, the resulting Array always has exactly the specified number of bytes.\nAs a special case, \"0A\" means a single, empty Array.\n\nFor the \"s\" format character, the count is interpreted as the size of the\nstring, not a repeat count as for the other format characters; for example,\n\"10s\" means a single 10-byte string, while \"10c\" means 10 characters. When\npacking, the string is truncated or padded with 0 bytes as appropriate to make\nit conform to the specified length. When unpacking, the resulting string always\nhas exactly the specified number of bytes. As a special case, \"0s\" means a\nsingle, empty string (while \"0c\" means 0 characters). If variable length strings\nrequired use the \"S\" format character, values decoded/encoded this way must be null\nterminated.\n\nA name/key can be assigned to each format character using \"(name)\". For unpack to\nuse names each format character in the format string must be assigned a name.\nExample: \"S(firstName)S(lastName)B(age)\". This would result in unpack returning\n{\"firstName\": \"Ryan\", \"lastName\": \"Olds\", \"age\": 28}\n\nBy default, C numbers are represented in network (or big-endian) byte order.\nAlternatively, the first character of the format string can be used to indicate\nbyte order of the packed data, according to the following table:\n\n    Character | Byte Order\n    ----------------------------------\n        <     | little-endian\n        >     | big-endian\n        !     | network (= big-endian)\n\nIf the first character is not one of these, \"!\" is assumed.\n\n## Running Tests\n\nTo run the test suite first invoke the following command within the repo, installing the development dependencies:\n\n    $ npm install\n\nthen run the tests:\n\n    $ npm test\n","readmeFilename":"README.md"}