{"id":20618595,"url":"https://github.com/allanchain/jau","last_synced_at":"2026-06-04T19:31:44.595Z","repository":{"id":57144202,"uuid":"256762804","full_name":"AllanChain/jau","owner":"AllanChain","description":"Just Anothor Unique array of objects","archived":false,"fork":false,"pushed_at":"2020-04-22T01:33:35.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T06:45:54.937Z","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/AllanChain.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}},"created_at":"2020-04-18T13:38:56.000Z","updated_at":"2020-04-24T01:25:30.000Z","dependencies_parsed_at":"2022-09-05T12:31:27.992Z","dependency_job_id":null,"html_url":"https://github.com/AllanChain/jau","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanChain%2Fjau","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanChain%2Fjau/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanChain%2Fjau/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanChain%2Fjau/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AllanChain","download_url":"https://codeload.github.com/AllanChain/jau/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242277657,"owners_count":20101536,"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-16T12:08:58.749Z","updated_at":"2025-03-06T19:44:21.075Z","avatar_url":"https://github.com/AllanChain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jau\n\nJust Anothor Unique array of objects.\n\n## `jau.unique`\n\njau can get unique objects by key(s) or a function. The first \"unique object\" is returned.\n\n```js\nconst jau = require('jau')\n\n// no param, simple equal will be used\n\njau.unique([1, 2, 2, 3, 1, 2, 4])\n// [1, 2, 3, 4]\njau.unique(['a', 'a', 'b', 'a', 'c', 'a', 'd']\n// ['a', 'b', 'c', 'd']\n\n// with property name\n\njau.unique([{a: 1}, {a: 1, b: 2}, {b: 2}], 'a')\n// [{a: 1}, {b: 2}]\njau.unique([{a: 1}, {a: 1, b: 2}, {b: 2}], 'b')\n// [{a: 1}, {a: 1, b: 2}]\n\n// with properties\n\njau.unique([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}], ['a', 'b'])\n// [{a: 1, b: 2, c: 1}, {b: 2}]\n\n// with function\n\njau.unique([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}], \n  (a, b) =\u003e a.a === b.a || a.b === b.b)\n// [{a: 1, b: 2, c: 1}]\n```\n\n## `jau.group`\n\nSometimes you may need to get the last \"unique object\", or perform some merge operation. `jau.group` gives you control over this.\n\nSimilarly:\n\n```js\n// group: no param\njau.group([1, 2, 2, 3, 1, 2, 4]),\n// [[1, 1], [2, 2, 2], [3], [4]]\n\n// group: with property name\njau.group([{a: 1}, {a: 1, b: 2}, {b: 2}], 'a'),\n// [[{a: 1}, {a: 1, b: 2}], [{b: 2}]]\n\n// group: with properties\njau.group([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}], ['a', 'b']),\n// [[{a: 1, b: 2, c: 1}, {a: 1, b: 2}], [{b: 2}]]\n\n// group: with function\njau.group([{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}],\n  (a, b) =\u003e a.a === b.a || a.b === b.b)\n// [[{a: 1, b: 2, c: 1}, {a: 1, b: 2}, {b: 2}]]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallanchain%2Fjau","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallanchain%2Fjau","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallanchain%2Fjau/lists"}