# LPOS

> Returns the index of matching elements inside a list.

## Arguments

<ParamField body="key" type="string" required>
  The key of the list.
</ParamField>

<ParamField body="element" type="unknown" required>
  The element to match.
</ParamField>

<ParamField body="opts">
  <ParamField body="rank" type="number">
    The rank of the element to match. If specified, the element at the given
    rank is matched instead of the first element.
  </ParamField>
  <ParamField body="count" type="number">
    The maximum number of elements to match. If specified, an array of elements
    is returned instead of a single element.
  </ParamField>
  <ParamField body="maxLen" type="number">
    Limit the number of comparisons to perform.
  </ParamField>
</ParamField>

## Response

<ResponseField type="number | number[]" required>
  The index of the matching element or an array of indexes if `opts.count` is
  specified.
</ResponseField>

<RequestExample>
```ts Example 
await redis.rpush("key", "a", "b", "c"); 
const index = await redis.lpos("key", "b");
console.log(index); // 1
 ```

```ts With Rank 
await redis.rpush("key", "a", "b", "c", "b"); 
const index = await redis.lpos("key", "b", { rank: 2 });
console.log(index); // 3
 ```

```ts With Count
await redis.rpush("key", "a", "b", "b");
const positions = await redis.lpos("key", "b", { count: 2 });
console.log(positions); // [1, 2]
```

</RequestExample>
