{"id":22361347,"url":"https://github.com/kei-k23/x-queryjs","last_synced_at":"2026-05-09T06:37:01.164Z","repository":{"id":249027703,"uuid":"830454811","full_name":"Kei-K23/x-queryjs","owner":"Kei-K23","description":"x-queryjs is utility library for querying collections","archived":false,"fork":false,"pushed_at":"2024-07-19T11:26:56.000Z","size":245,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T07:05:16.311Z","etag":null,"topics":["javascript","library","tsdx","typescript"],"latest_commit_sha":null,"homepage":"","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/Kei-K23.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-18T09:57:48.000Z","updated_at":"2024-09-18T01:06:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"02efec74-d785-4742-ac4a-39f13449a91c","html_url":"https://github.com/Kei-K23/x-queryjs","commit_stats":null,"previous_names":["kei-k23/x-queryjs"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Kei-K23/x-queryjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kei-K23%2Fx-queryjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kei-K23%2Fx-queryjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kei-K23%2Fx-queryjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kei-K23%2Fx-queryjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kei-K23","download_url":"https://codeload.github.com/Kei-K23/x-queryjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kei-K23%2Fx-queryjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32810048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["javascript","library","tsdx","typescript"],"created_at":"2024-12-04T16:29:20.571Z","updated_at":"2026-05-09T06:37:01.142Z","avatar_url":"https://github.com/Kei-K23.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# X-Queryjs\n\n`X-Queryjs` is small utility `JavaScript` library that is fully type safety, zero-dependencies and mimics the functionality and chaining capabilities of C# LINQ, allowing you to work with collections in a similar and more effective way.\n\n## Installation\n\nnpm\n\n```js\nnpm install x-queryjs\n```\n\npnpm\n\n```js\npnpm add x-queryjs\n```\n\n## Usage\n\nHere is a step-by-step guide on how to use the Queryable class.\n\n### Creating a Queryable Collection\n\nYou can create a new Queryable collection by passing an array of items to the constructor.\n\n```typescript\nimport { Queryable } from 'x-queryjs';\n\nconst numbers = new Queryable([1, 2, 3, 4, 5]);\nconst people = new Queryable([\n  { name: 'Alice', age: 30 },\n  { name: 'Bob', age: 25 },\n  { name: 'Charlie', age: 35 },\n]);\n```\n\n### Methods\n\n#### select\n\nProjects each element of a collection into a new form.\n\n```typescript\nconst names = people.select((person) =\u003e person.name);\nconsole.log(names.toArray()); // Output: ['Alice', 'Bob', 'Charlie']\n```\n\n#### where\n\nFilters a collection based on a predicate.\n\n```typescript\nconst adults = people.where((person) =\u003e person.age \u003e= 30);\nconsole.log(adults.toArray()); // Output: [{ name: 'Alice', age: 30 }, { name: 'Charlie', age: 35 }]\n```\n\n#### orderBy\n\nSorts the elements of a collection in ascending order according to a key.\n\n```typescript\nconst sortedByName = people.orderBy((person) =\u003e person.name);\nconsole.log(sortedByName.toArray()); // Output: [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }]\n```\n\n#### orderByDescending\n\nSorts the elements of a collection in descending order according to a key.\n\n```typescript\nconst sortedByAgeDesc = people.orderByDescending((person) =\u003e person.age);\nconsole.log(sortedByAgeDesc.toArray()); // Output: [{ name: 'Charlie', age: 35 }, { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }]\n```\n\n#### groupBy\n\nGroups the elements of a collection according to a specified key selector function.\n\n```typescript\nconst groupedByAge = people.groupBy((person) =\u003e person.age);\nconsole.log(groupedByAge);\n// Output:\n// {\n// 25: [{ name: 'Bob', age: 25 }],\n// 30: [{ name: 'Alice', age: 30 }],\n// 35: [{ name: 'Charlie', age: 35 }]\n// }\n```\n\n#### distinct\n\nReturns distinct elements from a collection according to a specified key selector function.\n\n```typescript\nconst distinctAges = people.distinct((person) =\u003e person.age);\nconsole.log(distinctAges.toArray()); // Output: [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }]\n```\n\n#### take\n\nReturns a specified number of contiguous elements from the start of a collection.\n\n```typescript\nconst firstTwo = people.take(2);\nconsole.log(firstTwo.toArray()); // Output: [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }]\n```\n\n#### skip\n\nBypasses a specified number of elements in a collection and then returns the remaining elements.\n\n```typescript\nconst skippedTwo = people.skip(2);\nconsole.log(skippedTwo.toArray()); // Output: [{ name: 'Charlie', age: 35 }]\n```\n\n#### toArray\n\nConverts the collection to an array.\n\n```typescript\nconst array = people.toArray();\nconsole.log(array); // Output: [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }]\n```\n\n#### sum\n\nComputes the sum of the sequence of numeric values that are obtained by invoking a transform function on each element of the input collection.\n\n```typescript\nconst totalAge = people.sum((person) =\u003e person.age);\nconsole.log(totalAge); // Output: 90\n```\n\n#### average\n\nComputes the average of the sequence of numeric values that are obtained by invoking a transform function on each element of the input collection.\n\n```typescript\nconst averageAge = people.average((person) =\u003e person.age);\nconsole.log(averageAge); // Output: 30\n```\n\n#### any\n\nDetermines whether any element of a collection satisfies a condition.\n\n```typescript\nconst hasAdults = people.any((person) =\u003e person.age \u003e= 18);\nconsole.log(hasAdults); // Output: true\n```\n\n#### all\n\nDetermines whether all elements of a collection satisfy a condition.\n\n```typescript\nconst allAdults = people.all((person) =\u003e person.age \u003e= 18);\nconsole.log(allAdults); // Output: true\n```\n\n#### first\n\nReturns the first element of a sequence that satisfies a specified condition or the first element if no condition is specified.\n\n```typescript\nconst firstAdult = people.first((person) =\u003e person.age \u003e= 30);\nconsole.log(firstAdult); // Output: { name: 'Alice', age: 30 }\n```\n\n#### firstOrDefault\n\nReturns the first element of a sequence that satisfies a specified condition or the first element if no condition is specified, or a default value if no such element is found.\n\n```typescript\nconst firstYoungAdult = people.firstOrDefault((person) =\u003e person.age \u003e= 20, {\n  name: 'Default',\n  age: 0,\n});\nconsole.log(firstYoungAdult); // Output: { name: 'Alice', age: 30 }\n```\n\n#### last\n\nReturns the last element of a sequence that satisfies a specified condition or the last element if no condition is specified.\n\n```typescript\nconst lastAdult = people.last((person) =\u003e person.age \u003e= 30);\nconsole.log(lastAdult); // Output: { name: 'Charlie', age: 35 }\n```\n\n#### lastOrDefault\n\nReturns the last element of a sequence that satisfies a specified condition or the last element if no condition is specified, or a default value if no such element is found.\n\n```typescript\nconst lastYoungAdult = people.lastOrDefault((person) =\u003e person.age \u003e= 20, {\n  name: 'Default',\n  age: 0,\n});\nconsole.log(lastYoungAdult); // Output: { name: 'Charlie', age: 35 }\n```\n\n## Contributors\n\nAll contributors are welcome. Please create a pull request or issue.\n\n## TODO\n\n- [ ] Implement other queryable class for other data type like JSON and so on.\n- [ ] Write thorough unit tests for every methods.\n- [ ] Improve performance without using any other dependencies\n- [ ] Write clear and self explanatory documentation\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkei-k23%2Fx-queryjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkei-k23%2Fx-queryjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkei-k23%2Fx-queryjs/lists"}