npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ember-array-map-resource

v3.0.2

Published

An implementation of Resources with some helpful utilities

Readme

ember-array-map-resource

npm version CI

This addon provides a useArrayMap function which returns a resource that reactively maps data per-element, so that when the overall collection is dirtied, only the changed/new/removed elements affect the mapped collection.

This technique requires that your elements be mapped to be object-like so that iteration can rely on object identity to optimize loop iteration.

Compatibility

  • Ember.js v3.25+
  • TypeScript v4.2+

Installation

npm install ember-array-map-resource
# or
yarn add ember-array-map-resource
# or
ember install ember-array-map-resource

Usage

This is most useful for library authors that may not have control of how an array of items is updated. It's common in modern JS to replace entire arrays when adding/removing/changing items in arrays -- useArrayMap provides a technique to re-optimize how updates within your library are handled. Folks can replace an entire array, and as long as object-identity is maintained.

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { useArrayMap } from 'ember-array-map-resource';

export default class MyComponent extends Component {
  @tracked records = [];

  mappedRecords = useArrayMap(this, {
    data: () => this.records,
    map: (record) => someTransform(record)
  });

  @action someTransform(record) {
    return /* ... ✂️  ... */
  }
}
{{!-- even if this.records is re-set entirely, mappedRecords will optimize iteration --}}
{{#each this.mappedRecords as |mappedRecord|}}
  ...
  {{!--
    within the each body, code will only be executed once for each
    - new record
    - replaced record
  --}}
{{/each}}

NOTE: each performance is handled by ember, and tweaks to its behavior can be tweaked. SEE: https://guides.emberjs.com/release/components/looping-through-lists/

NOTE: useArrayMap will have (very slightly) higher initial rendering time. It's not meant to be faster than properly managed vanilla arrays. useArrayMap's purpose is for making it harder for users to de-optimize their iteration.

The above example could be achieved with inline-helpers and without a resource via:

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

export default class MyComponent extends Component {
  @tracked records = [];

  @action someTransform(record) {
    return /* ... ✂️  ... */
  }
}
{{!-- even if this.records is re-set entirely, mappedRecords will optimize iteration --}}
{{#each this.records as |record|}}
  {{#let (this.someTransform record) as |mappedRecord|}}
    {{!-- expect same loop optimizations as above --}}
  {{/let}}
{{/each}}

So, why would you want to use a resource if you can acheive the same with a let? As a library author, you may be transforming data that you yourself don't have a say in how it gets rendered. For example, if your component template were {{yield this.records}}, the user would be required to both transform and optimize their loop. However, with useArrayMap and {{yield this.mappedRecords}}, the user can be naïve about the implementation details of the list, and still get performance benefits.

This could be helpful with

  • headless list implementations, where the user provides the entirety of the UI.
  • javascript-only map-loop optimizations

Public Types

  • ArrayMap<Element extends object, MapTo> - the return type from useArrayMap
    • iterable
    • array-index access

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Thanks

This library wouldn't be possible without the work of:

So much appreciate for the work both you have put in to Resources <3