diff --git a/.eslintrc.json b/.eslintrc.json index 9cc74dc..fbc0c5c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,6 +41,7 @@ "one-var": [2, { "uninitialized": "always" }], + "one-var-declaration-per-line": [2, "initializations"], "max-len": 0, "no-param-reassign": 0, "no-use-before-define": 0, diff --git a/CHANGELOG.md b/CHANGELOG.md index 241a3f7..8fece60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ +## 1.1.0 + +### Improvements + +1. Upgraded to Webpack 3, ESLint 4. +1. Refactored and decoupled inner modules. + ## 1.0.1 ### Features diff --git a/README.md b/README.md index f495c82..749b439 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ -# cookie-storage +# Cookie Storage A lightweight JavaScript UMD to handle cookies through Web Storage Interface. This library manages an adapter that implements an interface similar to -[Web Storage] to normalize the API for [document.cookie], with the advantage -that the values are stored as **JSON**, allowing to save and retrieve `Object` -and `Array`, which is not the default behavior when using the native +[Web Storage] to normalize the API for [document.cookie] to be as +[window.localStorage], with the advantage that values are stored as +**JSON**, allowing to save and retrieve values of type `Object` and +`Array`, which is not the default behavior when using the native `document.cookie`. If you want a more robust mechanism to store data in `cookies`, `localStorage`, -`sessionStorage`, `memoryStorage`, you may pay attention to [proxy-storage]. +`sessionStorage`, or `memoryStorage`, you should try [proxy-storage]. ## Content @@ -22,7 +23,7 @@ If you want a more robust mechanism to store data in `cookies`, `localStorage`, ## Installing the library -To include this library into your package manager with `npm` or `yarn` +To include this library into your package manager with `npm` or `yarn`, run: ```shell # with npm @@ -41,7 +42,7 @@ $ yarn add cookie-storage-v2 - + ``` In the above case, [`cookieStorage`](#api) is included as a global object @@ -61,13 +62,13 @@ or [AMD RequireJS]. ### CommonJS ```javascript -var cookies = require('cookie-storage-v2'); +var cookieStorage = require('cookie-storage-v2'); ``` ### ES2015 Export ```javascript -import cookies from 'cookie-storage-v2'; +import cookieStorage from 'cookie-storage-v2'; ``` ### AMD @@ -80,14 +81,16 @@ requirejs.config({ 'cookie-storage': '/cookie-storage.min' } }); -require(['cookie-storage'], function(cookies) { - cookies.setItem('testing', [1,2,3,5,8,13], { +require(['cookie-storage'], function(cookieStorage) { + cookieStorage.setItem('testing', [1,2,3,5,8,13], { expires: { minutes: 10 }, }); }); ``` -See an example with RequireJS here: http://jsfiddle.net/FdKTn/72/ +See an example with RequireJS here: http://jsfiddle.net/FdKTn/76/ + +[☗ Back to Index](#content) # API @@ -96,7 +99,7 @@ The exposed `cookieStorage` object is an instance of the internal [Web Storage] interface. It can store and retrieve **primitive**, `Object` and `Array` values, thanks to `JSON.stringify`. -The inherited members of the prototype are: +The prototype members are: - **`setItem`**`(key, value, options)`: stores a `value` given a `key` name.
The `options` parameter is optional and describes the metadata passed @@ -113,11 +116,11 @@ configures the way how the cookie is stored. It has the following properties: - `domain`_`{string}`_: the domain or subdomain where the cookie will be valid. - `path`_`{string}`_: relative path where the cookie is valid. _Default `"/"`_ -- `secure`_`{boolean}`_: if provided, sets a secure cookie (HTTPS). +- `secure`_`{boolean}`_: if provided, creates a secure cookie over HTTPS. - `expires`_`{Date, object}`_: the expiration date of the cookie. You can pass an object describing the expiration: - `date`_`{Date}`_: if provided, this date will be applied, otherwise the - current date will be used. + current date is used. - `minutes`_`{number}`_: minutes to add / subtract - `hours`_`{number}`_: hours to add / subtract - `days`_`{number}`_: days to add / subtract @@ -158,19 +161,18 @@ cookieStorage.setItem('testing3', 3, { }); ``` -**Important**: Take into account that if you want to modify or remove a cookie -that was created with a specific `path` or `domain` / subdomain, you need to -explicitate the domain attribute in the `options` when calling -`setItem(key, value, options)` or `removeItem(key, options)`. - -![cookies](https://www.dropbox.com/s/wlvgm0t8xc07me1/cookies-metadata.gif?dl=1) +**Important**: Take into account that if you want to **modify** or **remove** +a cookie that was created under specific `path` or `domain` (subdomain), you +need to specify the `domain` or `path` attributes in the `options` parameter +when calling `setItem(key, value, options)` or `removeItem(key, options)`. If you have created the cookie with **cookieStorage**, it will handle the -metadata internally, so that you can call `removeItem(key)` safely. +metadata internally, so that you can call `removeItem(key)` with no more +arguments. + +![cookies](https://www.dropbox.com/s/wlvgm0t8xc07me1/cookies-metadata.gif?dl=1) -But if you want to modify / remove a cookie that was created from another page, -then you should provide the metadata as `path` or `domain` in order to match -the right cookie: +Otherwise you need to provide the metadata `path` or `domain` as mentioned before: ```javascript // change the value of an external cookie in /answers @@ -186,41 +188,46 @@ cookieStorage.removeItem('optimizelyEndUserId', { ## Looping the storage -You can loop over the items in the `cookieStorage` instance, -but it is not a good practice, see the Important note below. +You can loop over the items in the `storage` instance, +but it is not recommended to rely on it because navigable +items in the `storage` instance are not synchronized with +external changes, for example, a cookie has expired, or a +cookie/localStorage element was created/deleted from another +page with the same domain/subdomain. ```javascript -cookieStorage.setItem('test1', 1); -cookieStorage.setItem('test2', 2); +const sessionStore = new WebStorage('sessionStorage'); -// loop over the storage object -Object.keys(cookieStorage).forEach((key) => { - console.log(key, cookieStorage[key]); +sessionStore.setItem('test1', 1); +sessionStore.setItem('test2', 2); + +// loop over the storage object (not recommended) +Object.keys(sessionStore).forEach((key) => { + console.log(key, sessionStore[key]); }); -// or... -for (let key in cookieStorage) { - console.log(key, cookieStorage[key]); +// or this way (not recommended) ... +for (let key in sessionStore) { + console.log(key, sessionStore[key]); } ``` -**Important**: Although you can loop over the storage items, it is -recommended to use the API methods instead, this is because navigable -items in the storage instance are not synchronized for external changes, -e.g. a domain cookie was created from another page, or a cookie has expired. +It is also applied not only when reading, but also when writing to storage: ```javascript -// not recommended, they are not synchronized +// not recommended: not synchronized var title = cookieStorage['title']; var session = cookieStorage.sessionId; cookieStorage['sessionId'] = 'E6URTG5'; -// the good way, it tracks external changes +// good practice: sync external changes var title = cookieStorage.getItem('title'); var session = cookieStorage.getItem('sessionId'); cookieStorage.setItem('sessionId', 'E6URTG5'); ``` +[☗ Back to API](#api) + ## Polyfills This library is written using some of the new ES5/ES6 features. If you have @@ -257,6 +264,8 @@ to the url, for example: Read the list of available features: [Features and Browsers Supported](https://polyfill.io/v2/docs/features/). +[☗ Back to Index](#content) + ## Versioning This projects adopts the [Semantic Versioning](http://semver.org/) @@ -272,6 +281,8 @@ Given a version number MAJOR.MINOR.PATCH, increment the: 1. MINOR version when you add functionality in a backwards-compatible manner. 1. PATCH version when you make backwards-compatible bug fixes. +[☗ Back to Index](#content) + ## Issues To report an issue and keep traceability of bug-fixes, please report to: @@ -291,9 +302,10 @@ repository. See [LICENSE](LICENSE) file for more information. -[proxy-storage]: https://github.com/jherax/proxy-storage [Web Storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage [document.cookie]: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie +[window.localStorage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage +[proxy-storage]: https://github.com/jherax/proxy-storage [UMD]: http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/ [CommonJS]: https://blog.risingstack.com/node-js-at-scale-module-system-commonjs-require/ [ES2015 Export]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export diff --git a/dist/cookie-storage.js b/dist/cookie-storage.js index 72d957e..5cd32c4 100644 --- a/dist/cookie-storage.js +++ b/dist/cookie-storage.js @@ -1,4 +1,4 @@ -/*! cookieStorage@v1.0.2. Jherax 2017. Visit https://github.com/jherax/cookie-storage */ +/*! cookieStorage@v1.1.0. Jherax 2017. Visit https://github.com/jherax/cookie-storage */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -44,9 +44,6 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ -/******/ // identity function for calling harmony imports with the correct context -/******/ __webpack_require__.i = function(value) { return value; }; -/******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { @@ -74,7 +71,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ return __webpack_require__(__webpack_require__.s = 1); /******/ }) /************************************************************************/ /******/ ([ @@ -88,9 +85,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isObject = isObject; -exports.alterDate = alterDate; -exports.setProperty = setProperty; exports.checkEmpty = checkEmpty; +exports.setProperty = setProperty; +exports.tryParse = tryParse; /** * Determines whether a value is a plain object. * @@ -102,30 +99,16 @@ function isObject(value) { } /** - * Adds or subtracts date portions to the given date and returns the new date. - * - * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * Validates if the key is not empty. + * (null, undefined or empty string) * - * @param {object} options: It contains the date parts to add or remove, and can have the following properties: - * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. - * - {number} minutes: minutes to add/subtract - * - {number} hours: hours to add/subtract - * - {number} days: days to add/subtract - * - {number} months: months to add/subtract - * - {number} years: years to add/subtract - * @return {Date} + * @param {string} key: keyname of an element in the storage mechanism + * @return {void} */ -function alterDate() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var opt = Object.assign({}, options); - var d = opt.date instanceof Date ? opt.date : new Date(); - if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); - if (+opt.hours) d.setHours(d.getHours() + opt.hours); - if (+opt.days) d.setDate(d.getDate() + opt.days); - if (+opt.months) d.setMonth(d.getMonth() + opt.months); - if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); - return d; +function checkEmpty(key) { + if (key == null || key === '') { + throw new Error('The key provided can not be empty'); + } } /** @@ -149,16 +132,19 @@ function setProperty(obj, name, value) { } /** - * Validates if the key is not empty. - * (null, undefined or empty string) + * Try to parse a value from JSON. * - * @param {string} key: keyname of an element in the storage mechanism - * @return {void} + * @param {string} value: the value to parse + * @return {any} */ -function checkEmpty(key) { - if (key == null || key === '') { - throw new Error('The key provided can not be empty'); +function tryParse(value) { + var parsed = void 0; + try { + parsed = JSON.parse(value); + } catch (e) { + parsed = value; } + return parsed; } /***/ }), @@ -168,199 +154,17 @@ function checkEmpty(key) { "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _utils = __webpack_require__(0); - -/** - * @private - * - * Proxy for document.cookie - * - * @see - * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie - * - * @type {object} - */ -var $cookie = { - get: function get() { - return document.cookie; - }, - set: function set(value) { - document.cookie = value; - }, - data: {} }; - -/** - * @private - * - * Builds the expiration for the cookie. - * - * @see utils.alterDate(options) - * - * @param {Date|object} date: the expiration date - * @return {string} - */ -function buildExpirationString(date) { - var expires = date instanceof Date ? (0, _utils.alterDate)({ date: date }) : (0, _utils.alterDate)(date); - return expires.toUTCString(); -} - -/** - * @private - * - * Builds the string for the cookie metadata. - * - * @param {string} key: name of the metadata - * @param {object} data: metadata of the cookie - * @return {string} - */ -function buildMetadataFor(key, data) { - if (!data[key]) return ''; - return ';' + key + '=' + data[key]; -} - -/** - * @private - * - * Builds the whole string for the cookie metadata. - * - * @param {object} data: metadata of the cookie - * @return {string} - */ -function formatMetadata(data) { - var expires = buildMetadataFor('expires', data); - var domain = buildMetadataFor('domain', data); - var path = buildMetadataFor('path', data); - var secure = data.secure ? ';secure' : ''; - return '' + expires + domain + path + secure; -} - -/** - * @private - * - * Finds an element in the array. - * - * @param {string} cookie: key=value - * @return {boolean} - */ -function findCookie(cookie) { - var nameEQ = this.toString(); - // prevent leading spaces before the key - return cookie.trim().indexOf(nameEQ) === 0; -} - -/** - * @private - * - * Create, read, and delete elements from document.cookie, - * and implements the Web Storage interface. - * - * @return {object} - */ -function cookieStorage() { - var api = { - setItem: function setItem(key, value, options) { - options = Object.assign({ path: '/' }, options); - // keep track of the metadata associated to the cookie - $cookie.data[key] = { path: options.path }; - var metadata = $cookie.data[key]; - if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) { - metadata.expires = buildExpirationString(options.expires); - } - if (options.domain && typeof options.domain === 'string') { - metadata.domain = options.domain.trim(); - } - if (options.secure === true) metadata.secure = true; - var cookie = key + '=' + encodeURIComponent(value) + formatMetadata(metadata); - // TODO: should encodeURIComponent(key) ? - $cookie.set(cookie); - }, - getItem: function getItem(key) { - var value = null; - var nameEQ = key + '='; - var cookie = $cookie.get().split(';').find(findCookie, nameEQ); - if (cookie) { - // prevent leading spaces before the key name - value = cookie.trim().substring(nameEQ.length, cookie.length); - value = decodeURIComponent(value); - } - if (value === null) delete $cookie.data[key]; - return value; - }, - removeItem: function removeItem(key, options) { - var metadata = Object.assign({}, $cookie.data[key], options); - metadata.expires = { days: -1 }; - api.setItem(key, '', metadata); - delete $cookie.data[key]; - }, - clear: function clear() { - var key = void 0, - indexEQ = void 0; // eslint-disable-line - $cookie.get().split(';').forEach(function (cookie) { - indexEQ = cookie.indexOf('='); - if (indexEQ > -1) { - key = cookie.substring(0, indexEQ); - // prevent leading spaces before the key - api.removeItem(key.trim()); - } - }); - } - }; - - return initialize(api); -} - -/** - * @private - * - * Copy the current items in the cookie storage. - * - * @param {object} api: the storage mechanism to initialize - * @return {object} - */ -function initialize(api) { - // sets API members to read-only and non-enumerable - for (var prop in api) { - // eslint-disable-line - (0, _utils.setProperty)(api, prop); - } - // copies all existing elements in the storage - $cookie.get().split(';').forEach(function (cookie) { - var index = cookie.indexOf('='); - var key = cookie.substring(0, index).trim(); - var value = cookie.substring(index + 1).trim(); - if (key) api[key] = decodeURIComponent(value); - }); - return api; -} - -/** - * @public API - */ -exports.default = cookieStorage(); -module.exports = exports['default']; - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _cookieStorage = __webpack_require__(1); +var _utils = __webpack_require__(0); -var _cookieStorage2 = _interopRequireDefault(_cookieStorage); +var _cookieStorage = __webpack_require__(2); -var _utils = __webpack_require__(0); +var _cookieStorage2 = _interopRequireDefault(_cookieStorage); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -373,39 +177,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * * @type {RegExp} */ -var bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i; - -/** - * @private - * - * Try to parse a value - * - * @param {string} value: the value to parse - * @return {any} - */ -function tryParse(value) { - var parsed = void 0; - try { - parsed = JSON.parse(value); - } catch (e) { - parsed = value; - } - return parsed; -} +var BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i; /** * @private * - * Copies all existing keys in the cookieStorage. + * Copies all existing keys in the storage. * - * @param {CookieStorage} obj: the object to where copy the keys + * @param {CookieStorage} instance: the object to where copy the keys * @param {object} storage: the storage mechanism - * @return {void} + * @return {object} */ -function copyKeys(obj, storage) { +function copyKeys(instance, storage) { Object.keys(storage).forEach(function (key) { - obj[key] = tryParse(storage[key]); + instance[key] = (0, _utils.tryParse)(storage[key]); }); + return instance; } /** @@ -421,7 +208,6 @@ function copyKeys(obj, storage) { */ var CookieStorage = function () { - /** * Creates an instance of CookieStorage. * @@ -438,7 +224,7 @@ var CookieStorage = function () { * * @param {string} key: keyname of the storage * @param {any} value: data to save in the storage - * @param {object} options: additional options for cookieStorage + * @param {object} options: additional options for cookieStore * @return {void} * * @memberOf CookieStorage @@ -449,7 +235,7 @@ var CookieStorage = function () { key: 'setItem', value: function setItem(key, value, options) { (0, _utils.checkEmpty)(key); - if (bannedKeys.test(key)) { + if (BANNED_KEYS.test(key)) { throw new Error('The key is a reserved word, therefore not allowed'); } this[key] = value; @@ -477,10 +263,11 @@ var CookieStorage = function () { (0, _utils.checkEmpty)(key); var value = _cookieStorage2.default.getItem(key); if (value == null) { + // null or undefined delete this[key]; value = null; } else { - value = tryParse(value); + value = (0, _utils.tryParse)(value); this[key] = value; } return value; @@ -490,7 +277,7 @@ var CookieStorage = function () { * Deletes a key from the storage. * * @param {string} key: keyname of the storage - * @param {object} options: additional options for cookieStorage + * @param {object} options: additional options for cookieStore * @return {void} * * @memberOf CookieStorage @@ -549,6 +336,245 @@ var CookieStorage = function () { exports.default = new CookieStorage(); module.exports = exports['default']; +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _utils = __webpack_require__(0); + +var _formatMetadata = __webpack_require__(3); + +var _formatMetadata2 = _interopRequireDefault(_formatMetadata); + +var _expirationDate = __webpack_require__(4); + +var _expirationDate2 = _interopRequireDefault(_expirationDate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * @private + * + * Proxy for document.cookie + * + * @see + * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie + * + * @type {object} + */ +var $cookie = { + get: function get() { + return document.cookie; + }, + set: function set(value) { + document.cookie = value; + }, + data: {} // metadata associated to the cookies +}; + +/** + * @private + * + * Finds an element in the array. + * + * @param {string} cookie: key=value + * @return {boolean} + */ +function findCookie(cookie) { + var nameEQ = this.toString(); + // prevent leading spaces before the key + return cookie.trim().indexOf(nameEQ) === 0; +} + +/** + * @public + * + * Create, read, and delete elements from document.cookie, + * and implements the Web Storage interface. + * + * @return {object} + */ +function cookieStorage() { + var api = { + setItem: function setItem(key, value, options) { + options = Object.assign({ path: '/' }, options); + // keep track of the metadata associated to the cookie + $cookie.data[key] = { path: options.path }; + var metadata = $cookie.data[key]; + if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) { + metadata.expires = (0, _expirationDate2.default)(options.expires); + } + if (options.domain && typeof options.domain === 'string') { + metadata.domain = options.domain.trim(); + } + if (options.secure === true) metadata.secure = true; + var cookie = key + '=' + encodeURIComponent(value) + (0, _formatMetadata2.default)(metadata); + // TODO: should encodeURIComponent(key) ? + $cookie.set(cookie); + }, + getItem: function getItem(key) { + var value = null; + var nameEQ = key + '='; + var cookie = $cookie.get().split(';').find(findCookie, nameEQ); + if (cookie) { + // prevent leading spaces before the key name + value = cookie.trim().substring(nameEQ.length, cookie.length); + value = decodeURIComponent(value); + } + if (value === null) delete $cookie.data[key]; + return value; + }, + removeItem: function removeItem(key, options) { + var metadata = Object.assign({}, $cookie.data[key], options); + metadata.expires = { days: -1 }; + api.setItem(key, '', metadata); + delete $cookie.data[key]; + }, + clear: function clear() { + var key = void 0, + indexEQ = void 0; + $cookie.get().split(';').forEach(function (cookie) { + indexEQ = cookie.indexOf('='); + if (indexEQ > -1) { + key = cookie.substring(0, indexEQ); + // prevent leading spaces before the key + api.removeItem(key.trim()); + } + }); + } + }; + + return initialize(api); +} + +/** + * @private + * + * Copy the current items in the cookie storage. + * + * @param {object} api: the storage mechanism to initialize + * @return {object} + */ +function initialize(api) { + // sets API members to read-only and non-enumerable + for (var prop in api) { + // eslint-disable-line + (0, _utils.setProperty)(api, prop); + } + // copies all existing elements in the storage + $cookie.get().split(';').forEach(function (cookie) { + var index = cookie.indexOf('='); + var key = cookie.substring(0, index).trim(); + var value = cookie.substring(index + 1).trim(); + if (key) api[key] = decodeURIComponent(value); + }); + return api; +} + +/** + * @public API + */ +exports.default = cookieStorage(); +module.exports = exports['default']; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = formatMetadata; +/** + * @private + * + * Builds the string for the cookie metadata. + * + * @param {string} key: name of the metadata + * @param {object} data: metadata of the cookie + * @return {string} + */ +function buildMetadataFor(key, data) { + if (!data[key]) return ''; + return ';' + key + '=' + data[key]; +} + +/** + * Builds the whole string for the cookie metadata. + * + * @param {object} data: metadata of the cookie + * @return {string} + */ +function formatMetadata(data) { + var expires = buildMetadataFor('expires', data); + var domain = buildMetadataFor('domain', data); + var path = buildMetadataFor('path', data); + var secure = data.secure ? ';secure' : ''; + return '' + expires + domain + path + secure; +} +module.exports = exports['default']; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = buildExpiration; +/** + * @private + * + * Adds or subtracts date portions to the given date and returns the new date. + * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * + * @param {object} options: It contains the date parts to add or remove, and can have the following properties: + * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. + * - {number} minutes: minutes to add/subtract + * - {number} hours: hours to add/subtract + * - {number} days: days to add/subtract + * - {number} months: months to add/subtract + * - {number} years: years to add/subtract + * @return {Date} + */ +function alterDate() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var opt = Object.assign({}, options); + var d = opt.date instanceof Date ? opt.date : new Date(); + if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); + if (+opt.hours) d.setHours(d.getHours() + opt.hours); + if (+opt.days) d.setDate(d.getDate() + opt.days); + if (+opt.months) d.setMonth(d.getMonth() + opt.months); + if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); + return d; +} + +/** + * Builds the expiration for the cookie. + * + * @param {Date|object} date: the expiration date + * @return {string} + */ +function buildExpiration(date) { + var expires = date instanceof Date ? alterDate({ date: date }) : alterDate(date); + return expires.toUTCString(); +} +module.exports = exports["default"]; + /***/ }) /******/ ]); }); \ No newline at end of file diff --git a/dist/cookie-storage.min.js b/dist/cookie-storage.min.js index 2f54242..967e6d7 100644 --- a/dist/cookie-storage.min.js +++ b/dist/cookie-storage.min.js @@ -1,3 +1,3 @@ -/*! cookieStorage@v1.0.2. Jherax 2017. Visit https://github.com/jherax/cookie-storage */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.cookieStorage=t():e.cookieStorage=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),n=t.date instanceof Date?t.date:new Date;return+t.minutes&&n.setMinutes(n.getMinutes()+t.minutes),+t.hours&&n.setHours(n.getHours()+t.hours),+t.days&&n.setDate(n.getDate()+t.days),+t.months&&n.setMonth(n.getMonth()+t.months),+t.years&&n.setFullYear(n.getFullYear()+t.years),n}function i(e,t,n){var r={configurable:!1,enumerable:!1,writable:!1};void 0!==n&&(r.value=n),Object.defineProperty(e,t,r)}function u(e){if(null==e||""===e)throw new Error("The key provided can not be empty")}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=r,t.alterDate=o,t.setProperty=i,t.checkEmpty=u},function(e,t,n){"use strict";function r(e){return(e instanceof Date?(0,c.alterDate)({date:e}):(0,c.alterDate)(e)).toUTCString()}function o(e,t){return t[e]?";"+e+"="+t[e]:""}function i(e){return""+o("expires",e)+o("domain",e)+o("path",e)+(e.secure?";secure":"")}function u(e){var t=this.toString();return 0===e.trim().indexOf(t)}function a(e){for(var t in e)(0,c.setProperty)(e,t);return s.get().split(";").forEach(function(t){var n=t.indexOf("="),r=t.substring(0,n).trim(),o=t.substring(n+1).trim();r&&(e[r]=decodeURIComponent(o))}),e}Object.defineProperty(t,"__esModule",{value:!0});var c=n(0),s={get:function(){return document.cookie},set:function(e){document.cookie=e},data:{}};t.default=function(){var e={setItem:function(e,t,n){n=Object.assign({path:"/"},n),s.data[e]={path:n.path};var o=s.data[e];((0,c.isObject)(n.expires)||n.expires instanceof Date)&&(o.expires=r(n.expires)),n.domain&&"string"==typeof n.domain&&(o.domain=n.domain.trim()),!0===n.secure&&(o.secure=!0);var u=e+"="+encodeURIComponent(t)+i(o);s.set(u)},getItem:function(e){var t=null,n=e+"=",r=s.get().split(";").find(u,n);return r&&(t=r.trim().substring(n.length,r.length),t=decodeURIComponent(t)),null===t&&delete s.data[e],t},removeItem:function(t,n){var r=Object.assign({},s.data[t],n);r.expires={days:-1},e.setItem(t,"",r),delete s.data[t]},clear:function(){var t=void 0,n=void 0;s.get().split(";").forEach(function(r){(n=r.indexOf("="))>-1&&(t=r.substring(0,n),e.removeItem(t.trim()))})}};return a(e)}(),e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=void 0;try{t=JSON.parse(e)}catch(n){t=e}return t}function i(e,t){Object.keys(t).forEach(function(n){e[n]=o(t[n])})}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n-1&&(t=r.substring(0,n),e.removeItem(t.trim()))})}};return u(e)}(),e.exports=t.default},function(e,t,n){"use strict";function r(e,t){return t[e]?";"+e+"="+t[e]:""}function o(e){return""+r("expires",e)+r("domain",e)+r("path",e)+(e.secure?";secure":"")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o,e.exports=t.default},function(e,t,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),n=t.date instanceof Date?t.date:new Date;return+t.minutes&&n.setMinutes(n.getMinutes()+t.minutes),+t.hours&&n.setHours(n.getHours()+t.hours),+t.days&&n.setDate(n.getDate()+t.days),+t.months&&n.setMonth(n.getMonth()+t.months),+t.years&&n.setFullYear(n.getFullYear()+t.years),n}function o(e){return r(e instanceof Date?{date:e}:e).toUTCString()}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o,e.exports=t.default}])}); //# sourceMappingURL=cookie-storage.min.map \ No newline at end of file diff --git a/dist/cookie-storage.min.map b/dist/cookie-storage.min.map index 3441c26..0439418 100644 --- a/dist/cookie-storage.min.map +++ b/dist/cookie-storage.min.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///cookie-storage.min.js","webpack:///webpack/bootstrap 89333130a60bc46c0471","webpack:///./src/utils.js","webpack:///./src/cookie-storage.js","webpack:///./src/main.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","toString","alterDate","options","arguments","length","undefined","opt","assign","date","Date","minutes","setMinutes","getMinutes","hours","setHours","getHours","days","setDate","getDate","months","setMonth","getMonth","years","setFullYear","getFullYear","setProperty","obj","descriptor","writable","checkEmpty","key","Error","buildExpirationString","_utils","toUTCString","buildMetadataFor","data","formatMetadata","secure","findCookie","cookie","nameEQ","trim","indexOf","initialize","api","prop","$cookie","split","forEach","index","substring","decodeURIComponent","document","set","default","setItem","path","metadata","expires","domain","encodeURIComponent","getItem","find","removeItem","clear","indexEQ","_classCallCheck","instance","Constructor","TypeError","tryParse","parsed","JSON","parse","e","copyKeys","storage","keys","_createClass","defineProperties","target","props","protoProps","staticProps","_cookieStorage","_cookieStorage2","bannedKeys","CookieStorage","test","stringify","_this"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,cAAAD,IAEAD,EAAA,cAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EA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,SInXDiD,EAAKjD,EAAOqB,GAElB,IADA,EAAA+B,EAAAJ,YAAWC,GACPyD,EAAWE,KAAK3D,GAClB,KAAM,IAAIC,OAAM,oDAElB5D,MAAK2D,GAAOjD,EAES,gBAAVA,KAAoBA,EAAQ4F,KAAKiB,UAAU7G,IACtDyG,EAAA/B,QAAQC,QAAQ1B,EAAKjD,EAAOqB,GAEC,OAAzBoF,EAAA/B,QAAQO,QAAQhC,UACX3D,MAAK2D,MJiYdA,IAAK,UACLjD,MAAO,SItXDiD,IACN,EAAAG,EAAAJ,YAAWC,EACX,IAAIjD,GAAQyG,EAAA/B,QAAQO,QAAQhC,EAQ5B,OAPa,OAATjD,SACKV,MAAK2D,GACZjD,EAAQ,OAERA,EAAQ0F,EAAS1F,GACjBV,KAAK2D,GAAOjD,GAEPA,KJoYPiD,IAAK,aACLjD,MAAO,SIzXEiD,EAAK5B,IACd,EAAA+B,EAAAJ,YAAWC,SACJ3D,MAAK2D,GACZwD,EAAA/B,QAAQS,WAAWlC,EAAK5B,MJqYxB4B,IAAK,QACLjD,MAAO,WI5XD,GAAA8G,GAAAxH,IACNe,QAAO4F,KAAK3G,MAAM8E,QAAQ,SAACnB,SAClB6D,GAAK7D,IACX3D,MACHmH,EAAA/B,QAAQU,WJ0YRnC,IAAK,SACLxC,IAAK,WIhYL,MAAOJ,QAAO4F,KAAK3G,MAAMiC,WJqYpBoF,gBAQTzH,GAAQwF,QIrYO,GAAIiC,eJsYnBxH,EAAOD,QAAUA,EAAiB","file":"cookie-storage.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cookieStorage\"] = factory();\n\telse\n\t\troot[\"cookieStorage\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cookieStorage\"] = factory();\n\telse\n\t\troot[\"cookieStorage\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isObject = isObject;\nexports.alterDate = alterDate;\nexports.setProperty = setProperty;\nexports.checkEmpty = checkEmpty;\n/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nfunction alterDate() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n var opt = Object.assign({}, options);\n var d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nfunction setProperty(obj, name, value) {\n var descriptor = {\n configurable: false,\n enumerable: false,\n writable: false\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nfunction checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _utils = __webpack_require__(0);\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nvar $cookie = {\n get: function get() {\n return document.cookie;\n },\n set: function set(value) {\n document.cookie = value;\n },\n data: {} };\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n var expires = date instanceof Date ? (0, _utils.alterDate)({ date: date }) : (0, _utils.alterDate)(date);\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return ';' + key + '=' + data[key];\n}\n\n/**\n * @private\n *\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction formatMetadata(data) {\n var expires = buildMetadataFor('expires', data);\n var domain = buildMetadataFor('domain', data);\n var path = buildMetadataFor('path', data);\n var secure = data.secure ? ';secure' : '';\n return '' + expires + domain + path + secure;\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n var nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @private\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n var api = {\n setItem: function setItem(key, value, options) {\n options = Object.assign({ path: '/' }, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = { path: options.path };\n var metadata = $cookie.data[key];\n if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n var cookie = key + '=' + encodeURIComponent(value) + formatMetadata(metadata);\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n getItem: function getItem(key) {\n var value = null;\n var nameEQ = key + '=';\n var cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n removeItem: function removeItem(key, options) {\n var metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = { days: -1 };\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n clear: function clear() {\n var key = void 0,\n indexEQ = void 0; // eslint-disable-line\n $cookie.get().split(';').forEach(function (cookie) {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n }\n };\n\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n (0, _utils.setProperty)(api, prop);\n }\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach(function (cookie) {\n var index = cookie.indexOf('=');\n var key = cookie.substring(0, index).trim();\n var value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n return api;\n}\n\n/**\n * @public API\n */\nexports.default = cookieStorage();\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _cookieStorage = __webpack_require__(1);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nvar _utils = __webpack_require__(0);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nvar bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n var parsed = void 0;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the cookieStorage.\n *\n * @param {CookieStorage} obj: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(obj, storage) {\n Object.keys(storage).forEach(function (key) {\n obj[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @private\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\n\nvar CookieStorage = function () {\n\n /**\n * Creates an instance of CookieStorage.\n *\n * @memberOf CookieStorage\n */\n function CookieStorage() {\n _classCallCheck(this, CookieStorage);\n\n copyKeys(this, _cookieStorage2.default);\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n\n _createClass(CookieStorage, [{\n key: 'setItem',\n value: function setItem(key, value, options) {\n (0, _utils.checkEmpty)(key);\n if (bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n _cookieStorage2.default.setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (_cookieStorage2.default.getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'getItem',\n value: function getItem(key) {\n (0, _utils.checkEmpty)(key);\n var value = _cookieStorage2.default.getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'removeItem',\n value: function removeItem(key, options) {\n (0, _utils.checkEmpty)(key);\n delete this[key];\n _cookieStorage2.default.removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'clear',\n value: function clear() {\n var _this = this;\n\n Object.keys(this).forEach(function (key) {\n delete _this[key];\n }, this);\n _cookieStorage2.default.clear();\n }\n\n /**\n * Gets the number of data items stored in the storage object.\n *\n * @readonly\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'length',\n get: function get() {\n return Object.keys(this).length;\n }\n }]);\n\n return CookieStorage;\n}();\n\n/**\n * @public API\n */\n\n\nexports.default = new CookieStorage();\nmodule.exports = exports['default'];\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// cookie-storage.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 89333130a60bc46c0471","/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nexport function isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nexport function alterDate(options = {}) {\n const opt = Object.assign({}, options);\n const d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nexport function setProperty(obj, name, value) {\n const descriptor = {\n configurable: false,\n enumerable: false,\n writable: false,\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nexport function checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","import {alterDate, isObject, setProperty} from './utils';\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nconst $cookie = {\n get: () => document.cookie,\n set: (value) => {\n document.cookie = value;\n },\n data: {}, // metadata associated to the cookies\n};\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n const expires = (date instanceof Date ?\n alterDate({date}) :\n alterDate(date)\n );\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return `;${key}=${data[key]}`;\n}\n\n/**\n * @private\n *\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction formatMetadata(data) {\n const expires = buildMetadataFor('expires', data);\n const domain = buildMetadataFor('domain', data);\n const path = buildMetadataFor('path', data);\n const secure = data.secure ? ';secure' : '';\n return `${expires}${domain}${path}${secure}`;\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n const nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @private\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n const api = {\n\n setItem(key, value, options) {\n options = Object.assign({path: '/'}, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = {path: options.path};\n const metadata = $cookie.data[key];\n if (isObject(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n const cookie = `${key}=${encodeURIComponent(value)}${formatMetadata(metadata)}`;\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n\n getItem(key) {\n let value = null;\n const nameEQ = `${key}=`;\n const cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n\n removeItem(key, options) {\n const metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = {days: -1};\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n\n clear() {\n let key, indexEQ; // eslint-disable-line\n $cookie.get().split(';').forEach((cookie) => {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n };\n\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n setProperty(api, prop);\n }\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach((cookie) => {\n const index = cookie.indexOf('=');\n const key = cookie.substring(0, index).trim();\n const value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n return api;\n}\n\n/**\n * @public API\n */\nexport default cookieStorage();\n\n\n\n// WEBPACK FOOTER //\n// ./src/cookie-storage.js","import cookies from './cookie-storage';\nimport {checkEmpty} from './utils';\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nconst bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the cookieStorage.\n *\n * @param {CookieStorage} obj: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(obj, storage) {\n Object.keys(storage).forEach((key) => {\n obj[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @private\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\nclass CookieStorage {\n\n /**\n * Creates an instance of CookieStorage.\n *\n * @memberOf CookieStorage\n */\n constructor() {\n copyKeys(this, cookies);\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n setItem(key, value, options) {\n checkEmpty(key);\n if (bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n cookies.setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (cookies.getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n getItem(key) {\n checkEmpty(key);\n let value = cookies.getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n removeItem(key, options) {\n checkEmpty(key);\n delete this[key];\n cookies.removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n clear() {\n Object.keys(this).forEach((key) => {\n delete this[key];\n }, this);\n cookies.clear();\n }\n\n /**\n * Gets the number of data items stored in the storage object.\n *\n * @readonly\n *\n * @memberOf CookieStorage\n */\n get length() {\n return Object.keys(this).length;\n }\n\n}\n\n/**\n * @public API\n */\nexport default new CookieStorage();\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///cookie-storage.min.js","webpack:///webpack/bootstrap 154f36952f7c5d71e507","webpack:///./src/utils.js","webpack:///./src/main.js","webpack:///./src/cookie-storage.js","webpack:///./src/format-metadata.js","webpack:///./src/expiration-date.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","value","toString","checkEmpty","key","Error","setProperty","obj","descriptor","writable","tryParse","parsed","JSON","parse","e","_classCallCheck","instance","Constructor","TypeError","copyKeys","storage","keys","forEach","_utils","_createClass","defineProperties","target","props","length","protoProps","staticProps","_cookieStorage","_cookieStorage2","default","BANNED_KEYS","CookieStorage","options","test","stringify","setItem","getItem","removeItem","_this","clear","_interopRequireDefault","findCookie","cookie","nameEQ","trim","indexOf","initialize","api","prop","$cookie","split","index","substring","decodeURIComponent","_formatMetadata","_formatMetadata2","_expirationDate","_expirationDate2","document","set","data","assign","path","metadata","expires","Date","domain","secure","encodeURIComponent","find","days","indexEQ","buildMetadataFor","formatMetadata","alterDate","arguments","undefined","opt","date","minutes","setMinutes","getMinutes","hours","setHours","getHours","setDate","getDate","months","setMonth","getMonth","years","setFullYear","getFullYear","buildExpiration","toUTCString"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,cAAAD,IAEAD,EAAA,cAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAV,EAAAiB,EAAA,SAAAtB,GACA,GAAAe,GAAAf,KAAAuB,WACA,WAA2B,MAAAvB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDpB,EAAAuB,EAAA,GAGAvB,IAAAwB,EAAA,KDgBM,SAAU7B,EAAQD,EAASM,GAEjC,YEzEO,SAASyB,GAASC,GACvB,MAAiD,oBAA1Cd,OAAOS,UAAUM,SAAStB,KAAKqB,GAUjC,QAASE,GAAWC,GACzB,GAAW,MAAPA,GAAuB,KAARA,EACjB,KAAM,IAAIC,OAAM,qCAYb,QAASC,GAAYC,EAAKvB,EAAMiB,GACrC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pD,QALKY,EAAIE,SAASpG,EAAEqG,WAAWrG,EAAEsG,aAAeJ,EAAIE,UAC/CF,EAAIK,OAAOvG,EAAEwG,SAASxG,EAAEyG,WAAaP,EAAIK,QACzCL,EAAIP,MAAM3F,EAAE0G,QAAQ1G,EAAE2G,UAAYT,EAAIP,OACtCO,EAAIU,QAAQ5G,EAAE6G,SAAS7G,EAAE8G,WAAaZ,EAAIU,SAC1CV,EAAIa,OAAO/G,EAAEgH,YAAYhH,EAAEiH,cAAgBf,EAAIa,OAC7C/G,EASM,QAASkH,GAAgBf,GAItC,MAFEJ,GADeI,YAAgBb,OACpBa,QACDA,GACGgB,cNgfjB/G,OAAOC,eAAenB,EAAS,cAC7BgC,OAAO,IAEThC,EAAQgE,QMvfgBgE,EN8hBxB/H,EAAOD,QAAUA,EAAiB","file":"cookie-storage.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cookieStorage\"] = factory();\n\telse\n\t\troot[\"cookieStorage\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cookieStorage\"] = factory();\n\telse\n\t\troot[\"cookieStorage\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isObject = isObject;\nexports.checkEmpty = checkEmpty;\nexports.setProperty = setProperty;\nexports.tryParse = tryParse;\n/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nfunction checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nfunction setProperty(obj, name, value) {\n var descriptor = {\n configurable: false,\n enumerable: false,\n writable: false\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Try to parse a value from JSON.\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n var parsed = void 0;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _utils = __webpack_require__(0);\n\nvar _cookieStorage = __webpack_require__(2);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nvar BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Copies all existing keys in the storage.\n *\n * @param {CookieStorage} instance: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {object}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach(function (key) {\n instance[key] = (0, _utils.tryParse)(storage[key]);\n });\n return instance;\n}\n\n/**\n * @private\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\n\nvar CookieStorage = function () {\n /**\n * Creates an instance of CookieStorage.\n *\n * @memberOf CookieStorage\n */\n function CookieStorage() {\n _classCallCheck(this, CookieStorage);\n\n copyKeys(this, _cookieStorage2.default);\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStore\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n\n _createClass(CookieStorage, [{\n key: 'setItem',\n value: function setItem(key, value, options) {\n (0, _utils.checkEmpty)(key);\n if (BANNED_KEYS.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n _cookieStorage2.default.setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (_cookieStorage2.default.getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'getItem',\n value: function getItem(key) {\n (0, _utils.checkEmpty)(key);\n var value = _cookieStorage2.default.getItem(key);\n if (value == null) {\n // null or undefined\n delete this[key];\n value = null;\n } else {\n value = (0, _utils.tryParse)(value);\n this[key] = value;\n }\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStore\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'removeItem',\n value: function removeItem(key, options) {\n (0, _utils.checkEmpty)(key);\n delete this[key];\n _cookieStorage2.default.removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'clear',\n value: function clear() {\n var _this = this;\n\n Object.keys(this).forEach(function (key) {\n delete _this[key];\n }, this);\n _cookieStorage2.default.clear();\n }\n\n /**\n * Gets the number of data items stored in the storage object.\n *\n * @readonly\n *\n * @memberOf CookieStorage\n */\n\n }, {\n key: 'length',\n get: function get() {\n return Object.keys(this).length;\n }\n }]);\n\n return CookieStorage;\n}();\n\n/**\n * @public API\n */\n\n\nexports.default = new CookieStorage();\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _utils = __webpack_require__(0);\n\nvar _formatMetadata = __webpack_require__(3);\n\nvar _formatMetadata2 = _interopRequireDefault(_formatMetadata);\n\nvar _expirationDate = __webpack_require__(4);\n\nvar _expirationDate2 = _interopRequireDefault(_expirationDate);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nvar $cookie = {\n get: function get() {\n return document.cookie;\n },\n set: function set(value) {\n document.cookie = value;\n },\n data: {} // metadata associated to the cookies\n};\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n var nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n var api = {\n setItem: function setItem(key, value, options) {\n options = Object.assign({ path: '/' }, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = { path: options.path };\n var metadata = $cookie.data[key];\n if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) {\n metadata.expires = (0, _expirationDate2.default)(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n var cookie = key + '=' + encodeURIComponent(value) + (0, _formatMetadata2.default)(metadata);\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n getItem: function getItem(key) {\n var value = null;\n var nameEQ = key + '=';\n var cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n removeItem: function removeItem(key, options) {\n var metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = { days: -1 };\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n clear: function clear() {\n var key = void 0,\n indexEQ = void 0;\n $cookie.get().split(';').forEach(function (cookie) {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n }\n };\n\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n (0, _utils.setProperty)(api, prop);\n }\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach(function (cookie) {\n var index = cookie.indexOf('=');\n var key = cookie.substring(0, index).trim();\n var value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n return api;\n}\n\n/**\n * @public API\n */\nexports.default = cookieStorage();\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = formatMetadata;\n/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return ';' + key + '=' + data[key];\n}\n\n/**\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction formatMetadata(data) {\n var expires = buildMetadataFor('expires', data);\n var domain = buildMetadataFor('domain', data);\n var path = buildMetadataFor('path', data);\n var secure = data.secure ? ';secure' : '';\n return '' + expires + domain + path + secure;\n}\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = buildExpiration;\n/**\n * @private\n *\n * Adds or subtracts date portions to the given date and returns the new date.\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nfunction alterDate() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n var opt = Object.assign({}, options);\n var d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Builds the expiration for the cookie.\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpiration(date) {\n var expires = date instanceof Date ? alterDate({ date: date }) : alterDate(date);\n return expires.toUTCString();\n}\nmodule.exports = exports[\"default\"];\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// cookie-storage.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 154f36952f7c5d71e507","/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nexport function isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nexport function checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nexport function setProperty(obj, name, value) {\n const descriptor = {\n configurable: false,\n enumerable: false,\n writable: false,\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Try to parse a value from JSON.\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nexport function tryParse(value) {\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","import {checkEmpty, tryParse} from './utils';\nimport cookieStore from './cookie-storage';\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nconst BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Copies all existing keys in the storage.\n *\n * @param {CookieStorage} instance: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {object}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach((key) => {\n instance[key] = tryParse(storage[key]);\n });\n return instance;\n}\n\n/**\n * @private\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\nclass CookieStorage {\n /**\n * Creates an instance of CookieStorage.\n *\n * @memberOf CookieStorage\n */\n constructor() {\n copyKeys(this, cookieStore);\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStore\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n setItem(key, value, options) {\n checkEmpty(key);\n if (BANNED_KEYS.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n cookieStore.setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (cookieStore.getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n getItem(key) {\n checkEmpty(key);\n let value = cookieStore.getItem(key);\n if (value == null) { // null or undefined\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStore\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n removeItem(key, options) {\n checkEmpty(key);\n delete this[key];\n cookieStore.removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf CookieStorage\n */\n clear() {\n Object.keys(this).forEach((key) => {\n delete this[key];\n }, this);\n cookieStore.clear();\n }\n\n /**\n * Gets the number of data items stored in the storage object.\n *\n * @readonly\n *\n * @memberOf CookieStorage\n */\n get length() {\n return Object.keys(this).length;\n }\n}\n\n/**\n * @public API\n */\nexport default new CookieStorage();\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js","import {isObject, setProperty} from './utils';\nimport formatMetadata from './format-metadata';\nimport buildExpiration from './expiration-date';\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nconst $cookie = {\n get: () => document.cookie,\n set: (value) => {\n document.cookie = value;\n },\n data: {}, // metadata associated to the cookies\n};\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n const nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n const api = {\n\n setItem(key, value, options) {\n options = Object.assign({path: '/'}, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = {path: options.path};\n const metadata = $cookie.data[key];\n if (isObject(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpiration(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n const cookie = `${key}=${encodeURIComponent(value)}${formatMetadata(metadata)}`;\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n\n getItem(key) {\n let value = null;\n const nameEQ = `${key}=`;\n const cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n\n removeItem(key, options) {\n const metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = {days: -1};\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n\n clear() {\n let key, indexEQ;\n $cookie.get().split(';').forEach((cookie) => {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n };\n\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n setProperty(api, prop);\n }\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach((cookie) => {\n const index = cookie.indexOf('=');\n const key = cookie.substring(0, index).trim();\n const value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n return api;\n}\n\n/**\n * @public API\n */\nexport default cookieStorage();\n\n\n\n// WEBPACK FOOTER //\n// ./src/cookie-storage.js","/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return `;${key}=${data[key]}`;\n}\n\n/**\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nexport default function formatMetadata(data) {\n const expires = buildMetadataFor('expires', data);\n const domain = buildMetadataFor('domain', data);\n const path = buildMetadataFor('path', data);\n const secure = data.secure ? ';secure' : '';\n return `${expires}${domain}${path}${secure}`;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/format-metadata.js","/**\n * @private\n *\n * Adds or subtracts date portions to the given date and returns the new date.\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nfunction alterDate(options = {}) {\n const opt = Object.assign({}, options);\n const d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Builds the expiration for the cookie.\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nexport default function buildExpiration(date) {\n const expires = (date instanceof Date ?\n alterDate({date}) :\n alterDate(date));\n return expires.toUTCString();\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/expiration-date.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 84fc290..58ca4ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cookie-storage-v2", - "version": "1.0.2", + "version": "1.1.0", "description": "A lightweight JavaScript UMD to handle cookies through Web Storage Interface", "author": "David Rivera ", "main": "dist/cookie-storage.js", @@ -32,18 +32,18 @@ }, "license": "MIT", "devDependencies": { - "babel-core": "^6.23.1", + "babel-core": "^6.25.0", "babel-eslint": "^7.1.1", - "babel-loader": "^6.4.0", + "babel-loader": "^7.1.1", "babel-plugin-add-module-exports": "^0.2.1", "babel-preset-es2015": "^6.22.0", "babel-preset-stage-2": "^6.22.0", "clean-webpack-plugin": "^0.1.15", - "eslint": "^3.17.1", - "eslint-config-airbnb-base": "^11.1.1", - "eslint-loader": "^1.6.3", - "eslint-plugin-import": "^2.2.0", - "webpack": "^2.2.1" + "eslint": "^4.1.1", + "eslint-config-airbnb-base": "^11.2.0", + "eslint-loader": "^1.8.0", + "eslint-plugin-import": "^2.6.1", + "webpack": "^3.0.0" }, "babel": { "presets": [ diff --git a/src/cookie-storage.js b/src/cookie-storage.js index ca154eb..d70814e 100644 --- a/src/cookie-storage.js +++ b/src/cookie-storage.js @@ -1,4 +1,6 @@ -import {alterDate, isObject, setProperty} from './utils'; +import {isObject, setProperty} from './utils'; +import formatMetadata from './format-metadata'; +import buildExpiration from './expiration-date'; /** * @private @@ -18,54 +20,6 @@ const $cookie = { data: {}, // metadata associated to the cookies }; -/** - * @private - * - * Builds the expiration for the cookie. - * - * @see utils.alterDate(options) - * - * @param {Date|object} date: the expiration date - * @return {string} - */ -function buildExpirationString(date) { - const expires = (date instanceof Date ? - alterDate({date}) : - alterDate(date) - ); - return expires.toUTCString(); -} - -/** - * @private - * - * Builds the string for the cookie metadata. - * - * @param {string} key: name of the metadata - * @param {object} data: metadata of the cookie - * @return {string} - */ -function buildMetadataFor(key, data) { - if (!data[key]) return ''; - return `;${key}=${data[key]}`; -} - -/** - * @private - * - * Builds the whole string for the cookie metadata. - * - * @param {object} data: metadata of the cookie - * @return {string} - */ -function formatMetadata(data) { - const expires = buildMetadataFor('expires', data); - const domain = buildMetadataFor('domain', data); - const path = buildMetadataFor('path', data); - const secure = data.secure ? ';secure' : ''; - return `${expires}${domain}${path}${secure}`; -} - /** * @private * @@ -81,7 +35,7 @@ function findCookie(cookie) { } /** - * @private + * @public * * Create, read, and delete elements from document.cookie, * and implements the Web Storage interface. @@ -97,7 +51,7 @@ function cookieStorage() { $cookie.data[key] = {path: options.path}; const metadata = $cookie.data[key]; if (isObject(options.expires) || options.expires instanceof Date) { - metadata.expires = buildExpirationString(options.expires); + metadata.expires = buildExpiration(options.expires); } if (options.domain && typeof options.domain === 'string') { metadata.domain = options.domain.trim(); @@ -129,7 +83,7 @@ function cookieStorage() { }, clear() { - let key, indexEQ; // eslint-disable-line + let key, indexEQ; $cookie.get().split(';').forEach((cookie) => { indexEQ = cookie.indexOf('='); if (indexEQ > -1) { diff --git a/src/expiration-date.js b/src/expiration-date.js new file mode 100644 index 0000000..8e0166f --- /dev/null +++ b/src/expiration-date.js @@ -0,0 +1,38 @@ +/** + * @private + * + * Adds or subtracts date portions to the given date and returns the new date. + * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * + * @param {object} options: It contains the date parts to add or remove, and can have the following properties: + * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. + * - {number} minutes: minutes to add/subtract + * - {number} hours: hours to add/subtract + * - {number} days: days to add/subtract + * - {number} months: months to add/subtract + * - {number} years: years to add/subtract + * @return {Date} + */ +function alterDate(options = {}) { + const opt = Object.assign({}, options); + const d = opt.date instanceof Date ? opt.date : new Date(); + if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); + if (+opt.hours) d.setHours(d.getHours() + opt.hours); + if (+opt.days) d.setDate(d.getDate() + opt.days); + if (+opt.months) d.setMonth(d.getMonth() + opt.months); + if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); + return d; +} + +/** + * Builds the expiration for the cookie. + * + * @param {Date|object} date: the expiration date + * @return {string} + */ +export default function buildExpiration(date) { + const expires = (date instanceof Date ? + alterDate({date}) : + alterDate(date)); + return expires.toUTCString(); +} diff --git a/src/format-metadata.js b/src/format-metadata.js new file mode 100644 index 0000000..586ac96 --- /dev/null +++ b/src/format-metadata.js @@ -0,0 +1,27 @@ +/** + * @private + * + * Builds the string for the cookie metadata. + * + * @param {string} key: name of the metadata + * @param {object} data: metadata of the cookie + * @return {string} + */ +function buildMetadataFor(key, data) { + if (!data[key]) return ''; + return `;${key}=${data[key]}`; +} + +/** + * Builds the whole string for the cookie metadata. + * + * @param {object} data: metadata of the cookie + * @return {string} + */ +export default function formatMetadata(data) { + const expires = buildMetadataFor('expires', data); + const domain = buildMetadataFor('domain', data); + const path = buildMetadataFor('path', data); + const secure = data.secure ? ';secure' : ''; + return `${expires}${domain}${path}${secure}`; +} diff --git a/src/main.js b/src/main.js index ab36df0..8abf6ce 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,5 @@ -import cookies from './cookie-storage'; -import {checkEmpty} from './utils'; +import {checkEmpty, tryParse} from './utils'; +import cookieStore from './cookie-storage'; /** * @private @@ -8,39 +8,22 @@ import {checkEmpty} from './utils'; * * @type {RegExp} */ -const bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i; +const BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i; /** * @private * - * Try to parse a value + * Copies all existing keys in the storage. * - * @param {string} value: the value to parse - * @return {any} - */ -function tryParse(value) { - let parsed; - try { - parsed = JSON.parse(value); - } catch (e) { - parsed = value; - } - return parsed; -} - -/** - * @private - * - * Copies all existing keys in the cookieStorage. - * - * @param {CookieStorage} obj: the object to where copy the keys + * @param {CookieStorage} instance: the object to where copy the keys * @param {object} storage: the storage mechanism - * @return {void} + * @return {object} */ -function copyKeys(obj, storage) { +function copyKeys(instance, storage) { Object.keys(storage).forEach((key) => { - obj[key] = tryParse(storage[key]); + instance[key] = tryParse(storage[key]); }); + return instance; } /** @@ -55,14 +38,13 @@ function copyKeys(obj, storage) { * @type {class} */ class CookieStorage { - /** * Creates an instance of CookieStorage. * * @memberOf CookieStorage */ constructor() { - copyKeys(this, cookies); + copyKeys(this, cookieStore); } /** @@ -70,22 +52,22 @@ class CookieStorage { * * @param {string} key: keyname of the storage * @param {any} value: data to save in the storage - * @param {object} options: additional options for cookieStorage + * @param {object} options: additional options for cookieStore * @return {void} * * @memberOf CookieStorage */ setItem(key, value, options) { checkEmpty(key); - if (bannedKeys.test(key)) { + if (BANNED_KEYS.test(key)) { throw new Error('The key is a reserved word, therefore not allowed'); } this[key] = value; // prevents converting strings to JSON to avoid extra quotes if (typeof value !== 'string') value = JSON.stringify(value); - cookies.setItem(key, value, options); + cookieStore.setItem(key, value, options); // checks if the cookie was created, or delete it if the domain or path are not valid - if (cookies.getItem(key) === null) { + if (cookieStore.getItem(key) === null) { delete this[key]; } } @@ -100,8 +82,8 @@ class CookieStorage { */ getItem(key) { checkEmpty(key); - let value = cookies.getItem(key); - if (value == null) { + let value = cookieStore.getItem(key); + if (value == null) { // null or undefined delete this[key]; value = null; } else { @@ -115,7 +97,7 @@ class CookieStorage { * Deletes a key from the storage. * * @param {string} key: keyname of the storage - * @param {object} options: additional options for cookieStorage + * @param {object} options: additional options for cookieStore * @return {void} * * @memberOf CookieStorage @@ -123,7 +105,7 @@ class CookieStorage { removeItem(key, options) { checkEmpty(key); delete this[key]; - cookies.removeItem(key, options); + cookieStore.removeItem(key, options); } /** @@ -137,7 +119,7 @@ class CookieStorage { Object.keys(this).forEach((key) => { delete this[key]; }, this); - cookies.clear(); + cookieStore.clear(); } /** @@ -150,7 +132,6 @@ class CookieStorage { get length() { return Object.keys(this).length; } - } /** diff --git a/src/utils.js b/src/utils.js index b46c12b..6195289 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,28 +9,16 @@ export function isObject(value) { } /** - * Adds or subtracts date portions to the given date and returns the new date. - * - * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * Validates if the key is not empty. + * (null, undefined or empty string) * - * @param {object} options: It contains the date parts to add or remove, and can have the following properties: - * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. - * - {number} minutes: minutes to add/subtract - * - {number} hours: hours to add/subtract - * - {number} days: days to add/subtract - * - {number} months: months to add/subtract - * - {number} years: years to add/subtract - * @return {Date} + * @param {string} key: keyname of an element in the storage mechanism + * @return {void} */ -export function alterDate(options = {}) { - const opt = Object.assign({}, options); - const d = opt.date instanceof Date ? opt.date : new Date(); - if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); - if (+opt.hours) d.setHours(d.getHours() + opt.hours); - if (+opt.days) d.setDate(d.getDate() + opt.days); - if (+opt.months) d.setMonth(d.getMonth() + opt.months); - if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); - return d; +export function checkEmpty(key) { + if (key == null || key === '') { + throw new Error('The key provided can not be empty'); + } } /** @@ -54,14 +42,17 @@ export function setProperty(obj, name, value) { } /** - * Validates if the key is not empty. - * (null, undefined or empty string) + * Try to parse a value from JSON. * - * @param {string} key: keyname of an element in the storage mechanism - * @return {void} + * @param {string} value: the value to parse + * @return {any} */ -export function checkEmpty(key) { - if (key == null || key === '') { - throw new Error('The key provided can not be empty'); +export function tryParse(value) { + let parsed; + try { + parsed = JSON.parse(value); + } catch (e) { + parsed = value; } + return parsed; } diff --git a/yarn.lock b/yarn.lock index 616600f..9d29857 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,10 +30,14 @@ acorn@^5.0.0, acorn@^5.0.1: version "5.0.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" -ajv-keywords@^1.0.0, ajv-keywords@^1.1.1: +ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" +ajv-keywords@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" + ajv@^4.7.0, ajv@^4.9.1: version "4.11.7" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" @@ -41,6 +45,15 @@ ajv@^4.7.0, ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" +ajv@^5.1.5: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.0.tgz#c1735024c5da2ef75cc190713073d44f098bf486" + dependencies: + co "^4.6.0" + fast-deep-equal "^0.1.0" + json-schema-traverse "^0.3.0" + json-stable-stringify "^1.0.1" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -49,9 +62,9 @@ align-text@^0.1.1, align-text@^0.1.3: longest "^1.0.1" repeat-string "^1.5.2" -ansi-escapes@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" +ansi-escapes@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" ansi-regex@^2.0.0: version "2.1.1" @@ -161,7 +174,7 @@ aws4@^1.2.1: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: +babel-code-frame@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" dependencies: @@ -169,20 +182,20 @@ babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.23.1, babel-core@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" +babel-core@^6.24.1, babel-core@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.1" + babel-generator "^6.25.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-template "^6.25.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" convert-source-map "^1.1.0" debug "^2.1.1" json5 "^0.5.0" @@ -202,13 +215,13 @@ babel-eslint@^7.1.1: babel-types "^6.23.0" babylon "^6.17.0" -babel-generator@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" +babel-generator@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" + babel-types "^6.25.0" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" @@ -333,14 +346,13 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-loader@^6.4.0: - version "6.4.1" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.4.1.tgz#0b34112d5b0748a8dcdbf51acf6f9bd42d50b8ca" +babel-loader@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.1.tgz#b87134c8b12e3e4c2a94e0546085bc680a2b8488" dependencies: - find-cache-dir "^0.1.1" - loader-utils "^0.2.16" + find-cache-dir "^1.0.0" + loader-utils "^1.0.2" mkdirp "^0.5.1" - object-assign "^4.0.1" babel-messages@^6.23.0: version "6.23.0" @@ -688,42 +700,42 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" +babel-template@^6.24.1, babel-template@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" lodash "^4.2.0" -babel-traverse@^6.23.1, babel-traverse@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" +babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" - babylon "^6.15.0" + babel-types "^6.25.0" + babylon "^6.17.2" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" +babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0, babylon@^6.15.0, babylon@^6.17.0: - version "6.17.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" +babylon@^6.17.0, babylon@^6.17.2: + version "6.17.4" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a" balanced-match@^0.4.1: version "0.4.2" @@ -763,7 +775,7 @@ boom@2.x.x: dependencies: hoek "2.x.x" -brace-expansion@^1.0.0: +brace-expansion@^1.0.0, brace-expansion@^1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" dependencies: @@ -927,11 +939,11 @@ clean-webpack-plugin@^0.1.15: dependencies: rimraf "~2.5.1" -cli-cursor@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: - restore-cursor "^1.0.1" + restore-cursor "^2.0.0" cli-width@^2.0.0: version "2.1.0" @@ -975,7 +987,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.5.2: +concat-stream@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -1079,12 +1091,18 @@ debug@2.2.0: dependencies: ms "0.7.1" -debug@^2.1.1, debug@^2.2.0: +debug@^2.1.1: version "2.6.4" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0" dependencies: ms "0.7.3" +debug@^2.2.0, debug@^2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + decamelize@^1.0.0, decamelize@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1264,23 +1282,21 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-config-airbnb-base@^11.1.1: - version "11.1.3" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.1.3.tgz#0e8db71514fa36b977fbcf977c01edcf863e0cf0" +eslint-config-airbnb-base@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.2.0.tgz#19a9dc4481a26f70904545ec040116876018f853" -eslint-import-resolver-node@^0.2.0: - version "0.2.3" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" +eslint-import-resolver-node@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz#4422574cde66a9a7b099938ee4d508a199e0e3cc" dependencies: - debug "^2.2.0" - object-assign "^4.0.1" - resolve "^1.1.6" + debug "^2.6.8" + resolve "^1.2.0" -eslint-loader@^1.6.3: - version "1.7.1" - resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-1.7.1.tgz#50b158dd6272dcefb97e984254837f81a5802ce0" +eslint-loader@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-1.8.0.tgz#8261f08cca4bd2ea263b77733e93cf0f21e20aa9" dependencies: - find-cache-dir "^0.1.1" loader-fs-cache "^1.0.0" loader-utils "^1.0.2" object-assign "^4.0.1" @@ -1294,64 +1310,69 @@ eslint-module-utils@^2.0.0: debug "2.2.0" pkg-dir "^1.0.0" -eslint-plugin-import@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz#72ba306fad305d67c4816348a4699a4229ac8b4e" +eslint-plugin-import@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.6.1.tgz#f580be62bb809421d46e338372764afcc9f59bf6" dependencies: builtin-modules "^1.1.1" contains-path "^0.1.0" - debug "^2.2.0" + debug "^2.6.8" doctrine "1.5.0" - eslint-import-resolver-node "^0.2.0" + eslint-import-resolver-node "^0.3.1" eslint-module-utils "^2.0.0" has "^1.0.1" lodash.cond "^4.3.0" minimatch "^3.0.3" - pkg-up "^1.0.0" + read-pkg-up "^2.0.0" + +eslint-scope@^3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" -eslint@^3.17.1: - version "3.19.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" +eslint@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.1.1.tgz#facbdfcfe3e0facd3a8b80dc98c4e6c13ae582df" dependencies: - babel-code-frame "^6.16.0" + babel-code-frame "^6.22.0" chalk "^1.1.3" - concat-stream "^1.5.2" - debug "^2.1.1" + concat-stream "^1.6.0" + debug "^2.6.8" doctrine "^2.0.0" - escope "^3.6.0" - espree "^3.4.0" + eslint-scope "^3.7.1" + espree "^3.4.3" esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" - glob "^7.0.3" - globals "^9.14.0" - ignore "^3.2.0" + glob "^7.1.2" + globals "^9.17.0" + ignore "^3.3.3" imurmurhash "^0.1.4" - inquirer "^0.12.0" - is-my-json-valid "^2.10.0" + inquirer "^3.0.6" + is-my-json-valid "^2.16.0" is-resolvable "^1.0.0" - js-yaml "^3.5.1" - json-stable-stringify "^1.0.0" + js-yaml "^3.8.4" + json-stable-stringify "^1.0.1" levn "^0.3.0" - lodash "^4.0.0" - mkdirp "^0.5.0" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" - path-is-inside "^1.0.1" - pluralize "^1.2.1" - progress "^1.1.8" - require-uncached "^1.0.2" - shelljs "^0.7.5" - strip-bom "^3.0.0" + path-is-inside "^1.0.2" + pluralize "^4.0.0" + progress "^2.0.0" + require-uncached "^1.0.3" strip-json-comments "~2.0.1" - table "^3.7.8" + table "^4.0.1" text-table "~0.2.0" - user-home "^2.0.0" -espree@^3.4.0: - version "3.4.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.2.tgz#38dbdedbedc95b8961a1fbf04734a8f6a9c8c592" +espree@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.3.tgz#2910b5ccd49ce893c2ffffaab4fd8b3a31b82374" dependencies: acorn "^5.0.1" acorn-jsx "^3.0.0" @@ -1402,10 +1423,6 @@ evp_bytestokey@^1.0.0: dependencies: create-hash "^1.1.1" -exit-hook@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1422,6 +1439,14 @@ extend@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" +external-editor@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.4.tgz#1ed9199da9cbfe2ef2f7a31b2fde8b0d12368972" + dependencies: + iconv-lite "^0.4.17" + jschardet "^1.4.2" + tmp "^0.0.31" + extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" @@ -1432,16 +1457,19 @@ extsprintf@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +fast-deep-equal@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-0.1.0.tgz#5c6f4599aba6b333ee3342e2ed978672f1001f8d" + fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" -figures@^1.3.5: - version "1.7.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: escape-string-regexp "^1.0.5" - object-assign "^4.1.0" file-entry-cache@^2.0.0: version "2.0.0" @@ -1472,6 +1500,14 @@ find-cache-dir@^0.1.1: mkdirp "^0.5.1" pkg-dir "^1.0.0" +find-cache-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" + dependencies: + commondir "^1.0.1" + make-dir "^1.0.0" + pkg-dir "^2.0.0" + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -1479,6 +1515,12 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" +find-up@^2.0.0, find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + dependencies: + locate-path "^2.0.0" + flat-cache@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" @@ -1588,18 +1630,18 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" +glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.0.0, globals@^9.14.0: +globals@^9.0.0, globals@^9.17.0: version "9.17.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" @@ -1699,13 +1741,17 @@ https-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" +iconv-lite@^0.4.17: + version "0.4.18" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" + ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" -ignore@^3.2.0: - version "3.2.7" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.7.tgz#4810ca5f1d8eca5595213a34b94f2eb4ed926bbd" +ignore@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.3.tgz#432352e57accd87ab3110e82d3fea0e47812156d" imurmurhash@^0.1.4: version "0.1.4" @@ -1734,21 +1780,22 @@ ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" -inquirer@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" +inquirer@^3.0.6: + version "3.1.1" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.1.1.tgz#87621c4fba4072f48a8dd71c9f9df6f100b2d534" dependencies: - ansi-escapes "^1.1.0" - ansi-regex "^2.0.0" + ansi-escapes "^2.0.0" chalk "^1.0.0" - cli-cursor "^1.0.1" + cli-cursor "^2.1.0" cli-width "^2.0.0" - figures "^1.3.5" + external-editor "^2.0.4" + figures "^2.0.0" lodash "^4.3.0" - readline2 "^1.0.1" - run-async "^0.1.0" - rx-lite "^3.1.2" - string-width "^1.0.1" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.0.0" strip-ansi "^3.0.0" through "^2.3.6" @@ -1826,7 +1873,7 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-my-json-valid@^2.10.0: +is-my-json-valid@^2.16.0: version "2.16.0" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693" dependencies: @@ -1865,6 +1912,10 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" @@ -1907,9 +1958,9 @@ js-tokens@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" -js-yaml@^3.5.1: - version "3.8.3" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.3.tgz#33a05ec481c850c8875929166fe1beb61c728766" +js-yaml@^3.8.4: + version "3.8.4" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6" dependencies: argparse "^1.0.7" esprima "^3.1.1" @@ -1918,6 +1969,10 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" +jschardet@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.4.2.tgz#2aa107f142af4121d145659d44f50830961e699a" + jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -1930,11 +1985,15 @@ json-loader@^0.5.4: version "0.5.4" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de" +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: +json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -1998,6 +2057,15 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + loader-fs-cache@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/loader-fs-cache/-/loader-fs-cache-1.0.1.tgz#56e0bf08bd9708b26a765b68509840c8dec9fdbc" @@ -2009,16 +2077,7 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.16: - version "0.2.17" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" - dependencies: - big.js "^3.1.3" - emojis-list "^2.0.0" - json5 "^0.5.0" - object-assign "^4.0.1" - -loader-utils@^1.0.2: +loader-utils@^1.0.2, loader-utils@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" dependencies: @@ -2026,11 +2085,18 @@ loader-utils@^1.0.2: emojis-list "^2.0.0" json5 "^0.5.0" +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + lodash.cond@^4.3.0: version "4.5.2" resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" -lodash@^4.0.0, lodash@^4.14.0, lodash@^4.2.0, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -2044,6 +2110,12 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0" +make-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978" + dependencies: + pify "^2.3.0" + memory-fs@^0.4.0, memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -2086,6 +2158,10 @@ mime-types@^2.1.12, mime-types@~2.1.7: dependencies: mime-db "~1.27.0" +mimic-fn@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" + minimalistic-assert@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3" @@ -2094,7 +2170,13 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3: +minimatch@^3.0.0, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimatch@^3.0.2, minimatch@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" dependencies: @@ -2108,7 +2190,7 @@ minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: +mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -2122,9 +2204,13 @@ ms@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" -mute-stream@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" nan@^2.3.0: version "2.6.2" @@ -2236,9 +2322,11 @@ once@^1.3.0, once@^1.3.3: dependencies: wrappy "1" -onetime@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" optionator@^0.8.2: version "0.8.2" @@ -2265,7 +2353,7 @@ os-locale@^1.4.0: dependencies: lcid "^1.0.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -2276,6 +2364,16 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +p-limit@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + dependencies: + p-limit "^1.1.0" + pako@~0.2.0: version "0.2.9" resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" @@ -2315,11 +2413,15 @@ path-exists@^2.0.0: dependencies: pinkie-promise "^2.0.0" +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: +path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" @@ -2335,6 +2437,12 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: + pify "^2.0.0" + pbkdf2@^3.0.3: version "3.0.9" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.9.tgz#f2c4b25a600058b3c3773c086c37dbbee1ffe693" @@ -2345,7 +2453,7 @@ performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" -pify@^2.0.0: +pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -2365,15 +2473,15 @@ pkg-dir@^1.0.0: dependencies: find-up "^1.0.0" -pkg-up@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" dependencies: - find-up "^1.0.0" + find-up "^2.1.0" -pluralize@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" +pluralize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" prelude-ls@~1.1.2: version "1.1.2" @@ -2395,9 +2503,9 @@ process@^0.11.0: version "0.11.9" resolved "https://registry.yarnpkg.com/process/-/process-0.11.9.tgz#7bd5ad21aa6253e7da8682264f1e11d11c0318c1" -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" +progress@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" prr@~0.0.0: version "0.0.0" @@ -2460,6 +2568,13 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -2468,6 +2583,14 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" + dependencies: + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.2, readable-stream@^2.2.6: version "2.2.9" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" @@ -2489,20 +2612,6 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" -readline2@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - mute-stream "0.0.5" - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - dependencies: - resolve "^1.1.6" - regenerate@^1.2.1: version "1.3.2" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" @@ -2597,7 +2706,7 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" -require-uncached@^1.0.2: +require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: @@ -2608,18 +2717,18 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" -resolve@^1.1.6: +resolve@^1.2.0: version "1.3.3" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5" dependencies: path-parse "^1.0.5" -restore-cursor@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" dependencies: - exit-hook "^1.0.0" - onetime "^1.0.0" + onetime "^2.0.0" + signal-exit "^3.0.2" right-align@^0.1.1: version "0.1.3" @@ -2643,15 +2752,21 @@ ripemd160@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e" -run-async@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" dependencies: - once "^1.3.0" + is-promise "^2.1.0" + +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" -rx-lite@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" safe-buffer@^5.0.1: version "5.0.1" @@ -2679,15 +2794,7 @@ sha.js@^2.3.6: dependencies: inherits "^2.0.1" -shelljs@^0.7.5: - version "0.7.7" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" - dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" - -signal-exit@^3.0.0: +signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -2705,9 +2812,9 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-list-map@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.1.tgz#1a33ac210ca144d1e561f906ebccab5669ff4cb4" +source-list-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" source-map-support@^0.4.2: version "0.4.14" @@ -2828,9 +2935,9 @@ supports-color@^3.1.0: dependencies: has-flag "^1.0.0" -table@^3.7.8: - version "3.8.3" - resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" +table@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.1.tgz#a8116c133fac2c61f4a420ab6cdf5c4d61f0e435" dependencies: ajv "^4.7.0" ajv-keywords "^1.0.0" @@ -2878,6 +2985,12 @@ timers-browserify@^2.0.2: dependencies: setimmediate "^1.0.4" +tmp@^0.0.31: + version "0.0.31" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" + dependencies: + os-tmpdir "~1.0.1" + to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -2924,9 +3037,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@^2.8.5: - version "2.8.22" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.22.tgz#d54934778a8da14903fa29a326fb24c0ab51a1a0" +uglify-js@^2.8.29: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" dependencies: source-map "~0.5.1" yargs "~3.10.0" @@ -2937,6 +3050,14 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" +uglifyjs-webpack-plugin@^0.4.4: + version "0.4.6" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz#b951f4abb6bd617e66f63eb891498e391763e309" + dependencies: + source-map "^0.5.6" + uglify-js "^2.8.29" + webpack-sources "^1.0.1" + uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -2948,12 +3069,6 @@ url@^0.11.0: punycode "1.3.2" querystring "0.2.0" -user-home@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" - dependencies: - os-homedir "^1.0.0" - util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -2995,37 +3110,38 @@ watchpack@^1.3.1: chokidar "^1.4.3" graceful-fs "^4.1.2" -webpack-sources@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" +webpack-sources@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: - source-list-map "^1.1.1" + source-list-map "^2.0.0" source-map "~0.5.3" -webpack@^2.2.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.4.1.tgz#15a91dbe34966d8a4b99c7d656efd92a2e5a6f6a" +webpack@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.0.0.tgz#ee9bcebf21247f7153cb410168cab45e3a59d4d7" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" - ajv "^4.7.0" - ajv-keywords "^1.1.1" + ajv "^5.1.5" + ajv-keywords "^2.0.0" async "^2.1.2" enhanced-resolve "^3.0.0" + escope "^3.6.0" interpret "^1.0.0" json-loader "^0.5.4" json5 "^0.5.1" loader-runner "^2.3.0" - loader-utils "^0.2.16" + loader-utils "^1.1.0" memory-fs "~0.4.1" mkdirp "~0.5.0" node-libs-browser "^2.0.0" source-map "^0.5.3" supports-color "^3.1.0" tapable "~0.2.5" - uglify-js "^2.8.5" + uglifyjs-webpack-plugin "^0.4.4" watchpack "^1.3.1" - webpack-sources "^0.2.3" + webpack-sources "^1.0.1" yargs "^6.0.0" which-module@^1.0.0: