cookies-next
Advanced tools
Comparing version 2.1.2 to 3.0.0
@@ -6,15 +6,3 @@ import { OptionsType, TmpCookiesObj, CookieValueTypes } from './types'; | ||
export declare const setCookie: (key: string, data: any, options?: OptionsType) => void; | ||
/** | ||
* @deprecated setCookies was deprecated. It will be deleted in the new version. Use setCookie instead. | ||
*/ | ||
export declare const setCookies: (key: string, data: any, options?: OptionsType) => void; | ||
export declare const deleteCookie: (key: string, options?: OptionsType) => void; | ||
/** | ||
* @deprecated removeCookies was deprecated. It will be deleted in the new version. Use deleteCookie instead. | ||
*/ | ||
export declare const removeCookies: (key: string, options?: OptionsType) => void; | ||
export declare const hasCookie: (key: string, options?: OptionsType) => boolean; | ||
/** | ||
* @deprecated checkCookies was deprecated. It will be deleted in the new version. Use hasCookie instead. | ||
*/ | ||
export declare const checkCookies: (key: string, options?: OptionsType) => boolean; |
@@ -25,16 +25,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkCookies = exports.hasCookie = exports.removeCookies = exports.deleteCookie = exports.setCookies = exports.setCookie = exports.getCookie = exports.getCookies = void 0; | ||
exports.hasCookie = exports.deleteCookie = exports.setCookie = exports.getCookie = exports.getCookies = void 0; | ||
var cookie_1 = require("cookie"); | ||
var isClientSide = function () { return typeof window !== 'undefined'; }; | ||
var processValue = function (value) { | ||
if (value === 'true') | ||
return true; | ||
if (value === 'false') | ||
return false; | ||
if (value === 'undefined') | ||
return undefined; | ||
if (value === 'null') | ||
return null; | ||
return value; | ||
}; | ||
var stringify = function (value) { | ||
@@ -84,3 +73,3 @@ if (value === void 0) { value = ''; } | ||
return undefined; | ||
return processValue(decode(value)); | ||
return decode(value); | ||
}; | ||
@@ -124,10 +113,2 @@ exports.getCookie = getCookie; | ||
exports.setCookie = setCookie; | ||
/** | ||
* @deprecated setCookies was deprecated. It will be deleted in the new version. Use setCookie instead. | ||
*/ | ||
var setCookies = function (key, data, options) { | ||
console.warn('[WARN]: setCookies was deprecated. It will be deleted in the new version. Use setCookie instead.'); | ||
return (0, exports.setCookie)(key, data, options); | ||
}; | ||
exports.setCookies = setCookies; | ||
var deleteCookie = function (key, options) { | ||
@@ -137,10 +118,2 @@ return (0, exports.setCookie)(key, '', __assign(__assign({}, options), { maxAge: -1 })); | ||
exports.deleteCookie = deleteCookie; | ||
/** | ||
* @deprecated removeCookies was deprecated. It will be deleted in the new version. Use deleteCookie instead. | ||
*/ | ||
var removeCookies = function (key, options) { | ||
console.warn('[WARN]: removeCookies was deprecated. It will be deleted in the new version. Use deleteCookie instead.'); | ||
return (0, exports.deleteCookie)(key, options); | ||
}; | ||
exports.removeCookies = removeCookies; | ||
var hasCookie = function (key, options) { | ||
@@ -153,9 +126,1 @@ if (!key) | ||
exports.hasCookie = hasCookie; | ||
/** | ||
* @deprecated checkCookies was deprecated. It will be deleted in the new version. Use hasCookie instead. | ||
*/ | ||
var checkCookies = function (key, options) { | ||
console.warn('[WARN]: checkCookies was deprecated. It will be deleted in the new version. Use hasCookie instead.'); | ||
return (0, exports.hasCookie)(key, options); | ||
}; | ||
exports.checkCookies = checkCookies; |
@@ -19,2 +19,2 @@ /// <reference types="node" /> | ||
}>; | ||
export declare type CookieValueTypes = string | boolean | undefined | null; | ||
export declare type CookieValueTypes = string | undefined; |
{ | ||
"name": "cookies-next", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "Getting, setting and removing cookies on both client and server with next.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -89,3 +89,3 @@ # cookies-next | ||
```js | ||
import { getCookies, setCookie, deleteCookie } from 'cookies-next'; | ||
import { getCookies, setCookie, deleteCookie, getCookie } from 'cookies-next'; | ||
@@ -92,0 +92,0 @@ // we can use it anywhere |
@@ -7,10 +7,2 @@ import { serialize, parse } from 'cookie'; | ||
const processValue = (value: string): CookieValueTypes => { | ||
if (value === 'true') return true; | ||
if (value === 'false') return false; | ||
if (value === 'undefined') return undefined; | ||
if (value === 'null') return null; | ||
return value; | ||
}; | ||
const stringify = (value: string = '') => { | ||
@@ -61,3 +53,3 @@ try { | ||
if (value === undefined) return undefined; | ||
return processValue(decode(value)); | ||
return decode(value); | ||
}; | ||
@@ -106,10 +98,2 @@ | ||
/** | ||
* @deprecated setCookies was deprecated. It will be deleted in the new version. Use setCookie instead. | ||
*/ | ||
export const setCookies = (key: string, data: any, options?: OptionsType): void => { | ||
console.warn('[WARN]: setCookies was deprecated. It will be deleted in the new version. Use setCookie instead.'); | ||
return setCookie(key, data, options); | ||
} | ||
export const deleteCookie = (key: string, options?: OptionsType): void => { | ||
@@ -119,10 +103,2 @@ return setCookie(key, '', { ...options, maxAge: -1 }); | ||
/** | ||
* @deprecated removeCookies was deprecated. It will be deleted in the new version. Use deleteCookie instead. | ||
*/ | ||
export const removeCookies = (key: string, options?: OptionsType): void => { | ||
console.warn('[WARN]: removeCookies was deprecated. It will be deleted in the new version. Use deleteCookie instead.'); | ||
return deleteCookie(key, options); | ||
}; | ||
export const hasCookie = (key: string, options?: OptionsType): boolean => { | ||
@@ -134,9 +110,1 @@ if (!key) return false; | ||
}; | ||
/** | ||
* @deprecated checkCookies was deprecated. It will be deleted in the new version. Use hasCookie instead. | ||
*/ | ||
export const checkCookies = (key: string, options?: OptionsType): boolean => { | ||
console.warn('[WARN]: checkCookies was deprecated. It will be deleted in the new version. Use hasCookie instead.'); | ||
return hasCookie(key, options); | ||
}; |
@@ -12,2 +12,2 @@ import { CookieSerializeOptions } from 'cookie'; | ||
export type TmpCookiesObj = { [key: string]: string } | Partial<{ [key: string]: string}>; | ||
export type CookieValueTypes = string | boolean | undefined | null; | ||
export type CookieValueTypes = string | undefined; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19880
252