NeahNew/node_modules/cookies-next/lib/common/utils.js
2025-05-03 14:17:46 +02:00

29 lines
1.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRenderPhase = exports.isClientSide = exports.decode = exports.stringify = void 0;
var stringify = function (value) {
try {
if (typeof value === 'string') {
return value;
}
var stringifiedValue = JSON.stringify(value);
return stringifiedValue;
}
catch (e) {
return value;
}
};
exports.stringify = stringify;
var decode = function (str) {
if (!str)
return str;
return str.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
};
exports.decode = decode;
var isClientSide = function (options) {
return !(options === null || options === void 0 ? void 0 : options.req) && !(options === null || options === void 0 ? void 0 : options.res) && !(options && 'cookies' in options && (options === null || options === void 0 ? void 0 : options.cookies));
};
exports.isClientSide = isClientSide;
var getRenderPhase = function () { return (typeof window === 'undefined' ? 'server' : 'client'); };
exports.getRenderPhase = getRenderPhase;