{"id":15355020,"url":"https://github.com/capaj/hashset.js","last_synced_at":"2025-07-23T21:38:37.745Z","repository":{"id":34650924,"uuid":"38618908","full_name":"capaj/hashset.js","owner":"capaj","description":"simple hashset implementation aimed to working with DB entries on frontend. If it has primary keys, storing it in a hashset is probably a good idea.","archived":false,"fork":false,"pushed_at":"2015-07-13T10:39:53.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-09T13:08:04.202Z","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/capaj.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-07-06T12:56:20.000Z","updated_at":"2019-08-09T01:39:06.000Z","dependencies_parsed_at":"2022-07-13T01:30:35.367Z","dependency_job_id":null,"html_url":"https://github.com/capaj/hashset.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/capaj/hashset.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fhashset.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fhashset.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fhashset.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fhashset.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capaj","download_url":"https://codeload.github.com/capaj/hashset.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fhashset.js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266753970,"owners_count":23979144,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-01T12:22:08.671Z","updated_at":"2025-07-23T21:38:37.720Z","avatar_url":"https://github.com/capaj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hashset.js [![Build Status](https://travis-ci.org/capaj/hashset.js.svg?branch=master)](https://travis-ci.org/capaj/hashset.js)\nsimple hashset implementation aimed to working with DB entries on frontend. If it has primary keys, storing it in a hashset is probably a good idea.\n\n## Installation\n```\njspm i npm:hashset.js\nnpm i hashset.js\n```\n\n## Why not es6 Set?\nBecause it is not suited for working with DB objects, such as objects returned from mongoDB where primary keys are '_id' properties. It is not possible to tell the native set that two objects with the same _id are the same.\n\n## API\nWith the API I tried to shadow ES6 Set, so it should feel almost as if you were working with the native Set implementation.\n\n### Hashset\n```\nvar hashFunction = '_id';\n//or your hashFunction can be an actual function\nvar hashFunction = function(item){return item.a+item.b};\nnew Hashset(hashFunction) //returns new instance of a Hashset\n```\n\n### Methods\n```\nadd(value) returns {boolean}\naddArray(arr) returns {Number}\nclear()\ndelete(valueOrKey) returns {boolean}\neach(iteratorFunction, thisObjopt)\nfilter() returns {Hashset}\ngetValue(hash) returns {*}\nhas(valueOrKey) returns {boolean}\nsize() returns {number}\ntoArray() returns {Array}\nupsert(value) returns {boolean}\t//requires Object.assign\nupsertArray(arr) returns {Number}\n```\n\nIf you want upserts in the ES5 environment, [polyfill Object.assign()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapaj%2Fhashset.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapaj%2Fhashset.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapaj%2Fhashset.js/lists"}