{"id":15537539,"url":"https://github.com/nullvoxpopuli/ember-array-map-resource","last_synced_at":"2025-04-23T15:23:17.305Z","repository":{"id":38173246,"uuid":"389122503","full_name":"NullVoxPopuli/ember-array-map-resource","owner":"NullVoxPopuli","description":"Array.prototype.map, but as a Resource that prevents unneeded memory thrashing","archived":false,"fork":false,"pushed_at":"2023-03-04T15:05:44.000Z","size":13213,"stargazers_count":4,"open_issues_count":23,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T22:23:47.552Z","etag":null,"topics":["ember","ember-addon","emberjs","hacktoberfest","resources"],"latest_commit_sha":null,"homepage":"https://ember-array-map-resource.pages.dev/","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/NullVoxPopuli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-24T14:46:29.000Z","updated_at":"2022-01-11T00:06:29.000Z","dependencies_parsed_at":"2023-02-18T13:05:38.844Z","dependency_job_id":"865f0d09-1c47-4b75-aa45-749437fb5bcd","html_url":"https://github.com/NullVoxPopuli/ember-array-map-resource","commit_stats":{"total_commits":314,"total_committers":4,"mean_commits":78.5,"dds":"0.11783439490445857","last_synced_commit":"02dca75840528d8ea0aa849141532daab4fcb4c6"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fember-array-map-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fember-array-map-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fember-array-map-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fember-array-map-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NullVoxPopuli","download_url":"https://codeload.github.com/NullVoxPopuli/ember-array-map-resource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250458092,"owners_count":21433796,"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":["ember","ember-addon","emberjs","hacktoberfest","resources"],"created_at":"2024-10-02T11:57:54.771Z","updated_at":"2025-04-23T15:23:17.257Z","avatar_url":"https://github.com/NullVoxPopuli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-array-map-resource\n\n## DEPRECATED / NO LONGER MAINTAINED\n\nThis library has been absorbed into `ember-resources`, here: \nhttps://ember-resources.pages.dev/modules/util_map\n\n-----------------------------------\n\n[![npm version](https://badge.fury.io/js/ember-array-map-resource.svg)](https://badge.fury.io/js/ember-array-map-resource)\n[![CI](https://github.com/NullVoxPopuli/ember-array-map-resource/actions/workflows/ci.yml/badge.svg?branch=main\u0026event=push)](https://github.com/NullVoxPopuli/ember-array-map-resource/actions/workflows/ci.yml)\n\nThis addon provides a `useArrayMap` function which returns a resource that\nreactively maps data per-element, so that when the overall collection is dirtied,\nonly the changed/new/removed elements affect the mapped collection.\n\nThis technique requires that your elements be mapped to be object-like so that iteration\ncan rely on object identity to optimize loop iteration.\n\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Public Types](#public-types)\n- [Contributing](#contributing)\n- [Thanks](#thanks)\n\n## Compatibility\n\n* Ember.js v3.25+\n* TypeScript v4.2+\n\n## Installation\n\n```bash\nnpm install ember-array-map-resource\n# or\nyarn add ember-array-map-resource\n# or\nember install ember-array-map-resource\n```\n\n## Usage\n\nThis is most useful for library authors that may not have control of _how_ an array of items\nis updated. It's common in modern JS to replace entire arrays when adding/removing/changing\nitems in arrays -- `useArrayMap` provides a technique to re-optimize how updates within your\nlibrary are handled. Folks can replace an entire array, and _as long as object-identity is\nmaintained_.\n\n```js\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { useArrayMap } from 'ember-array-map-resource';\n\nexport default class MyComponent extends Component {\n  @tracked records = [];\n\n  mappedRecords = useArrayMap(this, {\n    data: () =\u003e this.records,\n    map: (record) =\u003e someTransform(record)\n  });\n\n  @action someTransform(record) {\n    return /* ... ✂️  ... */\n  }\n}\n```\n```hbs\n{{!-- even if this.records is re-set entirely, mappedRecords will optimize iteration --}}\n{{#each this.mappedRecords as |mappedRecord|}}\n  ...\n  {{!--\n    within the each body, code will only be executed once for each\n    - new record\n    - replaced record\n  --}}\n{{/each}}\n```\n\nNOTE: `each` performance is handled by ember, and tweaks to its behavior can be tweaked.\nSEE: https://guides.emberjs.com/release/components/looping-through-lists/\n\nNOTE: `useArrayMap` will have (very slightly) higher initial rendering time.\nIt's not meant to be faster than properly managed vanilla arrays.\n`useArrayMap`'s purpose is for making it harder for users to de-optimize their iteration.\n\nThe above example could be achieved with inline-helpers and without a resource via:\n\n```js\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\n\nexport default class MyComponent extends Component {\n  @tracked records = [];\n\n  @action someTransform(record) {\n    return /* ... ✂️  ... */\n  }\n}\n```\n```hbs\n{{!-- even if this.records is re-set entirely, mappedRecords will optimize iteration --}}\n{{#each this.records as |record|}}\n  {{#let (this.someTransform record) as |mappedRecord|}}\n    {{!-- expect same loop optimizations as above --}}\n  {{/let}}\n{{/each}}\n```\n\nSo, why would you want to use a resource if you can acheive the same with a `let`?\nAs a library author, you may be transforming data that you yourself don't have a say in\nhow it gets rendered.  For example, if your component template were `{{yield this.records}}`,\nthe user would be required to both transform and optimize their loop.\nHowever, with `useArrayMap` and `{{yield this.mappedRecords}}`, the user can be naïve about\nthe implementation details of the list, and still get performance benefits.\n\nThis could be helpful with\n - headless list implementations, where the user provides the entirety of the UI.\n - javascript-only map-loop optimizations\n\n## Public Types\n\n- `ArrayMap\u003cElement extends object, MapTo\u003e` - the return type from `useArrayMap`\n  - iterable\n  - array-index access\n\n## Contributing\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n\n\n## Thanks\n\nThis library wouldn't be possible without the work of:\n - [@pzuraq](https://github.com/pzuraq)\n - [@josemarluedke](https://github.com/josemarluedke)\n\nSo much appreciate for the work both you have put in to Resources \u003c3\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullvoxpopuli%2Fember-array-map-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullvoxpopuli%2Fember-array-map-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullvoxpopuli%2Fember-array-map-resource/lists"}