partitionDefinitions
Sorts a list of values a host supplied into valid layer definitions and
the values that were not, so one bad definition costs one layer and not
the list. Whatever an entry holds, even a value that throws when read, it
does not throw: every entry is validated by validateLayerDefinition, and
an entry that fails is returned as a SkippedDefinition with its
problems and, when it had a text id, that id. (raw itself must be a
readable array: the runtime catalogue checks that.)
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { partitionDefinitions } from "@mapcairn/core";
function partitionDefinitions(raw: readonly unknown[], options: ValidationOptions, previous?: PartitionedDefinitions): PartitionedDefinitions;
Description
- A definition whose id a definition already kept has is skipped with the
problem
id: duplicate: the first valid one wins. - A value that is not an object is skipped with no id.
- A value that cannot be read at all is skipped with the problem
definition: could not be read. - Given the
previousresult, a definition that is deeply equal to the previous one with the same id keeps the previous object, and the wholelayers(orskipped) list is the previous one when nothing in it changed, so a refresh that changes nothing changes no reference. A definition nested more deeply thanjsonEqualfollows counts as changed.
Parameters
raw(readonly unknown[])options(ValidationOptions)previous?(PartitionedDefinitions)
Returns
PartitionedDefinitions