{"id":21831400,"url":"https://github.com/nodef/extra-bit","last_synced_at":"2025-04-14T07:07:11.382Z","repository":{"id":42076621,"uuid":"249481796","full_name":"nodef/extra-bit","owner":"nodef","description":"The bit is a basic unit of information in information theory, computing.","archived":false,"fork":false,"pushed_at":"2025-04-08T17:16:08.000Z","size":566,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T09:39:07.669Z","etag":null,"topics":["bit","bitwise","count","extra","get","get-as","interleave","manipulation","merge","operation","parity","reverse","rotate","scan","scan-reverse","set","set-as","sign-extend","swap","toggle"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/extra-bit","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/nodef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-23T16:17:50.000Z","updated_at":"2025-04-08T17:16:08.000Z","dependencies_parsed_at":"2025-04-13T09:39:13.733Z","dependency_job_id":null,"html_url":"https://github.com/nodef/extra-bit","commit_stats":{"total_commits":100,"total_committers":1,"mean_commits":100.0,"dds":0.0,"last_synced_commit":"b729ad89417d5e0e4a447f242216bd4b177587f9"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-bit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-bit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-bit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-bit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/extra-bit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248694790,"owners_count":21146949,"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":["bit","bitwise","count","extra","get","get-as","interleave","manipulation","merge","operation","parity","reverse","rotate","scan","scan-reverse","set","set-as","sign-extend","swap","toggle"],"created_at":"2024-11-27T19:10:16.156Z","updated_at":"2025-04-14T07:07:11.322Z","avatar_url":"https://github.com/nodef.png","language":"TypeScript","readme":"The [bit] is a basic unit of information in information theory, computing.\u003cbr\u003e\n📦 [Node.js](https://www.npmjs.com/package/extra-bit),\n🌐 [Web](https://www.npmjs.com/package/extra-bit.web),\n📜 [Files](https://unpkg.com/extra-bit/),\n📰 [Docs](https://nodef.github.io/extra-bit/),\n📘 [Wiki](https://github.com/nodef/extra-bit/wiki/).\n\nThe concept of a **bit**, which stands for *binary digit*, has been a\nfundamental unit of information in the fields of information theory and\ncomputing. Bitwise operations are used to manipulate and process data at the bit\nlevel, and these operations are *crucial for efficient programming* in a variety\nof domains, such as computer graphics and cryptography. JavaScript converts a\n`Number` (a *64-bit floating* *point number*) to a *32-bit integer* when bitwise\noperators (such as `|`) are applied. All bitwise operations are performed on\n**32-bit integers**. This package includes [bit twiddling hacks] by *Sean Eron*\n*Anderson* and many others.\n\nThis package is available in *Node.js* and *Web* formats. To use it on the web,\nsimply use the `extra_bit` global variable after loading with a `\u003cscript\u003e`\ntag from the [jsDelivr CDN].\n\n\u003e Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).\n\n[bit]: https://en.wikipedia.org/wiki/Bit\n[bit twiddling hacks]: https://graphics.stanford.edu/~seander/bithacks.html\n[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-bit.web/index.js\n\n\u003cbr\u003e\n\n```javascript\nconst xbit = require('extra-bit');\n// import * as xbit from \"extra-bit\";\n// import * as xbit from \"https://unpkg.com/extra-bit/index.mjs\"; (deno)\n\nxbit.count(7);\n// → 3 (111 ⇒ 3)\n\nxbit.parity(8, 2);\n// → 2 (10,00 ⇒ 10)\n\nxbit.swap(6, 1, 0);\n// → 5 (110 ⇒ 101)\n\nxbit.reverse(0xFFFF0000);\n// → 65535 (0x0000FFFF)\n\nxbit.signExtend(15, 4);\n// → -1\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## Index\n\n| Property | Description |\n|  ----  |  ----  |\n| [get] | Get bits at specified index. |\n| [getAs] | Get bits as per mask. |\n| [set] | Set bits at specified index. |\n| [setAs] | Set bits as per mask. |\n| [toggle] | Toggle bits at specified index. |\n| [toggleAs] | Toggle bits as per mask. |\n| [swap] | Swap bit sequences at specified indices. |\n| [scan] | Find index of first set bit from LSB. |\n| [scanReverse] | Find index of first set bit from MSB. |\n| [count] | Count bits set. |\n| [parity] | Calculate n-bit parity. |\n| [rotate] | Rotate bits by a certain amount. |\n| [reverse] | Reverse all bits. |\n| [merge] | Merge bits as per mask. |\n| [interleave] | Interleave bits of two int16s. |\n| [signExtend] | Sign extend variable bit-width integer. |\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## References\n\n- [Bit Twiddling Hacks by Sean Eron Anderson](https://graphics.stanford.edu/~seander/bithacks.html)\n- [bit-twiddle package by @mikolalysenko](https://www.npmjs.com/package/bit-twiddle)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n[![](https://img.youtube.com/vi/4Yy0pPTrHlk/maxresdefault.jpg)](https://www.youtube.com/watch?v=4Yy0pPTrHlk)\u003cbr\u003e\n[![ORG](https://img.shields.io/badge/org-nodef-green?logo=Org)](https://nodef.github.io)\n[![DOI](https://zenodo.org/badge/249481796.svg)](https://zenodo.org/badge/latestdoi/249481796)\n[![Coverage Status](https://coveralls.io/repos/github/nodef/extra-bit/badge.svg)](https://coveralls.io/github/nodef/extra-bit)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/fa297c53c53f4e01bce8/test_coverage)](https://codeclimate.com/github/nodef/extra-bit/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/fa297c53c53f4e01bce8/maintainability)](https://codeclimate.com/github/nodef/extra-bit/maintainability)\n![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/extra-bit)\n\n[get]: https://github.com/nodef/extra-bit/wiki/get\n[getAs]: https://github.com/nodef/extra-bit/wiki/getAs\n[set]: https://github.com/nodef/extra-bit/wiki/set\n[setAs]: https://github.com/nodef/extra-bit/wiki/setAs\n[toggle]: https://github.com/nodef/extra-bit/wiki/toggle\n[toggleAs]: https://github.com/nodef/extra-bit/wiki/toggleAs\n[swap]: https://github.com/nodef/extra-bit/wiki/swap\n[scan]: https://github.com/nodef/extra-bit/wiki/scan\n[scanReverse]: https://github.com/nodef/extra-bit/wiki/scanReverse\n[count]: https://github.com/nodef/extra-bit/wiki/count\n[parity]: https://github.com/nodef/extra-bit/wiki/parity\n[rotate]: https://github.com/nodef/extra-bit/wiki/rotate\n[reverse]: https://github.com/nodef/extra-bit/wiki/reverse\n[merge]: https://github.com/nodef/extra-bit/wiki/merge\n[interleave]: https://github.com/nodef/extra-bit/wiki/interleave\n[signExtend]: https://github.com/nodef/extra-bit/wiki/signExtend\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-bit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fextra-bit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-bit/lists"}