@@ -17,6 +17,7 @@ import {
1717 GeoUnit ,
1818 InsertPosition ,
1919 KeyWeight ,
20+ ListDirection ,
2021 RangeByIndex ,
2122 RangeByLex ,
2223 RangeByScore ,
@@ -63,6 +64,7 @@ import {
6364 createLIndex ,
6465 createLInsert ,
6566 createLLen ,
67+ createLMove ,
6668 createLPop ,
6769 createLPos ,
6870 createLPush ,
@@ -1465,6 +1467,47 @@ export class BaseClient {
14651467 return this . createWritePromise ( createLLen ( key ) ) ;
14661468 }
14671469
1470+ /**
1471+ * Atomically pops and removes the left/right-most element to the list stored at `source`
1472+ * depending on `whereTo`, and pushes the element at the first/last element of the list
1473+ * stored at `destination` depending on `whereFrom`, see {@link ListDirection}.
1474+ *
1475+ * See https://valkey.io/commands/lmove/ for details.
1476+ *
1477+ * @param source - The key to the source list.
1478+ * @param destination - The key to the destination list.
1479+ * @param whereFrom - The {@link ListDirection} to remove the element from.
1480+ * @param whereTo - The {@link ListDirection} to add the element to.
1481+ * @returns The popped element, or `null` if `source` does not exist.
1482+ *
1483+ * since Valkey version 6.2.0.
1484+ *
1485+ * @example
1486+ * ```typescript
1487+ * await client.lpush("testKey1", ["two", "one"]);
1488+ * await client.lpush("testKey2", ["four", "three"]);
1489+ *
1490+ * const result1 = await client.lmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT);
1491+ * console.log(result1); // Output: "one".
1492+ *
1493+ * const updated_array_key1 = await client.lrange("testKey1", 0, -1);
1494+ * console.log(updated_array); // Output: "two".
1495+ *
1496+ * const updated_array_key2 = await client.lrange("testKey2", 0, -1);
1497+ * console.log(updated_array_key2); // Output: ["one", "three", "four"].
1498+ * ```
1499+ */
1500+ public async lmove (
1501+ source : string ,
1502+ destination : string ,
1503+ whereFrom : ListDirection ,
1504+ whereTo : ListDirection ,
1505+ ) : Promise < string | null > {
1506+ return this . createWritePromise (
1507+ createLMove ( source , destination , whereFrom , whereTo ) ,
1508+ ) ;
1509+ }
1510+
14681511 /**
14691512 * Sets the list element at `index` to `element`.
14701513 * The index is zero-based, so `0` means the first element, `1` the second element and so on.
0 commit comments