{"id":13452034,"url":"https://github.com/reachifyio/dataloader-sort","last_synced_at":"2025-03-23T19:33:29.325Z","repository":{"id":177537665,"uuid":"87107472","full_name":"reachifyio/dataloader-sort","owner":"reachifyio","description":"Sort function for DataLoader to ensure the correct data is returned for the matching keys","archived":false,"fork":false,"pushed_at":"2019-03-20T20:57:13.000Z","size":30,"stargazers_count":25,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T18:56:12.730Z","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/reachifyio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-03T18:33:32.000Z","updated_at":"2022-10-30T18:55:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"593131fa-c47d-42e7-8a48-ab4a3deb81a7","html_url":"https://github.com/reachifyio/dataloader-sort","commit_stats":null,"previous_names":["reachifyio/dataloader-sort"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachifyio%2Fdataloader-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachifyio%2Fdataloader-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachifyio%2Fdataloader-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachifyio%2Fdataloader-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reachifyio","download_url":"https://codeload.github.com/reachifyio/dataloader-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245158923,"owners_count":20570287,"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-07-31T07:01:10.792Z","updated_at":"2025-03-23T19:33:28.974Z","avatar_url":"https://github.com/reachifyio.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# DataLoader Sort\nSort function for DataLoader to ensure the correct data is returned for the matching keys\n\n[![npm version](https://badge.fury.io/js/dataloader-sort.svg)](https://badge.fury.io/js/dataloader-sort) [![Build Status](https://travis-ci.org/reachifyio/dataloader-sort.svg?branch=master)](https://travis-ci.org/reachifyio/dataloader-sort) [![Coverage Status](https://coveralls.io/repos/github/reachifyio/dataloader-sort/badge.svg?branch=master)](https://coveralls.io/github/reachifyio/dataloader-sort?branch=master)\n\n## Installation\n`npm i -S dataloader-sort`\n\n## Notes\n* If no match is found it will return `null` for this key\n* Includes Flow types\n\n## Usage\n### Basic Usage\n```\nimport sort from 'dataloader-sort';\n\nconst keys = [1, 2, 3];\nconst data = [\n  { id: 3, value: 'three' },\n  { id: 1, value: 'one' },\n  { id: 4, value: 'four' },\n];\n\nconst result = sort(keys, data);\n```\n\n##### Output\n```\n[\n  { id: 1, value: 'one' },\n  null,\n  { id: 3, value: 'three' },\n]\n```\n\n### Custom Prop Usage\n```\nconst keys = [1, 2, 3];\nconst data = [\n  { other: 3, value: 'three' },\n  { other: 1, value: 'one' },\n  { other: 2, value: 'two' },\n];\n\nconst result = sort(keys, data, 'other');\n```\n\n##### Output\n```\n[\n  { other: 1, value: 'one' },\n  { other: 2, value: 'two' },\n  { other: 3, value: 'three' },\n]\n```\n\n### Object Keys Usage\n```\nconst keys = [\n  { userId: 1, messageId: 3 },\n  { userId: 2, messageId: 4 },\n  { userId: 3, messageId: 9 },\n  { userId: 3, messageId: 7 },\n  { userId: 1, messageId: 2 },\n];\nconst data = [\n  { userId: 1, messageId: 2, value: 'yayy' },\n  { userId: 3, messageId: 7, value: 'ya' },\n  { userId: 1, messageId: 3, value: 'woot' },\n  { userId: 2, messageId: 4, value: 'blue' },\n  { userId: 3, messageId: 9, value: 'green' },\n];\n\nconst result = sort(keys, data);\n```\n\n##### Output\n```\n[\n  { userId: 1, messageId: 3, value: 'woot' },\n  { userId: 2, messageId: 4, value: 'blue' },\n  { userId: 3, messageId: 9, value: 'green' },\n  { userId: 3, messageId: 7, value: 'ya' },\n  { userId: 1, messageId: 2, value: 'yayy' },\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freachifyio%2Fdataloader-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freachifyio%2Fdataloader-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freachifyio%2Fdataloader-sort/lists"}