# atom.io/foundations/enumeration

Source: docs/source/pages/docs/foundations/enumeration.mdx
URL: /docs/foundations/enumeration

# <low-emphasis>atom.io</low-emphasis>/foundations/enumeration

A small alternative to two-way TypeScript enums:
give it a readonly string array and it returns both readable string-to-number mappings
and number-to-string mappings.

### change enumeration
Source: docs/source/exhibits/foundations/enumeration/change-enumeration.ts

```ts
import { enumeration } from "atom.io/foundations/enumeration"

const change = enumeration([`add`, `delete`, `clear`] as const)

change.add // 0
change.delete // 1
change.clear // 2

change[0] // "add"
change[1] // "delete"
change[2] // "clear"
```

If you want the runtime object gone after compilation, pair it with
[comptime](https://www.npmjs.com/package/comptime).

## package contents

<table-wrapper>

| Export | Description |
| --- | --- |
| `IndexOf` | Type-level index lookup for a tuple member. |
| `Flip` | Type-level reverse mapping for string or number records. |
| `TwoWay` | A type with both forward and reverse mappings. |
| `Enumeration` | The two-way enumeration type produced for a string tuple. |
| `enumeration` | Create the two-way mapping at runtime. |

</table-wrapper>
