feat(markdown): Docs for utils.mergeOptions()
This commit is contained in:
parent
631ea8a50d
commit
a532a6e010
3 changed files with 36 additions and 1 deletions
|
@ -74,6 +74,7 @@ The following named exports are **utility methods**:
|
||||||
| `lineIntersectsCircle` | See the [lineIntersectsCircle](/reference/api/utils/lineintersectscircle) documentation |
|
| `lineIntersectsCircle` | See the [lineIntersectsCircle](/reference/api/utils/lineintersectscircle) documentation |
|
||||||
| `lineIntersectsCurve` | See the [lineIntersectsCurve](/reference/api/utils/lineintersectscurve) documentation |
|
| `lineIntersectsCurve` | See the [lineIntersectsCurve](/reference/api/utils/lineintersectscurve) documentation |
|
||||||
| `linesIntersect` | See the [linesIntersect](/reference/api/utils/linesintersect) documentation |
|
| `linesIntersect` | See the [linesIntersect](/reference/api/utils/linesintersect) documentation |
|
||||||
|
| `mergeOptions` | See the [mergeOptions](/reference/api/utils/mergeoptions) documentation |
|
||||||
| `pctBasedOn` | See the [pctBasedOn](/reference/api/utils/pctbasedon) documentation |
|
| `pctBasedOn` | See the [pctBasedOn](/reference/api/utils/pctbasedon) documentation |
|
||||||
| `pointOnBeam` | See the [pointOnBeam](/reference/api/utils/pointonbeam) documentation |
|
| `pointOnBeam` | See the [pointOnBeam](/reference/api/utils/pointonbeam) documentation |
|
||||||
| `pointOnCurve` | See the [pointOnCurve](/reference/api/utils/pointoncurve) documentation |
|
| `pointOnCurve` | See the [pointOnCurve](/reference/api/utils/pointoncurve) documentation |
|
||||||
|
|
|
@ -17,16 +17,23 @@ The `toAbs` property should hold a function with the following
|
||||||
signature:
|
signature:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function toAbs(percentage, settings) {
|
function toAbs(percentage, settings, mergeOptions) {
|
||||||
// return value in millimeter here
|
// return value in millimeter here
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The first parameter is the percentage value provided by the user (for example
|
The first parameter is the percentage value provided by the user (for example
|
||||||
`0.5` for `50%`).
|
`0.5` for `50%`).
|
||||||
|
|
||||||
The second parameter holds the pattern's [settings](/reference/settings) object
|
The second parameter holds the pattern's [settings](/reference/settings) object
|
||||||
which holds -- among other things -- the measurements provided by the user.
|
which holds -- among other things -- the measurements provided by the user.
|
||||||
|
|
||||||
|
The third parameter should be the return value of
|
||||||
|
[utils.mergeOptions()](/reference/api/utils/mergeoptions), which provides an
|
||||||
|
object with all option values populated. Although this parameter is not
|
||||||
|
required for simple values based on measurements, it is often required when the
|
||||||
|
result depends on several options.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
In our example above, let's say that the `chestEase` option is
|
In our example above, let's say that the `chestEase` option is
|
||||||
|
|
27
markdown/dev/reference/api/utils/mergeoptions/en.md
Normal file
27
markdown/dev/reference/api/utils/mergeoptions/en.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
title: utils.mergeOptions()
|
||||||
|
---
|
||||||
|
|
||||||
|
The `utils.mergeOptions()` function merges the user-provided options with the
|
||||||
|
options from the pattern configuration.
|
||||||
|
|
||||||
|
## Signature
|
||||||
|
|
||||||
|
```js
|
||||||
|
float deg2rad(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 method 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue