tough-cookie.cookiejar.clonesync.md

July 9, 2025 ยท View on GitHub

Home > tough-cookie > CookieJar > cloneSync

CookieJar.cloneSync() method

Produces a deep clone of this CookieJar. Modifications to the original do not affect the clone, and vice versa.

Note: Only works if both the configured Store and destination Store are synchronous.

Signature:

cloneSync(newStore?: Store): CookieJar | undefined;

Parameters

Parameter

Type

Description

newStore

Store

(Optional) The target Store to clone cookies into.

Returns:

CookieJar | undefined

Remarks

  • When no Store is provided, a new MemoryCookieStore will be used.

  • Transferring between store types is supported so long as the source implements .getAllCookies() and the destination implements .putCookie().