{"id":17963851,"url":"https://github.com/bramstein/bit-array","last_synced_at":"2025-05-12T17:23:05.574Z","repository":{"id":940695,"uuid":"715910","full_name":"bramstein/bit-array","owner":"bramstein","description":"JavaScript implementation of bit arrays.","archived":false,"fork":false,"pushed_at":"2021-10-20T16:57:45.000Z","size":35,"stargazers_count":78,"open_issues_count":6,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-12T17:22:54.345Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramstein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-06-11T15:46:34.000Z","updated_at":"2023-10-17T19:44:04.000Z","dependencies_parsed_at":"2022-08-16T11:35:05.414Z","dependency_job_id":null,"html_url":"https://github.com/bramstein/bit-array","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fbit-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fbit-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fbit-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fbit-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramstein","download_url":"https://codeload.github.com/bramstein/bit-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253785068,"owners_count":21963913,"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":[],"created_at":"2024-10-29T11:45:40.151Z","updated_at":"2025-05-12T17:23:05.535Z","avatar_url":"https://github.com/bramstein.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bit-Array is deprecated. \n\nPlease use \u003ca href=\"https://github.com/infusion/BitSet.js\" style=\"color: yellow;\"\u003eBitSet.js\u003c/a\u003e\n\n## JavaScript Bit Array Library\n\nThis library contains a JavaScript implementation of bit arrays. The library supports:\n\n* getting, setting and toggling of individual bits\n* iterating over each bit\n* counting the number of \"on\" bits\n* bitwise operations with other bit arrays such as OR, AND and XOR.\n* serialization to and from JSON\n* Browser, Node.js and Ender.js compatible\n\nThe bit array is sparse. The following example shows how to set and get individual bits within the array:\n\n    a = new BitArray(32);\n    a.set(0, true);\n    a.set(31, true);\n    a.toString(); // \"10000000000000000000000000000001\"\n    a.get(1); // false\n    a.get(31); // true\n\nNote that the array internally uses 32 bit integers (actually, JavaScript's number type is 64 bit, but only 32 bits can be addressed using bitwise operations,) so going beyond the given length throws an error:\n\n    a.set(32, true); // throws an index of range exception\n\nEven though bit arrays are not that useful in JavaScript, there is one place where they excel; encoding large boolean sets for transfer between the browser and server. A JSON representation of a bit array is much smaller than an actual boolean array.\n\n## API\n\nThe BitArray module has two constructors:\n\n\u003cdl\u003e\n    \u003cdt\u003eBitArray(size)\u003c/dt\u003e\n    \u003cdd\u003eCreates a new empty bit array with the given size in bits.\u003c/dd\u003e\n\n    \u003cdt\u003eBitArray(size, hex)\u003c/dt\u003e\n    \u003cdd\u003eCreates a new bit array with the given size and using the hex string as value\u003c/dd\u003e\n\u003c/dl\u003e\n\nThe following instance methods are supported:\n\n\u003cdl\u003e\n    \u003cdt\u003esize()\u003c/dt\u003e\n    \u003cdd\u003eReturns the total number of bits in the BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003eset(index, boolean)\u003c/dt\u003e\n    \u003cdd\u003eSets the bit at index to a value (boolean.)\u003c/dd\u003e\n\n    \u003cdt\u003eget(index)\u003c/dt\u003e\n    \u003cdd\u003eReturns the value of the bit at index (boolean.)\u003c/dd\u003e\n\n    \u003cdt\u003etoggle(index)\u003c/dt\u003e\n    \u003cdd\u003eToggles the bit at index. If the bit is on, it is turned off. Likewise, if the bit is off it is turned on.\u003c/dd\u003e\n\n    \u003cdt\u003ereset()\u003c/dt\u003e\n    \u003cdd\u003eResets the BitArray so that it is empty and can be re-used.\u003c/dd\u003e\n\n    \u003cdt\u003ecopy()\u003c/dt\u003e\n    \u003cdd\u003eReturns a copy of this BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003eequals(other)\u003c/dt\u003e\n    \u003cdd\u003eReturns true if this BitArray equals another. Two BitArrays are considered equal if both have the same length and bit pattern.\u003c/dd\u003e\n\n    \u003cdt\u003etoJSON()\u003c/dt\u003e\n    \u003cdd\u003eReturns the JSON representation of this BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003etoString()\u003c/dt\u003e\n    \u003cdd\u003eReturns a string representation of the BitArray with bits in logical order.\u003c/dd\u003e\n\n    \u003cdt\u003etoHexString()\u003c/dt\u003e\n    \u003cdd\u003eReturns a hex representation of the BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003etoArray()\u003c/dt\u003e\n    \u003cdd\u003eConvert the BitArray to an Array of boolean values.\u003c/dd\u003e\n\n    \u003cdt\u003ecount()\u003c/dt\u003e\n    \u003cdd\u003eReturns the total number of bits set to 1 in this BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003enot()\u003c/dt\u003e\n    \u003cdd\u003eInverts this BitArray.\u003c/dd\u003e\n\n    \u003cdt\u003eor(other)\u003c/dt\u003e\n    \u003cdd\u003eBitwise OR on the values of this BitArray using BitArray `other`.\u003c/dd\u003e\n\n    \u003cdt\u003eand(other)\u003c/dt\u003e\n    \u003cdd\u003eBitwise AND on the values of this BitArray using BitArray `other`.\u003c/dd\u003e\n\n    \u003cdt\u003exor(other)\u003c/dt\u003e\n    \u003cdd\u003eBitwise XOR on the values of this BitArray using BitArray `other`.\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Installation\n\nYou can install the bit array module using npm:\n\n    \u003e npm install bit-array\n\nAlternatively you could just include [bit-array.js](lib/bit-array.js) in your project.\n\n## License\n\nLicensed under the revised BSD License. Copyright 2010-2012 Bram Stein. All rights reserved.\n\nPorts\n-----\nhttps://github.com/foglcz/bit-array - PHP port by Pavel Ptacek\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fbit-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramstein%2Fbit-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fbit-array/lists"}