# decrement

Learn how to decrement a value by a given amount.

This method chains an `decrement` operation to the patch, which decrements a numeric value by a given amount.

Non-existent paths and null values are treated as zero.

> **Atomicity**
>
> If the value at the specified path is not a number, the operation fails and the entire patch is discarded.

## Signature

This method has the following signature:

```ts
patch.decrement(path: string, value: number = 1): Patch
```

The return is the `Patch` instance itself to allow operation chaining.

## Example

Here is a basic example of how to use this method:

```ts
patch.decrement('score', 10);
```

The following table shows how the operation behaves in different scenarios:

| Current value | Amount | Result |
| ------------- | ------ | ------ |
| `null`        | `10`   | `-10`  |
| `0`           | `10`   | `-10`  |
| `1`           | `10`   | `9`    |

## Parameters

The following list describes the supported parameters:

- `path`: `string`

  The path to the value to decrement in dot notation, like `points`.

- `value`: `number` (optional) (default: 1)

  The amount to decrement the value by, like `2`.
