stringifyDependencies
Writes dependency groups back as a field value, the inverse of parseDependencies; the
type of groups is that of format.
'debian' — the canonical spacing of the Debian Policy Manual 7.1: , between entries,
| between alternatives, a space before each (op version), [archs] and <profiles>.
'rpm' — , between entries, name op version, and (a or b) for alternatives.
'arch' — entries separated by a space, name>=version. 'alpine' — the same, with a
leading ! for a conflict. 'pep508' — one requirement per line,
name[extras]>=1,<2 ; marker. The formats without alternatives ('arch', 'alpine',
'pep508') throw a RangeError for a group of several.
parseDependencies(stringifyDependencies(groups, f), f) gives groups back, and stringifying a
parsed field normalises its whitespace. An empty group writes nothing, so it does not survive a
round trip.
Available since v3.1.10
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
groups | readonly DependencyGroup<DependencyOf<NoInfer<Format>>>[] | The groups of alternatives, as returned by `parseDependencies` |
format | Format | How to write the field |
Returns
Section titled “Returns”string — The field value; '' for []
Examples
Section titled “Examples”Write relationships as a field value
Section titled “Write relationships as a field value”Entries are joined with ”, ” and alternatives with ” | ”.
Normalise a field after editing it
Section titled “Normalise a field after editing it”Parse, change the groups, write them back in canonical spacing.
Write another format
Section titled “Write another format”The same function writes RPM, Arch, Alpine and PEP 508 fields, each from its own dependency type.
Related Types
Section titled “Related Types”DependencyFormats
Section titled “DependencyFormats”For each supported format, the shape of one dependency and the options its parser takes. This is what makes parseDependencies and stringifyDependencies type-safe per format.
DependencyGroup
Section titled “DependencyGroup”The alternatives (a | b) that satisfy one entry of a dependency field. A format without
alternatives ('arch', 'alpine', 'pep508') always has a single one.
DependencyOf
Section titled “DependencyOf”The dependency type of a format.
DependencyFormat
Section titled “DependencyFormat”The formats of dependency fields: 'debian', 'rpm', 'arch', 'alpine' and 'pep508'.
