{"id":21537120,"url":"https://github.com/rabanti-github/es6-yaca","last_synced_at":"2025-03-17T20:41:39.108Z","repository":{"id":86671248,"uuid":"101672457","full_name":"rabanti-github/es6-yaca","owner":"rabanti-github","description":"YACA (Yet Another Collection Approach) is a collections library for TypeScript / ES6 JavaScript","archived":false,"fork":false,"pushed_at":"2017-08-28T18:11:00.000Z","size":1096,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T07:41:35.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rabanti-github.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-08-28T18:07:42.000Z","updated_at":"2017-08-28T18:27:15.000Z","dependencies_parsed_at":"2023-11-28T23:15:06.873Z","dependency_job_id":null,"html_url":"https://github.com/rabanti-github/es6-yaca","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/rabanti-github%2Fes6-yaca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabanti-github%2Fes6-yaca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabanti-github%2Fes6-yaca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabanti-github%2Fes6-yaca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rabanti-github","download_url":"https://codeload.github.com/rabanti-github/es6-yaca/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244109800,"owners_count":20399559,"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-11-24T03:28:07.486Z","updated_at":"2025-03-17T20:41:39.084Z","avatar_url":"https://github.com/rabanti-github.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YACA\n\n**Y**et **A**nother **C**ollection **A**pproach\n\n## Introduction\n\nYACA is another approach to introduce Collections to TypeScript / JavaScript like known in Java, C# or other object-oriented programming languages. There are other approaches, but sometimes, small things regarding the convenience are missing.\n\n[![Coverage Status](https://coveralls.io/repos/github/rabanti-github/yaca/badge.svg?branch=master)](https://coveralls.io/github/rabanti-github/yaca?branch=master)\n![npm](https://img.shields.io/npm/v/yaca.svg?maxAge=86400)\n![license](https://img.shields.io/github/license/rabanti-github/yaca.svg)\n\nYACA contains at the moment **List\u0026lt;T\u0026gt;**, **Dictionary\u0026lt;K,V\u0026gt;** and **SortedDictionary\u0026lt;K,V\u0026gt;** as collection types. Further types (e.g. Stack) are planned.\n\n## Important features\n\n* Multiple add and remove functions like add, addRange, insertAtIndex, push or set\n* Multiple check functions like contains, containsKey, containsValues or containsKeyAsList\n* Multiple copy functions like copyToArray or getRange\n* forEach method provided (returns KeyValuePair for Dictionaries)\n* Build-in break and (optional) continue calls within forEach loops as control elements\n* Native sorting of the types number, string, boolean and Date (in List class)\n* Possibility of the implementation of a compareTo function in classes for sorting purpose (interface IComparer)\n* Possibility to sort SortedDictionary by key or value, according to the default behavior, a defined compariosn method or an implementation of a compareTo function\n* Provided static compareTo functions for the types number, string, boolean and Date (module Comparer)\n\nSee the **[Change Log](https://github.com/rabanti-github/yaca/blob/master/changelog.md)** for recent updates.\n\n## Installation\n\n```bash\nnpm install -S yaca\n```\n\n## List\u0026lt;T\u0026gt;\n\nA list stores values similar to an array. In comparison to an array, several functions like copies of a range, clearing or sorting can be applied out of the box. Additionally, operations for stacks and queues are included.\n\n### Supported functions\n\n* add\n* addRange\n* break (used in forEach)\n* clear\n* contains\n* continue (used in forEach)\n* dequeue\n* distinct\n* enqueue\n* forEach\n* get\n* getRange\n* indexOf\n* indicesOf\n* indicesOfAsList\n* insertAtIndices\n* lastIndexOf\n* next\n* peek\n* pop\n* remove\n* removeAll\n* removeAt\n* removeAtIndices\n* reverse\n* set\n* sort\n* swapValues\n\n### Usage\n\n```ts\nimport {List} from 'yaca';\n\n// Default constructor\nlet numberList: List\u003cnumber\u003e = new List\u003cnumber\u003e();\n\n// Constructor with initial value\nvar stringList: List\u003cstring\u003e = new List\u003cstring\u003e(\"initial value\");\n\n// Constructor with array as initial value\nlet booelanList: List\u003cboolean\u003e = new List\u003cboolean\u003e([true, false, true, true]);\n\n// Usage of more complex types\nvar otherList: List\u003cSomeType\u003e = new List\u003cSomeType\u003e();\n\nnumberList.add(22);\n\nnumberList.addRange([23,24,25]);\n\nnumberList.sort();\n\nnumberList.forEach(element =\u003e {\n            console.log(element);\n            if (element === 2)\n            {\n                numberList.continue(); // Optional / syntactic call to skip this iteration\n                return; // Mandatory! -\u003e sufficient as continue call\n            }\n            if (element === 4)\n            {\n                numberList.break(); // Breaks the forEach loop immediately\n                return; // Mandatory!\n            }\n\n        });\n\nnumberList.clear();\n```\n\nSee  [The List documentation page](https://rabanti-github.github.io/yaca/classes/_src_list_.list.html) for further details:\n\n* Constructors\n* Properties\n* Methods\n\n\n## Dictionary\u0026lt;K,V\u0026gt;\n\nA dictionary stores tuples of keys and an values. The type of both can be arbitrary. However, keys must be unique. Thus, a dictionary with boolean as keys allows only two tuples (true and false) in the Dictionary. If custom classes are used as keys, a valid toString function must be implemented in those classes or the function overrideHashFunction must be used in the Dictionary.\n\n### Supported functions\n\n* add\n* addRange\n* break (used in forEach)\n* clear\n* containsKey\n* containsKeys\n* containsValue\n* containsValues\n* continue (used in forEach)\n* distinct\n* forEach\n* get\n* getKeys\n* getKeysAsList\n* getKeysByValue\n* getKeysByValueAsList\n* getKeysByValues\n* getKeysByValuesAsList\n* getRange\n* getRageByValue\n* getValues\n* getValuesAsList\n* next\n* overrideHashFunction\n* remove\n* removeByValue\n* set\n* swapValues\n\n### Usage\n\n```ts\nimport {Dictionary} from 'yaca';\n\n// Default constructor\nlet dictionary: Dictionary\u003cnumber, string\u003e = new Dictionary\u003cnumber, string\u003e();\n\n// Constructor with initial value\nlet dictionary2: Dictionary\u003cnumber, string\u003e = new Dictionary\u003cnumber, string\u003e([1,2,3],[\"one\",\"two\",\"three\"]]);\n\n// Constructor with custom function to override the hashing of the keys (defaul is toString)\nlet dictionary3: Dictionary\u003cnumber, Date\u003e = new Dictionary\u003cnumber, Date\u003e(MyUtils.DateHashingFunction);\n\n// Usage of more complex types\nvar otherDictionary: Dictionary\u003cDate, SomeType\u003e = new Dictionary\u003cDate, SomeType\u003e();\n\ndictionary.add(22, \"twenty two\");\n\nlet value:string = dictionary2.get(2);\n\ndictionary2.forEach(item =\u003e {\n            console.log(\"key:\" + item.key + \" -\u003e value:\" + item.value);\n\n            if (item.value === \"two\")\n            {\n                dictionary2.continue(); // Optional / syntactic call to skip this iteration\n                return; // Mandatory! -\u003e sufficient as continue call\n            }\n            if (item.key === 3)\n            {\n                dictionary2.break(); // Breaks the forEach loop immediately\n                return; // Mandatory!\n            }\n\n        });\n\ndictionary3.clear();\n```\n\nSee  [The Dictionary documentation page](https://rabanti-github.github.io/yaca/classes/_src_dictionary_.dictionary.html) for further details:\n\n* Constructors\n* Properties\n* Methods\n\n## SortedDictionary\u0026lt;K,V\u0026gt;\n\nA sorted dictionary has the same behavior properties and functions like a standard dictionary. Additionally, there are many functions regarding the indices of the key value tuples and the possibility to sorting the dictionary by keys or values.\n\n### Supported functions\n\n\u003cb\u003eAll functions of Dictionary \u0026lt;K,V\u0026gt;\u003c/b\u003e\n\n* getByIndex\n* getByIndices\n* getByIndicesAsList\n* getKeyByIndex\n* getKeysByIndices\n* getKeysByIndicesAsList\n* removeByIndex\n* removeByIndices\n* setByIndex\n* setByIndices\n* sortByKey\n* sortByValue\n\n### Usage\n\n```ts\nimport {SortedDictionary} from 'yaca';\nimport {Comparer} from 'yaca';\n\n// Default constructor\nlet dictionary: SortedDictionary\u003cnumber, string\u003e = new SortedDictionary\u003cnumber, string\u003e();\n\n// Constructor with initial value\nlet dictionary2: Dictionary\u003cnumber, string\u003e = new Dictionary\u003cnumber, string\u003e([1,2,3],[\"one\",\"two\",\"three\"]]);\n\n// -\u003e All operation of the standard Dictionary\u003cK,V\u003e class possible\n\nlet value: string = dictionary2.getByIndex(1); // Returns \"two\" (key=2; index=1; value=\"two\")\n\ndictionary2.removeByIndex(2); // Removes the third element (key=3; index=2; value=\"three\")\n\ndictionary2.sortByKey(); // Sort the dictionary by its keys (using default behavior of number)\n\ndictionary2.sortByKey(Comparer.compareNumbers); // Sort the dictionary by its keys (using a comparison function)\n\ndictionary2.sortByValue(); // Sort the dictionary by its values (using default behavior of string)\n\n```\n\nSee  [The SortedDictionary documentation page](https://rabanti-github.github.io/yaca/classes/_src_sorteddictionary_.sorteddictionary.html) for further details:\n\n* Constructors\n* Properties\n* Methods","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabanti-github%2Fes6-yaca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frabanti-github%2Fes6-yaca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabanti-github%2Fes6-yaca/lists"}