{"id":29629908,"url":"https://github.com/binarymax/bitflags","last_synced_at":"2025-07-21T10:07:45.731Z","repository":{"id":26835108,"uuid":"30294425","full_name":"binarymax/bitflags","owner":"binarymax","description":"Small library for working with an arbitrarily large array of booleans","archived":false,"fork":false,"pushed_at":"2015-08-28T14:33:38.000Z","size":148,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T12:26:51.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/binarymax.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}},"created_at":"2015-02-04T10:53:50.000Z","updated_at":"2023-09-04T04:25:50.000Z","dependencies_parsed_at":"2022-07-17T21:46:06.102Z","dependency_job_id":null,"html_url":"https://github.com/binarymax/bitflags","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/binarymax/bitflags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fbitflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fbitflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fbitflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fbitflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binarymax","download_url":"https://codeload.github.com/binarymax/bitflags/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fbitflags/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266278415,"owners_count":23904044,"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":"2025-07-21T10:07:44.974Z","updated_at":"2025-07-21T10:07:45.726Z","avatar_url":"https://github.com/binarymax.png","language":"JavaScript","readme":"# bitflags\nSmall library for working with an arbitrarily large array of booleans\n\n\n## Install\n\n### npm\n```\nnpm install bitflags\n```\n\n## API\n\n```\nvar bitflags = require('bitflags');\nvar flags = bitflags(1000000); //Creates a million boolean flags\n```\n\n### get\nGets the bool at offset\n\n```\nflags.get(n) //returns true or false\n```\n\n### set\nSets a bit at offset to bool\n\n```\nflags.set(n,0) //sets to false\n```\n\n```\nflags.set(n,1) //sets to true\n```\n\n```\nflags.set(n,'truthy') //sets to true\n```\n\n\n### on\nSets the bit at offset to true\n\n```\nflags.on(n)\n```\n\n### off\nSets the bit at offset to false\n\n```\nflags.off(n)\n```\n\n### flip\nFlip and returns the value of a single bit at offset\n\n```\nflags.flip(n)\n```\n\n### fill\nReset to all 1's\n\n```\nflags.fill()\n```\n\n### clear\nReset to all 0's\n\n```\nflags.clear()\n```\n\n### size\nReturn exact size in bits\n*note: may be larger than size specified in constructor, due to storage in octets*\n```\nflags.size()\n```\n\n## Example\n\nSets a flag for each prime in the first 2000000 integers, using Sieve of Eratosthenes, returns a function to test for primes:\n\n```javascript\nvar getSieveOfEratosthenes = function() {\n\tvar size = 2000000;\n\tvar bits = bitflags(size);\n\tbits.fill();\n\tbits.set(0,0);\n\tvar lim = Math.ceil(Math.sqrt(size));\n\tfor(var i=2;i\u003c=lim;i++) {\n\t\tif(bits.get(i)){\n\t\t\tfor(var j=i*i;j\u003c=size;j+=i) {\n\t\t\t\tbits.set(j,0);\n\t\t\t}\n\t\t}\n\t};\n\n\treturn function(n){ return bits.get(n); };\n};\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarymax%2Fbitflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinarymax%2Fbitflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarymax%2Fbitflags/lists"}