@amaui/cookie
Advanced tools
Comparing version 1.0.1 to 1.0.11
@@ -5,5 +5,5 @@ declare class AmauiCookie { | ||
static get(name: string): any; | ||
static set(name_: string, value_: any, days?: number, path?: string): void; | ||
static add(name_: string, value_: any, days?: number, path?: string): void; | ||
static remove(name: string, path?: string): void; | ||
} | ||
export default AmauiCookie; |
@@ -39,3 +39,3 @@ "use strict"; | ||
static set(name_, value_, days = 364, path = '/') { | ||
static add(name_, value_, days = 364, path = '/') { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
@@ -42,0 +42,0 @@ const name = name_; |
@@ -11,3 +11,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { add } from '@amaui/date'; | ||
import { add as _add } from '@amaui/date'; | ||
@@ -59,4 +59,4 @@ var AmauiCookie = /*#__PURE__*/function () { | ||
}, { | ||
key: "set", | ||
value: function set(name_, value_) { | ||
key: "add", | ||
value: function add(name_, value_) { | ||
var days = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 364; | ||
@@ -68,3 +68,5 @@ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/'; | ||
var value = !is('string', value_) ? serialize(value_) : value_; | ||
var expires = add(days, 'day').utc; | ||
var expires = _add(days, 'day').utc; | ||
document.cookie = "".concat(name, "=").concat(value, "; expires=").concat(expires, "; path=").concat(path); | ||
@@ -71,0 +73,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -11,3 +11,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { add } from '@amaui/date'; | ||
import { add as _add } from '@amaui/date'; | ||
@@ -59,4 +59,4 @@ var AmauiCookie = /*#__PURE__*/function () { | ||
}, { | ||
key: "set", | ||
value: function set(name_, value_) { | ||
key: "add", | ||
value: function add(name_, value_) { | ||
var days = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 364; | ||
@@ -68,3 +68,5 @@ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/'; | ||
var value = !is('string', value_) ? serialize(value_) : value_; | ||
var expires = add(days, 'day').utc; | ||
var expires = _add(days, 'day').utc; | ||
document.cookie = "".concat(name, "=").concat(value, "; expires=").concat(expires, "; path=").concat(path); | ||
@@ -71,0 +73,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -31,3 +31,3 @@ import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
static set(name_, value_, days = 364, path = '/') { | ||
static add(name_, value_, days = 364, path = '/') { | ||
if (isEnvironment('browser')) { | ||
@@ -34,0 +34,0 @@ const name = name_; |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
{ | ||
"name": "@amaui/cookie", | ||
"version": "1.0.1", | ||
"version": "1.0.11", | ||
"description": "Cookie", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/amaui-org/amaui-cookie.git", |
@@ -48,3 +48,3 @@ | ||
// Add a cookie | ||
AmauiCookie.set('a', 4); | ||
AmauiCookie.add('a', 4); | ||
@@ -51,0 +51,0 @@ // Get a cookie |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -553,4 +553,4 @@ * This source code is licensed under the MIT license found in the | ||
}, { | ||
key: "set", | ||
value: function set(name_, value_) { | ||
key: "add", | ||
value: function add$1(name_, value_) { | ||
var days = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 364; | ||
@@ -562,3 +562,5 @@ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/'; | ||
var value = !is('string', value_) ? serialize$1(value_) : value_; | ||
var expires = add(days, 'day').utc; | ||
document.cookie = "".concat(name, "=").concat(value, "; expires=").concat(expires, "; path=").concat(path); | ||
@@ -565,0 +567,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.1 | ||
/** @license AmauiCookie v1.0.11 | ||
* | ||
@@ -6,2 +6,2 @@ * This source code is licensed under the MIT license found in the | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AmauiCookie=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}var a={elementIsObject:!1},u=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,u=i({},a,r);switch(t){case"string":return"string"==typeof n;case"number":return"number"==typeof n&&!Number.isNaN(n);case"boolean":return"boolean"==typeof n;case"array":return Array.isArray(n);case"object":var c="object"===o(n)&&!!n&&n.constructor===Object,l=e("element",n,u);return c&&(!l||u.elementIsObject);case"object-like":return"object"===o(n)&&(null===n||n.constructor!==Object);case"class":return("object"===o(n)||"function"==typeof n)&&(/class/gi.test(String(n))||/class/gi.test(String(null==n?void 0:n.constructor)));case"function":return!!(n&&n instanceof Function);case"async":return!(!e("function",n)||!(s("browser")?"AsyncFunction"===n.constructor.name:n()instanceof Promise));case"date":return!!(n&&n instanceof Date);case"element":return!(!n||!n.elementType&&!n.hasOwnProperty("$$typeof"));case"simple":return e("string",n,u)||e("number",n,u)||e("boolean",n,u)||e("element",n,u)&&!u.elementIsObject||[void 0,null].indexOf(n)>-1;case"not-array-object":return!e("array",n,u)&&!e("object",n,u);case"array-buffer":return"[object ArrayBuffer]"===String(n);case"blob":return s("browser")&&n instanceof Blob;case"buffer":return!!(s("nodejs")&&n&&null!==n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n));default:return!1}},s=function e(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;switch(t){case"browser":return"undefined"!=typeof window&&void 0!==window.document;case"worker":return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;case"nodejs":return!(void 0===r||"undefined"==typeof module||!module.exports);case"localhost":return n=void 0!==o?o:e("browser")&&window.location.hostname,u("string",n)&&["localhost","127.0.0.1"].some((function(e){return n.indexOf(e)>-1}));default:return!1}},c=function e(t){if(u("array",t))return t.map((function(t){return e(t)}));if(u("object",t)){var n={};return Object.keys(t).forEach((function(r){return n[r]=e(t[r])})),n}return t},l={copy:!1,merge:{array:!1}},f=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l,o=i({},l,r);if(o.merge.array&&u("array",t)&&u("array",n))for(var a=Math.max(t.length,n.length),s=0;s<a;s++)void 0===t[s]&&(t[s]=n[s]),(u("object",t[s])&&u("object",n[s])||u("array",t[s])&&u("array",n[s]))&&(t[s]=e(t[s],n[s],o));return u("object",t)&&u("object",n)&&Object.keys(n).forEach((function(r){t.hasOwnProperty(r)?u("object",t[r])&&u("object",n[r])&&(t[r]=e(t[r],n[r],o)):t[r]=o.copy?c(n[r]):n[r]})),t},d={decode:!0,decodeMethod:decodeURIComponent},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=f(t,d),r=e;u("string",e)&&n.decode&&u("function",n.decodeMethod)&&(r=n.decodeMethod(e));try{if(u("string",r)){if("undefined"===r)return;return"NaN"===r?NaN:JSON.parse(r)}return r}catch(e){}return r},y=function e(t){return u("object",t)?"{".concat(Object.keys(t).sort().map((function(n){return'"'.concat(n,'":').concat(e(t[n]))})).join(","),"}"):u("array",t)?"[".concat(t.map((function(t){return e(t)})).join(","),"]"):u("string",t)?'"'.concat(t,'"'):function(e){return u("string",e)?e.replace(/(\s|\r|\n)+/," "):e}(JSON.stringify(function(e){return void 0===e?"undefined":e instanceof Function||e instanceof Object?e.toString():e}(t)))},v={},g=["January","February","March","April","May","June","July","August","September","October","November","December"],b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],p=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function w(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.amauidate;if(n&&n.valid)switch(t){case"millisecond":return new k(n.value.setMilliseconds(n.millisecond+e));case"second":return new k(n.value.setSeconds(n.second+e));case"minute":return new k(n.value.setMinutes(n.minute+e));case"hour":return new k(n.value.setHours(n.hour+e));case"day":return new k(n.value.setDate(n.day+e));case"week":return new k(n.value.setDate(n.day+7*e));case"month":return new k(n.value.setMonth(n.month-1+e));case"year":return new k(n.value.setFullYear(n.year+e))}}var k=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;e(this,t),this.value_=n,this.options=r,this.value=void 0,this.millisecond=void 0,this.milliseconds=void 0,this.second=void 0,this.minute=void 0,this.hour=void 0,this.day=void 0,this.dayWeek=void 0,this.dayYear=void 0,this.week=void 0,this.month=void 0,this.year=void 0,this.init()}return n(t,[{key:"init",value:function(){this.options=f(this.options,v),u("number",this.value_)&&10===String(this.value_).length&&(this.value_*=1e3),this.value=new Date(this.value_ instanceof t?this.value_.value:this.value_),this.valid&&(this.millisecond=this.value[this.options.utc?"getUTCMilliseconds":"getMilliseconds"](),this.milliseconds=this.value.getTime(),this.second=this.value[this.options.utc?"getUTCSeconds":"getSeconds"](),this.minute=this.value[this.options.utc?"getUTCMinutes":"getMinutes"](),this.hour=this.value[this.options.utc?"getUTCHours":"getHours"](),this.day=this.value[this.options.utc?"getUTCDate":"getDate"](),this.dayWeek=this.value[this.options.utc?"getUTCDay":"getDay"](),this.month=this.value[this.options.utc?"getUTCMonth":"getMonth"]()+1,this.year=this.value[this.options.utc?"getUTCFullYear":"getFullYear"](),this.dayYear=Math.floor((this.milliseconds-Number(new Date(this.year,0,0)))/1e3/60/60/24),this.weekValue())}},{key:"weekValue",value:function(){var e=new Date(this.year,0,1);return e.setDate(e.getDate()+(1-e.getDay()%7)),this.week=Math.round((Number(this.value)-Number(e))/6048e5)+1,this.week}},{key:"months",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.months)||g}},{key:"monthsAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.monthsAbr)||b}},{key:"daysWeek",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeek)||m}},{key:"daysWeekAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeekAbr)||p}},{key:"valid",get:function(){return void 0===this.value_||this.value_ instanceof Date||this.value_ instanceof t||(e=new Date(this.value_).getTime(),Number.isInteger(e)&&String(e).length>=10&&(new Date(e).getTime()>0||new Date(1e3*e).getTime()>0));var e}},{key:"local",get:function(){if(this.valid)return new t(new Date(this.value.toLocaleString("en-us")))}},{key:"utc",get:function(){return new t(this.value,{utc:!0})}},{key:"iso",get:function(){if(this.valid)return this.value.toISOString()}},{key:"daysInMonth",get:function(){return new Date(this.year,this.month,0).getDate()}},{key:"weeksInYear",get:function(){var e=new Date(this.year,0,1),t=1===new Date(this.year,1,29).getMonth();return 4===e.getDay()||t&&3===e.getDay()?53:52}},{key:"valueOf",get:function(){return this.milliseconds}},{key:"unix",get:function(){if(this.valid)return Math.floor(this.value.getTime()/1e3)}},{key:"timezone",value:function(e){if(this.valid&&e)return new t(this.value.toLocaleString("en-us",{timeZone:e}))}}],[{key:"utc",get:function(){return new t(new Date,{utc:!0})}},{key:"daysInMonth",get:function(){return(new t).daysInMonth}},{key:"valueOf",get:function(){return(new t).valueOf}},{key:"unix",get:function(){return(new t).unix}},{key:"milliseconds",get:function(){return(new t).milliseconds}},{key:"iso",get:function(){return(new t).iso}},{key:"amauidate",get:function(){return new t}},{key:"local",get:function(){return(new t).local}}]),t}();function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var O=function(){function t(){e(this,t)}return n(t,null,[{key:"cookie",get:function(){return s("browser")&&window.document.cookie||""}},{key:"cookies",get:function(){if(s("browser")){var e,n={},r=j(t.cookie.split("; "));try{for(r.s();!(e=r.n()).done;){var o=e.value.split("=");n[o[0]]=h(o.slice(1).join("="))}}catch(e){r.e(e)}finally{r.f()}return n}}},{key:"get",value:function(e){if(s("browser"))return t.cookies[e]}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:364,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/";if(s("browser")){var o=e,i=u("string",t)?t:y(t),a=w(n,"day").utc;document.cookie="".concat(o,"=").concat(i,"; expires=").concat(a,"; path=").concat(r)}}},{key:"remove",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";if(s("browser")){var r=t.cookies;r.hasOwnProperty(e)&&(document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(n))}}}]),t}();return O})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AmauiCookie=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}var a={elementIsObject:!1},u=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,u=i({},a,r);switch(t){case"string":return"string"==typeof n;case"number":return"number"==typeof n&&!Number.isNaN(n);case"boolean":return"boolean"==typeof n;case"array":return Array.isArray(n);case"object":var c="object"===o(n)&&!!n&&n.constructor===Object,l=e("element",n,u);return c&&(!l||u.elementIsObject);case"object-like":return"object"===o(n)&&(null===n||n.constructor!==Object);case"class":return("object"===o(n)||"function"==typeof n)&&(/class/gi.test(String(n))||/class/gi.test(String(null==n?void 0:n.constructor)));case"function":return!!(n&&n instanceof Function);case"async":return!(!e("function",n)||!(s("browser")?"AsyncFunction"===n.constructor.name:n()instanceof Promise));case"date":return!!(n&&n instanceof Date);case"element":return!(!n||!n.elementType&&!n.hasOwnProperty("$$typeof"));case"simple":return e("string",n,u)||e("number",n,u)||e("boolean",n,u)||e("element",n,u)&&!u.elementIsObject||[void 0,null].indexOf(n)>-1;case"not-array-object":return!e("array",n,u)&&!e("object",n,u);case"array-buffer":return"[object ArrayBuffer]"===String(n);case"blob":return s("browser")&&n instanceof Blob;case"buffer":return!!(s("nodejs")&&n&&null!==n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n));default:return!1}},s=function e(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;switch(t){case"browser":return"undefined"!=typeof window&&void 0!==window.document;case"worker":return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;case"nodejs":return!(void 0===r||"undefined"==typeof module||!module.exports);case"localhost":return n=void 0!==o?o:e("browser")&&window.location.hostname,u("string",n)&&["localhost","127.0.0.1"].some((function(e){return n.indexOf(e)>-1}));default:return!1}},c=function e(t){if(u("array",t))return t.map((function(t){return e(t)}));if(u("object",t)){var n={};return Object.keys(t).forEach((function(r){return n[r]=e(t[r])})),n}return t},l={copy:!1,merge:{array:!1}},f=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l,o=i({},l,r);if(o.merge.array&&u("array",t)&&u("array",n))for(var a=Math.max(t.length,n.length),s=0;s<a;s++)void 0===t[s]&&(t[s]=n[s]),(u("object",t[s])&&u("object",n[s])||u("array",t[s])&&u("array",n[s]))&&(t[s]=e(t[s],n[s],o));return u("object",t)&&u("object",n)&&Object.keys(n).forEach((function(r){t.hasOwnProperty(r)?u("object",t[r])&&u("object",n[r])&&(t[r]=e(t[r],n[r],o)):t[r]=o.copy?c(n[r]):n[r]})),t},d={decode:!0,decodeMethod:decodeURIComponent},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=f(t,d),r=e;u("string",e)&&n.decode&&u("function",n.decodeMethod)&&(r=n.decodeMethod(e));try{if(u("string",r)){if("undefined"===r)return;return"NaN"===r?NaN:JSON.parse(r)}return r}catch(e){}return r},y=function e(t){return u("object",t)?"{".concat(Object.keys(t).sort().map((function(n){return'"'.concat(n,'":').concat(e(t[n]))})).join(","),"}"):u("array",t)?"[".concat(t.map((function(t){return e(t)})).join(","),"]"):u("string",t)?'"'.concat(t,'"'):function(e){return u("string",e)?e.replace(/(\s|\r|\n)+/," "):e}(JSON.stringify(function(e){return void 0===e?"undefined":e instanceof Function||e instanceof Object?e.toString():e}(t)))},v={},g=["January","February","March","April","May","June","July","August","September","October","November","December"],b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],p=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function w(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.amauidate;if(n&&n.valid)switch(t){case"millisecond":return new k(n.value.setMilliseconds(n.millisecond+e));case"second":return new k(n.value.setSeconds(n.second+e));case"minute":return new k(n.value.setMinutes(n.minute+e));case"hour":return new k(n.value.setHours(n.hour+e));case"day":return new k(n.value.setDate(n.day+e));case"week":return new k(n.value.setDate(n.day+7*e));case"month":return new k(n.value.setMonth(n.month-1+e));case"year":return new k(n.value.setFullYear(n.year+e))}}var k=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;e(this,t),this.value_=n,this.options=r,this.value=void 0,this.millisecond=void 0,this.milliseconds=void 0,this.second=void 0,this.minute=void 0,this.hour=void 0,this.day=void 0,this.dayWeek=void 0,this.dayYear=void 0,this.week=void 0,this.month=void 0,this.year=void 0,this.init()}return n(t,[{key:"init",value:function(){this.options=f(this.options,v),u("number",this.value_)&&10===String(this.value_).length&&(this.value_*=1e3),this.value=new Date(this.value_ instanceof t?this.value_.value:this.value_),this.valid&&(this.millisecond=this.value[this.options.utc?"getUTCMilliseconds":"getMilliseconds"](),this.milliseconds=this.value.getTime(),this.second=this.value[this.options.utc?"getUTCSeconds":"getSeconds"](),this.minute=this.value[this.options.utc?"getUTCMinutes":"getMinutes"](),this.hour=this.value[this.options.utc?"getUTCHours":"getHours"](),this.day=this.value[this.options.utc?"getUTCDate":"getDate"](),this.dayWeek=this.value[this.options.utc?"getUTCDay":"getDay"](),this.month=this.value[this.options.utc?"getUTCMonth":"getMonth"]()+1,this.year=this.value[this.options.utc?"getUTCFullYear":"getFullYear"](),this.dayYear=Math.floor((this.milliseconds-Number(new Date(this.year,0,0)))/1e3/60/60/24),this.weekValue())}},{key:"weekValue",value:function(){var e=new Date(this.year,0,1);return e.setDate(e.getDate()+(1-e.getDay()%7)),this.week=Math.round((Number(this.value)-Number(e))/6048e5)+1,this.week}},{key:"months",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.months)||g}},{key:"monthsAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.monthsAbr)||b}},{key:"daysWeek",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeek)||m}},{key:"daysWeekAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeekAbr)||p}},{key:"valid",get:function(){return void 0===this.value_||this.value_ instanceof Date||this.value_ instanceof t||(e=new Date(this.value_).getTime(),Number.isInteger(e)&&String(e).length>=10&&(new Date(e).getTime()>0||new Date(1e3*e).getTime()>0));var e}},{key:"local",get:function(){if(this.valid)return new t(new Date(this.value.toLocaleString("en-us")))}},{key:"utc",get:function(){return new t(this.value,{utc:!0})}},{key:"iso",get:function(){if(this.valid)return this.value.toISOString()}},{key:"daysInMonth",get:function(){return new Date(this.year,this.month,0).getDate()}},{key:"weeksInYear",get:function(){var e=new Date(this.year,0,1),t=1===new Date(this.year,1,29).getMonth();return 4===e.getDay()||t&&3===e.getDay()?53:52}},{key:"valueOf",get:function(){return this.milliseconds}},{key:"unix",get:function(){if(this.valid)return Math.floor(this.value.getTime()/1e3)}},{key:"timezone",value:function(e){if(this.valid&&e)return new t(this.value.toLocaleString("en-us",{timeZone:e}))}}],[{key:"utc",get:function(){return new t(new Date,{utc:!0})}},{key:"daysInMonth",get:function(){return(new t).daysInMonth}},{key:"valueOf",get:function(){return(new t).valueOf}},{key:"unix",get:function(){return(new t).unix}},{key:"milliseconds",get:function(){return(new t).milliseconds}},{key:"iso",get:function(){return(new t).iso}},{key:"amauidate",get:function(){return new t}},{key:"local",get:function(){return(new t).local}}]),t}();function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var O=function(){function t(){e(this,t)}return n(t,null,[{key:"cookie",get:function(){return s("browser")&&window.document.cookie||""}},{key:"cookies",get:function(){if(s("browser")){var e,n={},r=j(t.cookie.split("; "));try{for(r.s();!(e=r.n()).done;){var o=e.value.split("=");n[o[0]]=h(o.slice(1).join("="))}}catch(e){r.e(e)}finally{r.f()}return n}}},{key:"get",value:function(e){if(s("browser"))return t.cookies[e]}},{key:"add",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:364,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/";if(s("browser")){var o=e,i=u("string",t)?t:y(t),a=w(n,"day").utc;document.cookie="".concat(o,"=").concat(i,"; expires=").concat(a,"; path=").concat(r)}}},{key:"remove",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";if(s("browser")){var r=t.cookies;r.hasOwnProperty(e)&&(document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(n))}}}]),t}();return O})); |
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
47840