# MemoryUrlState

An in-memory [`UrlState`](https://docs.mapcairn.com/api/core/UrlState.md).

This is a class exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { MemoryUrlState } from "@mapcairn/core";
 
class MemoryUrlState implements UrlState
```

## Description

How to script it: pass the starting value, as if the page had loaded with
that address. `write` replaces the whole value (it does not merge), and
`writes` records every value written, in order. Nothing is debounced.

## Constructors

### (constructor)

```ts
constructor(initial?: UrlStateValue);
```

Constructs a new instance of the `MemoryUrlState` class

- `initial?` (`UrlStateValue`)

## Properties

### writes

```ts
readonly writes: UrlStateValue[];
```

Every value passed to `write`, in order.

## Methods

### link

```ts
link(value: UrlStateValue): string;
```

The memory address base followed by the hash `value` makes. It has no side effect.

- `value` (`UrlStateValue`)

### read

```ts
read(): UrlStateValue;
```

The value last written, or the one it started with.

### write

```ts
write(value: UrlStateValue): void;
```

Replaces the whole value and records it in `writes`. It does not merge or debounce.

- `value` (`UrlStateValue`)

## See also

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

Source: [packages/core/src/fakes/MemoryUrlState.ts:16](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/fakes/MemoryUrlState.ts#L16)
