# Class: Storage\<T\>

Defined in: [core/src/storage.ts:48](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L48)

localStorage wrapper that never throws: private mode, blocked storage and corrupt JSON fall back to defaults
so the game still runs. Saves from older versions of the game load safely (see `fit` and `StorageOptions`).

## Type Parameters

### T

`T` *extends* `object`

## Constructors

### Constructor

> **new Storage**\<`T`\>(`key`, `defaults`, `__namedParameters?`): `Storage`\<`T`\>

Defined in: [core/src/storage.ts:51](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L51)

#### Parameters

##### key

`string`

##### defaults

`T`

##### \_\_namedParameters?

[`StorageOptions`](../interfaces/StorageOptions.md)\<`T`\> = `{}`

#### Returns

`Storage`\<`T`\>

## Properties

### key

> `readonly` **key**: `string`

Defined in: [core/src/storage.ts:52](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L52)

## Accessors

### data

#### Get Signature

> **get** **data**(): `Readonly`\<`T`\>

Defined in: [core/src/storage.ts:79](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L79)

##### Returns

`Readonly`\<`T`\>

## Methods

### get()

> **get**\<`K`\>(`key`): `T`\[`K`\]

Defined in: [core/src/storage.ts:83](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L83)

#### Type Parameters

##### K

`K` *extends* `string` \| `number` \| `symbol`

#### Parameters

##### key

`K`

#### Returns

`T`\[`K`\]

***

### reset()

> **reset**(): `boolean`

Defined in: [core/src/storage.ts:98](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L98)

Back to the defaults. Returns whether that reached storage, like `set`.

#### Returns

`boolean`

***

### set()

> **set**\<`K`\>(`key`, `v`): `boolean`

Defined in: [core/src/storage.ts:92](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/core/src/storage.ts#L92)

Change a field. Returns whether it reached storage: `false` means the value lives in memory only, and a
reload gets the last save that fitted (storage full, private mode, or no localStorage). Before 0.28 it
returned nothing. localStorage usually holds about 5 MB per origin.

#### Type Parameters

##### K

`K` *extends* `string` \| `number` \| `symbol`

#### Parameters

##### key

`K`

##### v

`T`\[`K`\]

#### Returns

`boolean`
