---
title: "CommandHistory | Customer's Canvas On-Premises"
canonical: "https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/CommandHistory/"
---

# CommandHistory

> History of executed commands.

## Classes

### CommandHistory

#### Implements

- [`ICommandHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#icommandhistory)

#### Constructors

##### Constructor

```ts
new CommandHistory(size?): CommandHistory;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `size?` | `number` |

###### Returns

[`CommandHistory`](#commandhistory)

#### Methods

##### addCommand()

```ts
addCommand(command): void;
```

Adds the executed command to history.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `command` | [`ICommand`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommand.md#icommand) | executed command. |

###### Returns

`void`

###### Implementation of

[`ICommandHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#icommandhistory).[`addCommand`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#addcommand)

##### clearHistory()

```ts
clearHistory(): void;
```

Clears the history of executed commands.

###### Returns

`void`

###### Implementation of

[`ICommandHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#icommandhistory).[`clearHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#clearhistory)

##### getCommandsCount()

```ts
getCommandsCount(): number;
```

Returns the number of commands in history.

###### Returns

`number`

###### Implementation of

[`ICommandHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#icommandhistory).[`getCommandsCount`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#getcommandscount)

##### getLastCommand()

```ts
getLastCommand(index?): ICommand;
```

Returns the last command executed from history by index.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `index?` | `number` | command index ('0' used for the most recent command). |

###### Returns

[`ICommand`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommand.md#icommand)

###### Implementation of

[`ICommandHistory`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#icommandhistory).[`getLastCommand`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICommandHistory.md#getlastcommand)
