# 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`](https://docs.mapcairn.com/api/core/SkippedDefinition.md) 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

```ts
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 `previous` result, a definition that is deeply equal to the
 previous one with the same id keeps the previous object, and the whole
 `layers` (or `skipped`) list is the previous one when nothing in it
 changed, so a refresh that changes nothing changes no reference. A
 definition nested more deeply than `jsonEqual` follows counts as
 changed.

## Parameters

- `raw` (`readonly unknown[]`)
- `options` (`ValidationOptions`)
- `previous?` (`PartitionedDefinitions`)

## Returns

`PartitionedDefinitions`

## See also

- [`ValidationOptions`](https://docs.mapcairn.com/api/core/ValidationOptions.md)
- [`PartitionedDefinitions`](https://docs.mapcairn.com/api/core/PartitionedDefinitions.md)

Source: [packages/core/src/layers/partitionDefinitions.ts:68](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/layers/partitionDefinitions.ts#L68)
