{"id":16252993,"url":"https://github.com/neki-dev/arrays-otherness","last_synced_at":"2025-03-19T20:31:45.461Z","repository":{"id":56953767,"uuid":"453521261","full_name":"neki-dev/arrays-otherness","owner":"neki-dev","description":"🧩 Handle matching, missing and excess items of an array based on target array","archived":false,"fork":false,"pushed_at":"2024-08-04T22:24:55.000Z","size":440,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T10:52:10.044Z","etag":null,"topics":["arrays","compare","difference"],"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/neki-dev.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":"2022-01-29T21:19:52.000Z","updated_at":"2024-08-25T22:34:34.000Z","dependencies_parsed_at":"2024-10-27T21:32:03.184Z","dependency_job_id":"b5296ce7-3165-4f29-a603-a956e0eca11e","html_url":"https://github.com/neki-dev/arrays-otherness","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":"0.10810810810810811","last_synced_commit":"1ff9a6931fad5c022bb265270e7d7bd82305b15d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Farrays-otherness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Farrays-otherness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Farrays-otherness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Farrays-otherness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neki-dev","download_url":"https://codeload.github.com/neki-dev/arrays-otherness/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501436,"owners_count":20462860,"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":["arrays","compare","difference"],"created_at":"2024-10-10T15:15:37.764Z","updated_at":"2025-03-19T20:31:41.162Z","avatar_url":"https://github.com/neki-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ⚡ Arrays otherness\n[![Version](https://badgen.net/npm/v/arrays-otherness)](https://npmjs.com/package/arrays-otherness)\n[![Small size](https://img.badgesize.io/neki-dev/arrays-otherness/master/dist/index.js)](https://github.com/neki-dev/arrays-otherness/blob/master/dist/index.js)\n[![Testing](https://github.com/neki-dev/arrays-otherness/actions/workflows/test.yml/badge.svg)](https://github.com/neki-dev/arrays-otherness/actions/workflows/test.yml)\n[![Building](https://github.com/neki-dev/arrays-otherness/actions/workflows/build.yml/badge.svg)](https://github.com/neki-dev/arrays-otherness/actions/workflows/build.yml)\n\nGet and handle a matching, missing and excess items of an array based on target array\n\n.\n\n* ### Install\n\n```sh\nnpm i arrays-otherness\n```\n\n* ### Usage\n\n```js\narraysOtherness\u003cT\u003e(\n    // Array for checking\n    originArray: T[], \n    // Etalon array\n    targetArray: T[], \n    // Function of matching arrays items\n    matchFn: (res) =\u003e boolean\n): {\n    // Execute callback if items in two arrays\n    match: (callback: (res) =\u003e void) =\u003e this,\n    // Execute callback if target item missing in origin array\n    missing: (callback: (res) =\u003e void) =\u003e this,\n    // Execute callback if origin item is excess in target array\n    excess: (callback: (res) =\u003e void) =\u003e this,\n}\n```\n\n* ### Example\n\n```js\nconst arraysOtherness = require('arrays-otherness');\n\nconst originArray = [\n    { id: 1, name: 'John' },\n    { id: 2, name: 'Sam' },\n    { id: 3, name: 'Nick' },\n];\n\nconst targetArray = [\n    { id: 1, name: 'Jonny' },\n    { id: 3, name: 'Nick' },\n    { id: 4, name: 'Lisa' },\n    { id: 5, name: 'Frank' },\n];\n\narraysOtherness(originArray, targetArray, ({ origin, target }) =\u003e (origin.id === target.id))\n    .match(({ target, origin }) =\u003e {\n        console.log('matched =', target, 'and', origin);\n        \n        // matched = { id: 1, name: 'John' } and { id: 1, name: 'Jonny' }\n        // matched = { id: 3, name: 'Nick' } and { id: 3, name: 'Nick' }\n    })\n    .missing(({ target }) =\u003e {\n        console.log('to create =', target);\n\n        // to create = { id: 4, name: 'Lisa' }\n        // to create = { id: 5, name: 'Frank' }\n    })\n    .excess(({ origin }) =\u003e {\n        console.log('to remove =', origin);\n\n        // to remove = { id: 2, name: 'Sam' }\n    });\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Farrays-otherness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneki-dev%2Farrays-otherness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Farrays-otherness/lists"}