UNPKG

@iosifnicolae2/nextjs-turbo-redis-cache

Version:

[![npm version](https://img.shields.io/npm/v/@trieb.work/nextjs-turbo-redis-cache.svg)](https://www.npmjs.com/package/@trieb.work/nextjs-turbo-redis-cache) ![Turbo redis cache image](https://github.com/user-attachments/assets/98e0dfd9-f38a-42ad-a355-98437

27 lines (26 loc) 718 B
// eslint-disable-next-line @typescript-eslint/no-explicit-any export function bufferReviver(_: string, value: any): any { if (value && typeof value === 'object' && typeof value.$binary === 'string') { return Buffer.from(value.$binary, 'base64'); } return value; } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function bufferReplacer(_: string, value: any): any { if (Buffer.isBuffer(value)) { return { $binary: value.toString('base64'), }; } if ( value && typeof value === 'object' && value?.type === 'Buffer' && Array.isArray(value.data) ) { return { $binary: Buffer.from(value.data).toString('base64'), }; } return value; }