OpenFn / OpenFn/docs

Javascript Tips: Add patterns for mapping and lookups

Open
#463 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
23
Forks
20
Avg merge
3d 1h
Merged PRs (30d)
6

Description

The JS Tip section could use a bit about mapping and lookup patterns.

For mapping, I'd like to show example usage of array map and reduce, with short simple examples.

For lookups (dictionaries), I'd like to show a lookup pattern to map static values, functions or templates.

This is basically nonsense pseudocode but this is the sort of thing I want to show:

const map = {
   'static-key:' 'some-other-value',
   'dynamic-key': (v) => v.toUpperCase()
}

const mapped = patients.map((patient) => {
  const p = {};
  for (key of patient) {
   const mappedKey = map[key].(key)   ?? key;
   p[mappedKey] = map[patient[key]] ?? patient[key]
  }
 return p;
});

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the JS Tip section at documentation/jobs/javascript and review its existing examples and style. Add short array map and reduce examples plus lookup examples for static values, functions, and templates; it is done when all requested mapping and lookup patterns are clearly documented there.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.