{"id":18799579,"url":"https://github.com/l2silver/reorder-ordinals","last_synced_at":"2025-06-22T23:07:22.381Z","repository":{"id":97820189,"uuid":"280263659","full_name":"l2silver/reorder-ordinals","owner":"l2silver","description":"simple js library for reordering a list of objects with an ordinal property","archived":false,"fork":false,"pushed_at":"2020-09-12T20:31:04.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-22T23:07:15.441Z","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/l2silver.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":"2020-07-16T21:36:44.000Z","updated_at":"2020-09-12T20:31:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"34149bf8-ba1d-42a1-9abc-e2e3ef67970a","html_url":"https://github.com/l2silver/reorder-ordinals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/l2silver/reorder-ordinals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Freorder-ordinals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Freorder-ordinals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Freorder-ordinals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Freorder-ordinals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/l2silver","download_url":"https://codeload.github.com/l2silver/reorder-ordinals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Freorder-ordinals/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261380910,"owners_count":23149966,"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-07T22:15:47.701Z","updated_at":"2025-06-22T23:07:17.364Z","avatar_url":"https://github.com/l2silver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reorder Ordinals\n\nA simple library to change the ordinal property of objects in an array.\n\n## Getting started\n````\nnpm i reorder-ordinals\n````\n\n## Example Usecase\n\n````\nconst reorderOrdinalsGenerator = require('reorder-ordinals'); //(options?: Object)=\u003eFunc\nconst reorderOrdinals = reorderOrdinalsGenerator(); //(arr: [{ordinal: Int}, ...], startingOrdinal: Int, endingOrdinal: Int);\n\nlet result, expected, i1, i2, i3, items;\ni1 = {\n  id: 1,\n  ordinal: 0\n}\n\ni2 = {\n  id: 2,\n  ordinal: 2\n}\n\ni3 = {\n  id: 3,\n  ordinal: 1\n};\n\nitems = [\n  i1, i2, i3\n];\n\nresult = reorderOrdinals(items, 1, 0)\nexpected = [{...i1, ordinal: 1}, i2, {...i3, ordinal: 0}];\nassert.deepEqual(result, expected);\n````\n## Options\n\n````\nreorderOrdinalsGenerator(options=\n{\n  simple: true // takes an array and treats elements index as ordinal\n  getOrdinal: (ele)=\u003eInt // func to return the ordinal of an element in the array\n  updateOrdinal: (ele, nextVal) =\u003e ele (updated) // func that updates the ordinal of an element\n}\n\n);\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Freorder-ordinals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl2silver%2Freorder-ordinals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Freorder-ordinals/lists"}