Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Transformer: Map initialization patterns to getOrInsert APIs

Open
#143 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
tooling

Research direction

Start by inspecting the existing transformers in src/newlyAvailable/ and how they are exported from src/newlyAvailable.js. Add tests in tests/newlyAvailable/ covering the shown get-or-init patterns and unsafe side-effect cases, then document the transformer in README.md. Done means the safe patterns upgrade while side-effect behavior is preserved.

Written by the indexing model from the issue text.

Description

newly available

Summary

Add a transformer that upgrades common Map get-or-init patterns to getOrInsert/getOrInsertComputed.

Examples

// before
if (!cache.has(key)) {
  cache.set(key, []);
}
const value = cache.get(key);

// after
const value = cache.getOrInsert(key, []);
// before
if (!cache.has(key)) {
  cache.set(key, buildValue());
}
const value = cache.get(key);

// after
const value = cache.getOrInsertComputed(key, buildValue);

Scope

  • Baseline category: newly available.
  • Preserve side-effect behavior; skip unsafe cases.

Acceptance criteria

  • Implement in src/newlyAvailable/
  • Export from src/newlyAvailable.js
  • Add tests in tests/newlyAvailable/
  • Document in README.md
Dominant language
JavaScript
Stars
15
Forks
2
Avg merge
2h 9m
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from codingjoe/esupgrade

All issues in codingjoe/esupgrade

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.