{"id":17036163,"url":"https://github.com/kormanowsky/collection","last_synced_at":"2025-08-25T01:11:31.875Z","repository":{"id":86846254,"uuid":"136540464","full_name":"kormanowsky/collection","owner":"kormanowsky","description":"JavaScript collection of objects","archived":false,"fork":false,"pushed_at":"2018-06-07T23:21:54.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T02:23:41.019Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kormanowsky.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-07T23:07:53.000Z","updated_at":"2018-06-07T23:21:56.000Z","dependencies_parsed_at":"2023-03-13T19:50:14.222Z","dependency_job_id":null,"html_url":"https://github.com/kormanowsky/collection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kormanowsky%2Fcollection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kormanowsky%2Fcollection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kormanowsky%2Fcollection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kormanowsky%2Fcollection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kormanowsky","download_url":"https://codeload.github.com/kormanowsky/collection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245031345,"owners_count":20549913,"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-14T08:49:31.214Z","updated_at":"2025-03-22T22:42:19.354Z","avatar_url":"https://github.com/kormanowsky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Collection\nJavaScript collection of objects.\nA Collection is an array of objects of specified class. All elements of a collection must be instances of the same class. You can add, remove, get elements, or do something for each of them like if you use a usual array. This function lets you forget about checking if a variable is an object of class because it does that stuff by itself. \n## Creating new Collection\nJust create new Collection object: \n```javascript\nfunction MyClass(x,y){\n  this.x = x;\n  this.y = y;\n}\nvar myCollection = new Collection(MyClass);\n```\n## Adding new element\nCall Collection.add() and you will get the id of new element: \n```javascript\nvar myElementId = myCollection.add(new MyClass(1,2));\n```\nThen you can use this id to do something with this element.\n## Getting the element\nCall Collection.get():\n```javascript\nvar myElement = myCollection.get(myElementId);\n```\n## Removing the element\nCall Collection.remove():\n```javascript\nmyCollection.remove(myElementId);\n```\n## Looping through the elements\n```javascript\nmyCollection.forEach(function(element, index, array){\n  //something\n});\n```\n## Extending your Collection\n```javascript\nfunction myVeryNiceFunction(list){\n  return list[0];\n}\nmyCollection.extend('veryNiceFunction', myVeryNiceFunction);\nvar firstElement = myCollection.veryNiceFunction();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkormanowsky%2Fcollection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkormanowsky%2Fcollection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkormanowsky%2Fcollection/lists"}