1.1 KiB
1.1 KiB
title |
---|
Pattern.needs() |
A pattern's needs()
method will return true
or false
depending on whether a pattern part is a requirement for the
pattern to be drafted in its current configuration. In other
words, it will return true
of the part is needed.
A part is needed if:
- it is requested by the user in the
only
pattern setting - it is a dependency of a part requested by the user in the
only
pattern setting - the
only
pattern setting is not set or isfalse
, and the part is not hidden
You don't typically use this method. Instead, you configure part dependencies in your configuration file.
Pattern.needs() signature
bool pattern.needs(string partName)
Pattern.needs() example
import Aaron from "@freesewing/aaron"
import models from "@freesewing/models"
const pattern = new Aaron({
settings: {
embed: true,
},
measurements: models.manSize38
})
if (pattern.needs('front')) console.log('Front is needed')
else console.log('Front is not needed')