@vkontakte/vkjs
Advanced tools
Comparing version 0.28.0 to 0.29.0
export declare function getCookie(name: string): string | undefined; | ||
export declare const isCookieEnabled: () => boolean; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.getCookie = getCookie; | ||
exports.isCookieEnabled = void 0; | ||
function getCookie(name) { | ||
@@ -12,2 +13,16 @@ var matches = document.cookie.match(new RegExp('(?:^|; )' + name.replace(/([.$?*|{}()\[\]\\\/+^])/g, '\\$1') + '=([^;]*)')); | ||
} | ||
var isCookieEnabledCache = null; | ||
var isCookieEnabled = function isCookieEnabled() { | ||
if (isCookieEnabledCache === null) { | ||
try { | ||
document.cookie = 'cookietest=1'; | ||
isCookieEnabledCache = document.cookie.indexOf('cookietest=') !== -1; | ||
document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT'; | ||
} catch (e) { | ||
isCookieEnabledCache = false; | ||
} | ||
} | ||
return isCookieEnabledCache; | ||
}; | ||
exports.isCookieEnabled = isCookieEnabled; | ||
//# sourceMappingURL=cookie.js.map |
@@ -5,2 +5,15 @@ export function getCookie(name) { | ||
} | ||
var isCookieEnabledCache = null; | ||
export var isCookieEnabled = function isCookieEnabled() { | ||
if (isCookieEnabledCache === null) { | ||
try { | ||
document.cookie = 'cookietest=1'; | ||
isCookieEnabledCache = document.cookie.indexOf('cookietest=') !== -1; | ||
document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT'; | ||
} catch (e) { | ||
isCookieEnabledCache = false; | ||
} | ||
} | ||
return isCookieEnabledCache; | ||
}; | ||
//# sourceMappingURL=cookie.js.map |
@@ -26,3 +26,3 @@ export { animate, animationEvent, transitionEvent, waitAnimationEnd, cancelWaitAnimationEnd, waitTransitionEnd, cancelWaitTransitionEnd } from './animate'; | ||
export { asyncImportLoader } from './async'; | ||
export { getCookie } from './cookie'; | ||
export { getCookie, isCookieEnabled } from './cookie'; | ||
export { SECONDS_IN_THE_DAY, isDateToday, isDateYesterday, isDateTomorrow, isSameDate, getBeginningOfDay, isLeapYear, getLastDayOfMonth, getStartOfWeek, addDays, createDateFromUnixTimestamp, getUnixTimestampFromDate, convertDateToInputFormat } from './date'; | ||
@@ -29,0 +29,0 @@ export { formatDuration } from './duration'; |
@@ -10,3 +10,3 @@ export { animate, animationEvent, transitionEvent, waitAnimationEnd, cancelWaitAnimationEnd, waitTransitionEnd, cancelWaitTransitionEnd, } from './animate'; | ||
export { asyncImportLoader } from './async'; | ||
export { getCookie } from './cookie'; | ||
export { getCookie, isCookieEnabled } from './cookie'; | ||
export { SECONDS_IN_THE_DAY, isDateToday, isDateYesterday, isDateTomorrow, isSameDate, getBeginningOfDay, isLeapYear, getLastDayOfMonth, getStartOfWeek, addDays, createDateFromUnixTimestamp, getUnixTimestampFromDate, convertDateToInputFormat, } from './date'; | ||
@@ -13,0 +13,0 @@ export { formatDuration } from './duration'; |
@@ -294,2 +294,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "isCookieEnabled", { | ||
enumerable: true, | ||
get: function get() { | ||
return _cookie.isCookieEnabled; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isDateToday", { | ||
@@ -296,0 +302,0 @@ enumerable: true, |
{ | ||
"name": "@vkontakte/vkjs", | ||
"version": "0.28.0", | ||
"version": "0.29.0", | ||
"description": "VK shared JS libs", | ||
@@ -119,5 +119,5 @@ "main": "lib/index.js", | ||
"resolutions": { | ||
"@typescript-eslint/eslint-plugin": "5.42.0", | ||
"@typescript-eslint/eslint-plugin": "5.43.0", | ||
"@typescript-eslint/parser": "5.42.0" | ||
} | ||
} |
@@ -7,1 +7,19 @@ export function getCookie(name: string): string | undefined { | ||
} | ||
let isCookieEnabledCache: boolean | null = null; | ||
export const isCookieEnabled = () => { | ||
if (isCookieEnabledCache === null) { | ||
try { | ||
document.cookie = 'cookietest=1'; | ||
isCookieEnabledCache = document.cookie.indexOf('cookietest=') !== -1; | ||
document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT'; | ||
} catch (e) { | ||
isCookieEnabledCache = false; | ||
} | ||
} | ||
return isCookieEnabledCache; | ||
}; |
@@ -47,3 +47,3 @@ export { | ||
export { getCookie } from './cookie'; | ||
export { getCookie, isCookieEnabled } from './cookie'; | ||
@@ -50,0 +50,0 @@ export { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
374451
5756