Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add castMapping function #43

Merged
merged 8 commits into from
Jul 13, 2024
Merged

feat: add castMapping function #43

merged 8 commits into from
Jul 13, 2024

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jun 28, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

This will be used by #36 to provide similar functionality in the min and max Radashi functions.

The castMapping function is primarily intended for use by other utility functions that would like to support a multitude of possible (and potentially optional) mapping strategies.

// The created “mapping function” always takes a single argument.
const getFooProperty = castMapping('foo')
const getHalved = castMapping((arg: number) => arg / 2)

getFooProperty({ foo: 1 }) // => 1
getHalved(200) // => 100

What kind of change does this PR introduce?

Feature

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size
A src/casted/castMapping.ts 116

@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Jun 28, 2024
@aleclarson aleclarson force-pushed the main branch 4 times, most recently from 35fc67a to 04bad7b Compare July 1, 2024 19:17
@aleclarson aleclarson changed the title feat: add getter function feat: add castMapping function Jul 13, 2024
@aleclarson aleclarson merged commit 27382bb into main Jul 13, 2024
4 checks passed
@aleclarson aleclarson deleted the feat/getter-fn branch July 13, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This PR adds a new function or extends an existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant