{"id":15612311,"url":"https://github.com/euberdeveloper/byteify","last_synced_at":"2025-04-28T18:54:02.192Z","repository":{"id":52870319,"uuid":"353446182","full_name":"euberdeveloper/byteify","owner":"euberdeveloper","description":"An npm module that serializes or deserializes your native types to an array of bytes.","archived":false,"fork":false,"pushed_at":"2023-04-27T14:01:26.000Z","size":912,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T10:44:04.322Z","etag":null,"topics":["hacktoberfest","hacktoberfest2022","npm","typescript"],"latest_commit_sha":null,"homepage":"https://byteify.euber.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/euberdeveloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-31T18:01:20.000Z","updated_at":"2024-01-22T01:09:51.000Z","dependencies_parsed_at":"2024-06-19T17:40:24.947Z","dependency_job_id":"e61977c4-e304-470c-9b69-a18a4f0331fc","html_url":"https://github.com/euberdeveloper/byteify","commit_stats":{"total_commits":189,"total_committers":3,"mean_commits":63.0,"dds":0.05820105820105825,"last_synced_commit":"cf611505a395458574065bbc0e6c4cb36bcbe915"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fbyteify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fbyteify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fbyteify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2Fbyteify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euberdeveloper","download_url":"https://codeload.github.com/euberdeveloper/byteify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251372457,"owners_count":21578960,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","hacktoberfest2022","npm","typescript"],"created_at":"2024-10-03T06:41:43.875Z","updated_at":"2025-04-28T18:54:02.175Z","avatar_url":"https://github.com/euberdeveloper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Lint](https://github.com/euberdeveloper/byteify/workflows/Lint/badge.svg)\n![Build](https://github.com/euberdeveloper/byteify/workflows/Build/badge.svg)\n![Test](https://github.com/euberdeveloper/byteify/workflows/Test/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/euberdeveloper/byteify/badge.svg?branch=main)](https://coveralls.io/github/euberdeveloper/byteify?branch=main)\n[![codecov](https://codecov.io/gh/euberdeveloper/byteify/branch/main/graph/badge.svg?token=4YW49XC338)](https://codecov.io/gh/euberdeveloper/byteify)\n[![Known Vulnerabilities](https://snyk.io/test/github/euberdeveloper/byteify/badge.svg?targetFile=package.json)](https://snyk.io/test/github/euberdeveloper/byteify?targetFile=package.json)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![License](https://img.shields.io/npm/l/byteify.svg)](https://github.com/euberdeveloper/byteify/blob/master/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/euberdeveloper/byteify.svg)](https://github.com/euberdeveloper/byteify/issues)\n[![GitHub stars](https://img.shields.io/github/stars/euberdeveloper/byteify.svg)](https://github.com/euberdeveloper/byteify/stargazers)\n![npm](https://img.shields.io/npm/v/byteify.svg)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Types](https://img.shields.io/npm/types/byteify.svg)](https://www.npmjs.com/package/byteify)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/898fd5ca5774fb92d9c8/test_coverage)](https://codeclimate.com/github/euberdeveloper/byteify/test_coverage)\n\n# byteify\nAn npm module that serializes or deserializes your native types to an array of bytes.\n\n## Install\n\nTo install byteify, run:\n\n```bash\n$ npm install byteify\n```\n\n## Usage\n\n## Serialize\n\n```js\nconst byteify = require('byteify');\n\n// The value will be: [1]\nconst serializedBool = byteify.serializeBool(true);\n\n// The value will be: [10]\nconst serializedUint8 = byteify.serializeUint8(10); \n// The value will be: [1, 0]\nconst serializedUint16 = byteify.serializeUint16(256, { endianess: ByteifyEndianess.BIG_ENDIAN }); \n// The value will be: [0, 15, 66, 64]\nconst serializedUint32 = byteify.serializeUint32(1000000, { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: [0, 0, 0, 0, 5, 245, 225, 0]\nconst serializedUint64 = byteify.serializeUint64(100000000n, { endianess: ByteifyEndianess.BIG_ENDIAN }); \n\n// The value will be: [255]\nconst serializedInt8 = byteify.serializeInt8(-1);\n// The value will be: [252, 24]\nconst serializedInt16 = byteify.serializeInt16(-1000, { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: [255, 254, 121, 96]\nconst serializedInt32 = byteify.serializeInt32(-100000, { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: [255, 255, 255, 255, 255, 255, 255, 255]\nconst serializedInt64 = byteify.serializeInt64(-1n, { endianess: ByteifyEndianess.BIG_ENDIAN });\n\n// The value will be: [10, 215, 185, 65]  \nconst serializedFloat32 = byteify.serializeFloat32(23.23, { endianess: ByteifyEndianess.LITTLE_ENDIAN });\n// The value will be: [123, 20, 174, 71, 225, 58, 55, 64]\nconst serializedFloat64 = byteify.serializeFloat64(23.23, { endianess: ByteifyEndianess.LITTLE_ENDIAN });\n```\n\n## Deserialize\n\n```js\nconst byteify = require('byteify');\nconst ByteifyEndianess = byteify.ByteifyEndianess;\n\n// The value will be: true\nconst deserializedBool = byteify.deserializeBool([1]);\n\n// The value will be: 10\nconst deserializedUint8 = byteify.deserializeUint8([10]);\n// The value will be: 1\nconst deserializedUint16 = byteify.deserializeUint16([1, 0], { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: 0\nconst deserializedUint32 = byteify.deserializeUint32([0, 15, 66, 64], { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: 100000000nn\nconst deserializedUint64 = byteify.deserializeUint64([5, 245, 225, 0, 5, 245, 225, 0], { endianess: ByteifyEndianess.BIG_ENDIAN });\n\n// The value will be: -1\nconst deserializedInt8 = byteify.deserializeInt8([255]);\n// The value will be: -1000\nconst deserializedInt16 = byteify.deserializeInt16([252, 24], { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: -100000\nconst deserializedInt32 = byteify.deserializeInt32([255, 254, 121, 96], { endianess: ByteifyEndianess.BIG_ENDIAN });\n// The value will be: -1n\nconst deserializedInt64 = byteify.deserializeInt64([255, 255, 255, 255, 255, 255, 255, 255], { endianess: ByteifyEndianess.BIG_ENDIAN });\n\n// The value will be: 23.23\nconst deserializedFloat32 = byteify.deserializeFloat32([10, 215, 185, 65], { endianess: ByteifyEndianess.LITTLE_ENDIAN });\n// The value will be: 23.23\nconst deserializedFloat64 = byteify.deserializeFloat64([123, 20, 174, 71, 225, 58,  55, 64], { endianess: ByteifyEndianess.LITTLE_ENDIAN });\n```\n\n## Endianess\n\nBy default, Little Endian is used. If you want to use Big Endian, you can pass it as an option\n\n```js\nconst byteify = require('byteify');\nconst ByteifyEndianess = byteify.ByteifyEndianess;\n\n// The value will be: 1000000\nconst deserializedUint64 = byteify.deserializeUint64([64, 66, 15, 0, 0, 0, 0, 0]);\nconst deserializedUint64 = byteify.deserializeUint64([64, 66, 15, 0, 0, 0, 0, 0], { endianess: ByteifyEndianess.LITTLE_ENDIAN });\nconst deserializedUint64 = byteify.deserializeUint64([0, 0, 0, 0, 0, 15, 66, 64], { endianess: ByteifyEndianess.BIG_ENDIAN });\n\n// The value will be [64, 66, 15, 0, 0, 0, 0, 0]\nconst serializedUint64 = byteify.serializeUint64(1000000, { endianess: ByteifyEndianess.LITTLE_ENDIAN });\n// The value will be [0, 0, 0, 0, 0, 15, 66, 64]\nconst serializedUint64 = byteify.serializeUint64(1000000, { endianess: ByteifyEndianess.BIG_ENDIAN });\n```\n\n## Limits\n\n```js\nconst { limits } = require('byteify');\n\n/*\n{\n    bool: 1,\n    uint8: 255,\n    uint16: 65_535,\n    uint32: 4_294_967_295,\n    uint64: 18_446_744_073_709_551_616n,\n    int8: 127,\n    int16: 32_767,\n    int32: 2_147_483_647,\n    int64: 9_223_372_036_854_775_807n,\n    float32: Number.MAX_VALUE,\n    float64: Number.MAX_VALUE\n}\n*/\nconsole.log(limits.MAX);\n\n/*\n{\n    bool: 0,\n    uint8: 0,\n    uint16: 0,\n    uint32: 0,\n    uint64: 0n,\n    int8: -128,\n    int16: -32_768,\n    int32: -2_147_483_648,\n    int64: -9_223_372_036_854_775_808n,\n    float32: -Number.MAX_VALUE,\n    float64: -Number.MAX_VALUE\n}\n*/\nconsole.log(limits.MIN);\n\n/*\n{\n    bool: 1,\n    uint8: 1,\n    uint16: 2,\n    uint32: 4,\n    uint64: 8,\n    int8: 1,\n    int16: 2,\n    int32: 4,\n    int64: 8,\n    float32: 4,\n    float64: 8\n}\n*/\nconsole.log(limits.N_OF_BYTES);\n```\n## API\n\nThe documentation site is: [byteify documentation](https://byteify.euber.dev)\n\nThe documentation for development site is: [byteify dev documentation](https://byteify-dev.euber.dev)\n\n## Development\n\nTo build the module make sure you have the dev dependencies installed.\n\nThe project is written in `Typescript`, bundled with `esbuild`, linted with `ESLint` and tested with `Jest`.\n\n### Lint\n\nIn order to lint the code:\n\n```bash\n$ npm run lint\n```\n\nIn order to lint and fix the code:\n\n```bash\n$ npm run lint:fix\n```\n\nThere are also the `:source` and `:test` suffix after `lint` in order to lint only the source code or the test code.\n\n### Transpile\n\nTo transpile both the source and the test code:\n\n```bash\n$ npm run transpile\n```\n\nThe `source` and the `test` folders will be transpiled in the `dist` folder. Also the `type declarations` will be generated.\n\n\nTo transpile only the source code:\n\n```bash\n$ npm run transpile:source\n```\n\nThe `source` folder will be transpiled in the `dist` folder. Also the `type declarations` will be generated.\n\n### Test\n\nAfter having transpiled the code, run:\n\n```bash\n$ npm test\n```\n\nin order to run the tests with `jest`.\n\nIf a coverage report is to be generated, run:\n\n```bash\n$ npm run cover:generate\n```\n\n### Bundle\n\n```bash\n$ npm run bundle\n```\n\nThe `source` folder will be compiled in the `bundled` folder. It will contain the bundled `index.js` and `index.d.ts` files.\n\n### Notes\n\n* For simplicity, the limits for the floating point numbers are always `Number.MAX_VALUE` and `-Number.MAX_VALUE`. For `float32` this means that the result is not guaranteed for too precise inputs.\n* For `uint64` and `int64`, the `BigInt` type is used.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fbyteify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuberdeveloper%2Fbyteify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fbyteify/lists"}