1
0
Fork 0
freesewing/sites/dev/docs/reference/api/utils/mergeoptions/readme.mdx
Joost De Cock ab3204f9f1 chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus
setup. It's part of my efforts to simplify FreeSewing's setup so we can
focus on our core value proposition.
2024-09-28 13:13:48 +02:00

30 lines
950 B
Text

---
title: utils.mergeOptions()
---
The `utils.mergeOptions()` function merges the user-provided options with the
options from the pattern configuration.
## Signature
```js
Object utils.mergeOptions(
Object settings,
Object optionsConfig
)
```
## Notes
Typically the only options that are passed as part of settings to the pattern
are those that differ from the defaults. This means that if you want to check
an option outside a draft method, you need to check whether the option is set,
and if it's not get the default value from the pattern config. Furthermore,
where the default is stored and whether or not it should be further transformed
depends on the option type.
This function exists to facilitate this. You pass it the user-provided settings,
and the pattern config options key, and it will return an object where all
options are populated with the user-provided values, or their defaults if the
user did not provide any input.