[
  {
    "path": ".circleci/config.yml",
    "content": "# Javascript Node CircleCI 2.0 configuration file\n#\n# Check https://circleci.com/docs/2.0/language-javascript/ for more details\n#\nversion: 2\njobs:\n  build:\n    docker:\n      # specify the version you desire here\n      - image: circleci/node:7.10\n      \n      # Specify service dependencies here if necessary\n      # CircleCI maintains a library of pre-built images\n      # documented at https://circleci.com/docs/2.0/circleci-images/\n      # - image: circleci/mongo:3.4.4\n\n    working_directory: ~/repo\n\n    steps:\n      - checkout\n\n      # Download and cache dependencies\n      - restore_cache:\n          keys:\n          - v1-dependencies-{{ checksum \"package.json\" }}\n          # fallback to using the latest cache if no exact match is found\n          - v1-dependencies-\n\n      - run: yarn install\n\n      - save_cache:\n          paths:\n            - node_modules\n          key: v1-dependencies-{{ checksum \"package.json\" }}\n        \n      # run tests!\n      - run: yarn test"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nnpm-debug.log\n*.sublime-workspace\n"
  },
  {
    "path": "COPYRIGHT",
    "content": "Copyright (c) 2023 - Marcus Westin"
  },
  {
    "path": "Changelog",
    "content": "v2.0.0\n+ New pluggable architecture!\n+ New storages: localStorage, cookieStorage, memoryStorage, sessionStorage, oldFF-globalStorage, oldIE-userDataStorage.\n+ New plugins: defaults, dump, events, expire, json2, observe, operations, update, v1-backcompat.\n+ New builds: everything, legacy, modern, v1-backcompat, minimal (17k, 13k, 12k, 6k respectively)\n\nv1.3.20\n+ Fully automated test framework\n+ Fix infinite loop in IE\n\nv1.3.19\n+ Use umdjs to export store.js (#116, #111, #96, #91, #78, ...)\n+ Make compatible with \"use strict\" mode (#111)\n+ Fix store.clear in legacy-IE code path (#103)\n+ Roadmap for v1.4.x and v2.x.x\n\nv1.3.17\n+ Add store.has\n+ Add store.get default value, e.g `store.get('foo', 1)`\n+ Fix IE strict mode compatability issue (#105)\n+ Added store.version\n\nv1.3.16\n+ Improve environment/module.exports detection (#88, github.com/benrudolph)\n\nv1.3.15\n+ Enable inlining the minified build\n+ Fix AMD issue (https://github.com/marcuswestin/store.js/issues/85)\n+ Fix for keys starting with a digit in IE7 (https://github.com/marcuswestin/store.js/issues/83)\n\nv1.3.14\n+ Makefile\n+ Fix old-IE getAll/forEach, actually this time. I think\n\nv1.3.12\n+ Fix old-IE forEach again. Hrm...\n\nv1.3.11\n+ Fix old-IE forEach\n\nv1.3.10\n+ Add store.forEach\n+ Add bower.json (sign, I know, yet another package file to maintain)\n+ Add MIT license header\n\nv1.3.9\n+ Make store.js work in Node.js (using any working localStorage shim for Node.js)\n\nv1.3.8\n+ Fix closing </iframe> tag for IE7 (GH issue #68)\n\nv1.3.7\n+ Fix store.getAll for IE6\n\nv1.3.6\n+ Remove globalStorage and drop FF 2.0/3.0 support (See https://github.com/marcuswestin/store.js/issues/44)\n\nv1.3.5\n+ Now store.set returns the set value: `store.set(key, value) == value`\n+ Values previously set with localStorage directly are now parsed handler by store.js: `localStorage['foo'] = 1; assert(store.get('foo') == 1)`\n\nv1.3.4\n+ Add store.enabled\n+ Deprecate store.disabled\n+ Add link to Jack Franklin's screencast\n\nv1.3.3\n+ Fix IE keys beginning with numeric characters (nice find @pauldwaite)\n\nv1.3.2\n+ Implement store.getAll() (patch by @blq)\n\nv1.3.0\n+ Use uglify.js for minifying store.min.js and store+json.min.js\n+ Add build script\n\nv1.2.0\n+ Remove same-path restrictions in IE6/7! (Thanks @mjpizz!)\n+ Support CommonJS and AMD module systems (Thanks @pereckerdal!)\n+ Fix: store.set('foo', undefined); store.get('foo') no longer throws (Thanks @buger!)\n\nv1.1.1\n+ Publish in npm as \"store\" rather than \"store.js\"\n+ Add commonjs export for require support\n+ Add supported browsers Chrome 6-11, Firefox 4.0\n\nv1.1.0\n+ First versioned version.\n+ API: store.set, store.get, store.remove, store.clear, store.transact\n+ Minified versions are included: store.min.js for store.js only, and store+json2.min.js for store.js and json2.js\n\nTODO\n- Get around IE6/7 per-directory restrition. @lrbabe/@louis_remi had the idea of putting the store.js API in an anonymous iframe a la https://github.com/meebo/embed-code and see what directory restriction that would fall under\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2010-2017 Marcus Westin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "test: test-node lint\ninstall:\n\tyarn install\n\ntest-node:\n\tnode scripts/run-node-tests.js\n\ntest-browser:\n\tnode scripts/run-browser-tests-live-reload.js\n\ntest-full: build test\n\tnode scripts/run-saucelabs-tests.js\ntest-ie: build test\n\tnode scripts/run-saucelabs-tests.js ie\ntest-safari: build test\n\tnode scripts/run-saucelabs-tests.js safari\ntest-firefox: build test\n\tnode scripts/run-saucelabs-tests.js firefox\ntest-chrome: build test\n\tnode scripts/run-saucelabs-tests.js chrome\ntest-android: build test\n\tnode scripts/run-saucelabs-tests.js android\ntest-ios: build test\n\tnode scripts/run-saucelabs-tests.js ios\ntest-opera: build test\n\tnode scripts/run-saucelabs-tests.js opera\n\ntunnel:\n\tnode scripts/create-tunnel.js\n\nbuild:\n\tnode scripts/compile-builds.js\n\nlint:\n\t./node_modules/.bin/eslint tests/* src/* plugins/* storages/*  \\\n\t\t--ignore-pattern src/addon/lib/json2.js                    \\\n"
  },
  {
    "path": "README-More.md",
    "content": "How does it work?\n------------------\nstore.js uses localStorage when available, and falls back on the userData behavior in IE6 and IE7. No flash to slow down your page load. No cookies to fatten your network requests.\n\nstore.js depends on JSON for serialization to disk.\n\n\nInstallation\n------------\nJust grab [store.min.js] or [store+json2.min.js] and include them with a script tag.\n\n\n`store.enabled` flag\n--------------------\nIf your product depends on store.js, you must check the `store.enabled` flag first:\n\n```html\n<script src=\"store.min.js\"></script>\n<script>\n\tinit()\n\tfunction init() {\n\t\tif (!store.enabled) {\n\t\t\talert('Local storage is not supported by your browser. Please disable \"Private Mode\", or upgrade to a modern browser.')\n\t\t\treturn\n\t\t}\n\t\tvar user = store.get('user')\n\t\t// ... and so on ...\n\t}\n</script>\n```\n\nLocalStorage may sometimes appear to be available but throw an error when used. An example is Safari's private browsing mode. Other browsers allow the user to temporarily disable localStorage. Store.js detects these conditions and sets the `store.enabled` flag appropriately.\n\n\nScreencast\n-----------\n[Introductory Screencast to Store.js](http://javascriptplayground.com/blog/2012/06/javascript-local-storage-store-js-tutorial) by Jack Franklin.\n\n\nContributors & Forks\n--------------------\nContributors: https://github.com/marcuswestin/store.js/graphs/contributors\n\nForks: https://github.com/marcuswestin/store.js/network/members\n\n\nIn node.js\n----------\nstore.js works as expected in node.js, assuming that global.localStorage has been set:\n\n```\nglobal.localStorage = require('localStorage')\nvar store = require('./store')\nstore.set('foo', 1)\nconsole.log(store.get('foo'))\n```\n\n\nSupported browsers\n------------------\n - Tested in iOS 4+\n - Tested in Firefox 3.5\n - Tested in Firefox 3.6\n - Tested in Firefox 4.0+\n - Support dropped for Firefox < 3.5 (see notes below)\n - Tested in Chrome 5\n - Tested in Chrome 6\n - Tested in Chrome 7\n - Tested in Chrome 8\n - Tested in Chrome 10\n - Tested in Chrome 11+\n - Tested in Safari 4\n - Tested in Safari 5\n - Tested in IE6\n - Tested in IE7\n - Tested in IE8\n - Tested in IE9\n - Tested in IE10\n - Tested in Opera 10\n - Tested in Opera 11\n - Tested in Opera 12\n - Tested in Node.js v0.10.4 (with https://github.com/coolaj86/node-localStorage 1.0.2)\n\n*Private mode* Store.js may not work while browsing in private mode. This is as it should be. Check the `store.enabled` flag before relying on store.js.\n\n*Saucelabs.com rocks* Extensive browser testing of store.js is possible thanks to Saucelabs.com. Check them out, they're awesome.\n\n*Firefox 3.0 & 2.0:* Support for FF 2 & 3 was dropped in v1.3.6. If you require support for ancient versions of FF, use v1.3.5 of store.js.\n\n*Important note:* In IE6 and IE7, many special characters are not allowed in the keys used to store any key/value pair. With [@mferretti](https://github.com/mferretti)'s help, there's a suitable workaround which replaces most forbidden characters with \"___\".\n\n\nStorage limits\n--------------\n - IE6 & IE7: 1MB total, but 128kb per \"path\" or \"document\" (see http://msdn.microsoft.com/en-us/library/ms531424(v=vs.85).aspx)\n - See http://dev-test.nemikor.com/web-storage/support-test/ for a list of limits per browser\n\nUnsupported browsers\n-------------------\n - Firefox 1.0: no means (beside cookies and flash)\n - Safari 2: no means (beside cookies and flash)\n - Safari 3: no synchronous api (has asynch sqlite api, but store.js is synch)\n - Opera 9: don't know if there is synchronous api for storing data locally\n - Firefox 1.5: don't know if there is synchronous api for storing data locally\n - Microsoft IIS & IE7: With meta tag & \"charset=iso-8859-1\", things stop working. See issue #47.\n\n\nSome notes on serialization\n---------------------------\nlocalStorage, when used without store.js, calls toString on all stored values. This means that you can't conveniently store and retrieve numbers, objects or arrays:\n\n```js\nlocalStorage.myage = 24\nlocalStorage.myage !== 24\nlocalStorage.myage === '24'\n\nlocalStorage.user = { name: 'marcus', likes: 'javascript' }\nlocalStorage.user === \"[object Object]\"\n\nlocalStorage.tags = ['javascript', 'localStorage', 'store.js']\nlocalStorage.tags.length === 32\nlocalStorage.tags === \"javascript,localStorage,store.js\"\n```\n\nWhat we want (and get with store.js) is\n\n```js\nstore.set('myage', 24)\nstore.get('myage') === 24\n\nstore.set('user', { name: 'marcus', likes: 'javascript' })\nalert(\"Hi my name is \" + store.get('user').name + \"!\")\n\nstore.set('tags', ['javascript', 'localStorage', 'store.js'])\nalert(\"We've got \" + store.get('tags').length + \" tags here\")\n```\n\nThe native serialization engine of javascript is JSON. Rather than leaving it up to you to serialize and deserialize your values, store.js uses JSON.stringify() and JSON.parse() on each call to store.set() and store.get(), respectively.\n\nSome browsers do not have native support for JSON. For those browsers you should include [JSON2.js] \\(non-minified copy is included in this repo).\n\n\nNo sessionStorage/auto-expiration?\n----------------------------------\nNo. I believe there is no way to provide sessionStorage semantics cross browser. However, it is trivial to expire values on read on top of store.js:\n\n```js\nvar storeWithExpiration = {\n\tset: function(key, val, exp) {\n\t\tstore.set(key, { val:val, exp:exp, time:new Date().getTime() })\n\t},\n\tget: function(key) {\n\t\tvar info = store.get(key)\n\t\tif (!info) { return null }\n\t\tif (new Date().getTime() - info.time > info.exp) { return null }\n\t\treturn info.val\n\t}\n}\nstoreWithExpiration.set('foo', 'bar', 1000)\nsetTimeout(function() { console.log(storeWithExpiration.get('foo')) }, 500) // -> \"bar\"\nsetTimeout(function() { console.log(storeWithExpiration.get('foo')) }, 1500) // -> null\n```\n\n\n\n  [JSON2.js]: https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js\n  [store.min.js]: https://raw.github.com/marcuswestin/store.js/master/store.min.js\n  [store+json2.min.js]: https://raw.github.com/marcuswestin/store.js/master/store+json2.min.js\n "
  },
  {
    "path": "README.md",
    "content": "Store.js\n========\n\nCross-browser storage for all use cases, used across the web.\n\n[![Circle CI](https://img.shields.io/circleci/project/github/marcuswestin/store.js.svg)](https://circleci.com/gh/marcuswestin/store.js)\n[![npm version](https://badge.fury.io/js/store.svg)](https://badge.fury.io/js/store)\n[![npm](https://img.shields.io/npm/dm/store.svg?maxAge=2592000)](https://npm-stat.com/charts.html?package=store)\n\nStore.js has been around since 2010 ([first commit](https://github.com/marcuswestin/store.js/commit/cb0198c2c02ff5f17c084276eeb4f28c79849d5e), [v1 release](https://news.ycombinator.com/item?id=1468802)). It is used in production on tens of thousands of websites, such as cnn.com, dailymotion.com, & many more.\n\nStore.js provides basic key/value storage functionality (`get/set/remove/each`) as well as a rich set of plug-in [storages](#user-content-storages) and extra [functionality](#user-content-plugins).\n\n\n1. [Basic Usage](#user-content-basic-usage)\n\t- All you need to get started\n\t- [API](#user-content-api)\n\t- [Installation](#user-content-installation)\n2. [Supported Browsers](#user-content-supported-browsers)\n\t- All of them, pretty much :)\n\t- [List of supported browsers](#user-content-list-of-supported-browsers)\n3. [Plugins](#user-content-plugins)\n\t- Additional common functionality\n\t- [List of all Plugins](#user-content-list-of-all-plugins)\n\t- [Using Plugins](#user-content-using-plugins)\n\t- [Write your own Plugin](#user-content-write-your-own-plugin)\n4. [Builds](#user-content-builds)\n\t- Choose which build is right for you\n\t- [List of default Builds](#user-content-list-of-default-builds)\n\t- [Make your own Build](#user-content-make-your-own-build)\n5. [Storages](#user-content-storages)\n\t- Storages provide underlying persistence\n\t- [List of all Storages](#user-content-list-of-all-storages)\n\t- [Storages limits](#user-content-storages-limits)\n\t- [Write your own Storage](#user-content-write-your-own-storage)\n\n\nBasic Usage\n-----------\n\nAll you need to know to get started:\n\n### API\n\nstore.js exposes a simple API for cross-browser local storage:\n\n```js\n// Store current user\nstore.set('user', { name:'Marcus' })\n\n// Get current user\nstore.get('user')\n\n// Remove current user\nstore.remove('user')\n\n// Clear all keys\nstore.clearAll()\n\n// Loop over all stored values\nstore.each(function(value, key) {\n\tconsole.log(key, '==', value)\n})\n```\n\n### Installation\n\nUsing npm:\n\n```sh\nnpm i store\n```\n\n```js\n// Example store.js usage with npm\nvar store = require('store')\nstore.set('user', { name:'Marcus' })\nstore.get('user').name == 'Marcus'\n```\n\nUsing script tag (first download one of the [builds](dist/)):\n\n```html\n<!-- Example store.js usage with script tag -->\n<script src=\"path/to/my/store.legacy.min.js\"></script>\n<script>\nstore.set('user', { name:'Marcus' })\nstore.get('user').name == 'Marcus'\n</script>\n```\n\n\n\nSupported Browsers\n------------------\n\nAll of them, pretty much :)\n\nTo support all browsers (including IE 6, IE 7, Firefox 4, etc.), use `require('store')` (alias for `require('store/dist/store.legacy')`) or [store.legacy.min.js](dist/store.legacy.min.js).\n\nTo save some kilobytes but still support all modern browsers, use `require('store/dist/store.modern')` or [store.modern.min.js](dist/store.modern.min.js) instead.\n\n### List of supported browsers\n\n- Tested on IE6+\n- Tested on iOS 8+\n- Tested on Android 4+\n- Tested on Firefox 4+\n- Tested on Chrome 27+\n- Tested on Safari 5+\n- Tested on Opera 11+\n- Tested on Node (with https://github.com/coolaj86/node-localStorage)\n\n\n\n\nPlugins\n-------\n\nPlugins provide additional common functionality that some users might need:\n\n### List of all Plugins\n\n- [all.js](plugins/all.js):                      All the plugins in one handy place.\n- [defaults.js](plugins/defaults.js):            Declare default values. [Example usage](plugins/defaults_test.js)\n- [dump.js](plugins/dump.js):                    Dump all stored values. [Example usage](plugins/dump_test.js)\n- [events.js](plugins/events.js):                Get notified when stored values change. [Example usage](plugins/events_test.js)\n- [expire.js](plugins/expire.js):                Expire stored values at a given time. [Example usage](plugins/expire_test.js)\n- [observe.js](plugins/observe.js):              Observe stored values and their changes. [Example usage](plugins/observe_test.js)\n- [operations.js](plugins/operations.js):        Useful operations like push, shift & assign. [Example usage](plugins/operations_test.js)\n- [update.js](plugins/update.js):                Update a stored object, or create it if null. [Example usage](plugins/update_test.js)\n- [v1-backcompat.js](plugins/v1-backcompat.js):  Full backwards compatibility with store.js v1. [Example usage](plugins/v1-backcompat_test.js)\n\n### Using Plugins\n\nWith npm:\n\n```js\n// Example plugin usage:\nvar expirePlugin = require('store/plugins/expire')\nstore.addPlugin(expirePlugin)\n```\n\nIf you're using script tags, you can either use [store.everything.min.js](dist/store.everything.min.js) (which\nhas all plugins built-in), or clone this repo to add or modify a build and run `make build`.\n\n### Write your own plugin\n\nA store.js plugin is a function that returns an object that gets added to the store.\nIf any of the plugin functions overrides existing functions, the plugin function can still call\nthe original function using the first argument (super_fn).\n\n```js\n// Example plugin that stores a version history of every value\nvar versionHistoryPlugin = function() {\n\tvar historyStore = this.namespace('history')\n\treturn {\n\t\tset: function(super_fn, key, value) {\n\t\t\tvar history = historyStore.get(key) || []\n\t\t\thistory.push(value)\n\t\t\thistoryStore.set(key, history)\n\t\t\treturn super_fn()\n\t\t},\n\t\tgetHistory: function(key) {\n\t\t\treturn historyStore.get(key)\n\t\t}\n\t}\n}\nstore.addPlugin(versionHistoryPlugin)\nstore.set('foo', 'bar 1')\nstore.set('foo', 'bar 2')\nstore.getHistory('foo') == ['bar 1', 'bar 2']\n```\n\nLet me know if you need more info on writing plugins. For the moment I recommend\ntaking a look at the [current plugins](plugins/). Good example plugins are\n[plugins/defaults](plugins/defaults.js), [plugins/expire](plugins/expire.js) and\n[plugins/events](plugins/events.js).\n\n\n\nBuilds\n------\n\nChoose which build is right for you!\n\n### List of default builds\n\n- [store.everything.min.js](dist/store.everything.min.js): All the plugins, all the storages. [Source](dist/store.everything.js)\n- [store.legacy.min.js](dist/store.legacy.min.js): Full support for all tested browsers. Add plugins separately. [Source](dist/store.legacy.js)\n- [store.modern.min.js](dist/store.modern.min.js): Full support for all modern browsers. Add plugins separately. [Source](dist/store.modern.js)\n- [store.v1-backcompat.min.js](dist/store.v1-backcompat.min.js): Full backwards compatibility with [store.js v1](https://github.com/marcuswestin/store.js/releases/tag/v1.3.20). [Source](dist/store.v1-backcompat.js)\n\n### Make your own Build\n\nIf you're using npm you can create your own build:\n\n```js\n// Example custom build usage:\nvar engine = require('store/src/store-engine')\nvar storages = [\n\trequire('store/storages/localStorage'),\n\trequire('store/storages/cookieStorage')\n]\nvar plugins = [\n\trequire('store/plugins/defaults'),\n\trequire('store/plugins/expire')\n]\nvar store = engine.createStore(storages, plugins)\nstore.set('foo', 'bar', new Date().getTime() + 3000) // Using expire plugin to expire in 3 seconds\n```\n\n\n\n\nStorages\n--------\nStore.js will pick the best available storage, and automatically falls back to the first available storage that works:\n\n### List of all Storages\n\n- [all.js](storages/all.js)                                     All the storages in one handy place.\n- [localStorage.js](storages/localStorage.js)                   Store values in localStorage. Great for all modern browsers.\n- [sessionStorage.js](storages/sessionStorage.js)               Store values in sessionStorage.\n- [cookieStorage.js](storages/cookieStorage.js)                 Store values in cookies. Useful for Safari Private mode.\n- [memoryStorage.js](storages/memoryStorage.js)                 Store values in memory. Great fallback to ensure store functionality at all times.\n- [oldFF-globalStorage.js](storages/oldFF-globalStorage.js)     Store values in globalStorage. Only useful for legacy Firefox 3+.\n- [oldIE-userDataStorage.js](storages/oldIE-userDataStorage.js) Store values in userData. Only useful for legacy IE 6+.\n\n\n### Storages limits\n\nEach storage has different limits, restrictions and overflow behavior on different browser. For example, Android has has a 4.57M localStorage limit in 4.0, a 2.49M limit in 4.1, and a 4.98M limit in 4.2... Yeah.\n\nTo simplify things we provide these recommendations to ensure cross browser behavior:\n\n| Storage         | Targets                | Recommendations                 | More info                                        |\n|:----------------|:-----------------------|:--------------------------------|:-------------------------------------------------|\n| all             | All browsers           | Store < 1 million characters    | (Except Safari Private mode)                     |\n| all             | All & Private mode     | Store < 32 thousand characters  | (Including Safari Private mode)                  |\n| localStorage    | Modern browsers        | Max 2mb  (~1M chars)            | [limits][local-limits], [android][local-android] |\n| sessionStorage  | Modern browsers        | Max 5mb  (~2M chars)            | [limits][session-limits]                         |\n| cookieStorage   | Safari Private mode    | Max 4kb  (~2K chars)            | [limits][cookie-limits]                          |\n| userDataStorage | IE5, IE6 & IE7         | Max 64kb (~32K chars)           | [limits][userdata-limits]                        |\n| globalStorage   | Firefox 2-5            | Max 5mb  (~2M chars)            | [limits][global-limits]                          |\n| memoryStorage   | All browsers, fallback | Does not persist across pages!  |                                                  |\n\n[local-limits]: https://arty.name/localstorage.html\n[local-android]: http://dev-test.nemikor.com/web-storage/support-test/\n[session-limits]: http://stackoverflow.com/questions/15840976/how-large-is-html5-session-storage\n[cookie-limits]: http://browsercookielimits.squawky.net/\n[userdata-limits]: https://msdn.microsoft.com/en-us/library/ms533015(v=vs.85).aspx\n[global-limits]: https://github.com/jeremydurham/persist-js/blob/master/README.md#4-size-limits\n[more]: https://www.html5rocks.com/en/tutorials/offline/quota-research/\n\n\n### Write your own Storage\n\nChances are you won't ever need another storage. But if you do...\n\nSee [storages/](storages/) for examples. Two good examples are [memoryStorage](storages/memoryStorage.js) and [localStorage](storages/localStorage.js).\n\nBasically, you just need an object that looks like this:\n\n```js\n// Example custom storage\nvar storage = {\n\tname: 'myStorage',\n\tread: function(key) { ... },\n\twrite: function(key, value) { ... },\n\teach: function(fn) { ... },\n\tremove: function(key) { ... },\n\tclearAll: function() { ... }\n}\nvar store = require('store').createStore(storage)\n```\n"
  },
  {
    "path": "dist/store.everything.js",
    "content": "var engine = require('../src/store-engine')\n\nvar storages = require('../storages/all')\nvar plugins = require('../plugins/all')\n\nmodule.exports = engine.createStore(storages, plugins)\n"
  },
  {
    "path": "dist/store.legacy.js",
    "content": "var engine = require('../src/store-engine')\n\nvar storages = require('../storages/all')\nvar plugins = [require('../plugins/json2')]\n\nmodule.exports = engine.createStore(storages, plugins)\n"
  },
  {
    "path": "dist/store.modern.js",
    "content": "var engine = require('../src/store-engine')\n\nvar storages = [\n\trequire('../storages/localStorage'), \n\trequire('../storages/sessionStorage'), \n\trequire('../storages/cookieStorage'), \n\trequire('../storages/memoryStorage'),\n]\nvar plugins = []\n\nmodule.exports = engine.createStore(storages, plugins)\n"
  },
  {
    "path": "dist/store.tests.js",
    "content": "// store-test-suite will run all the store.js tests\n// and report the results.\n\nvar tests = require('../tests/tests')\n\ntests.runTests()\n"
  },
  {
    "path": "dist/store.v1-backcompat.js",
    "content": "var engine = require('../src/store-engine')\n\nvar storages = require('../storages/all')\nvar plugins = [require('../plugins/v1-backcompat')]\n\nmodule.exports = engine.createStore(storages, plugins)\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"store\",\n  \"version\": \"2.0.12\",\n  \"description\": \"A localStorage wrapper for all browsers without using cookies or flash. Uses localStorage, globalStorage, and userData behavior under the hood\",\n  \"main\": \"dist/store.legacy.js\",\n  \"scripts\": {\n    \"test\": \"make test\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/marcuswestin/store.js.git\"\n  },\n  \"author\": \"Marcus Westin <narcvs@gmail.com>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"http://github.com/marcuswestin/store.js/issues\"\n  },\n  \"homepage\": \"https://github.com/marcuswestin/store.js#readme\",\n  \"devDependencies\": {\n    \"babel-preset-es2015\": \"^6.22.0\",\n    \"babelify\": \"^7.3.0\",\n    \"browserify\": \"^14.1.0\",\n    \"budo\": \"^7.1.0\",\n    \"eslint\": \"^3.12.2\",\n    \"localStorage\": \"^1.0.3\",\n    \"lodash\": \"^3.10.1\",\n    \"ngrok\": \"^2.2.6\",\n    \"request\": \"^2.67.0\",\n    \"tinytest\": \"^1.1.3\",\n    \"uglify-js\": \"^2.7.5\"\n  },\n  \"eslintConfig\": {\n    \"env\": {\n      \"browser\": true,\n      \"commonjs\": true,\n      \"es6\": true,\n      \"node\": true\n    },\n    \"extends\": \"eslint:recommended\",\n    \"parserOptions\": {\n      \"sourceType\": \"module\"\n    },\n    \"globals\": {\n      \"test\": false,\n      \"assert\": false,\n      \"print\": false\n    },\n    \"rules\": {\n      \"comma-dangle\": [\"error\", \"only-multiline\"],\n      \"no-unused-vars\": [\n        \"error\",\n        {\n          \"vars\": \"all\",\n          \"args\": \"none\",\n          \"varsIgnorePattern\": \"^_$\"\n        }\n      ],\n      \"indent\": [\n        \"error\",\n        \"tab\"\n      ],\n      \"linebreak-style\": [\n        \"error\",\n        \"unix\"\n      ],\n      \"semi\": [\n        \"error\",\n        \"never\"\n      ]\n    }\n  },\n  \"engines\": {\n    \"node\": \"*\"\n  },\n  \"directories\": {\n    \"lib\": \".\"\n  }\n}\n"
  },
  {
    "path": "plugins/all.js",
    "content": "module.exports = [\n\trequire('./compression'),\n\trequire('./defaults'),\n\trequire('./dump'),\n\trequire('./events'),\n\trequire('./observe'),\n\trequire('./expire'),\n\trequire('./json2'),\n\trequire('./operations'),\n\trequire('./update'),\n\trequire('./v1-backcompat'),\n]\n"
  },
  {
    "path": "plugins/all_tests.js",
    "content": "module.exports = {\n\t\"compression\": require('./compression_test'),\n\t\"defaults\": require('./defaults_test'),\n\t\"dump\": require('./dump_test'),\n\t\"events\": require('./events_test'),\n\t\"observe\": require('./observe_test'),\n\t\"expire\": require('./expire_test'),\n\t\"json2\": require('./json2_test'),\n\t\"operations\": require('./operations_test'),\n\t\"update\": require('./update_test'),\n\t\"v1-backcompat\": require('./v1-backcompat_test'),\n}\n"
  },
  {
    "path": "plugins/compression.js",
    "content": "const LZString = require('./lib/lz-string')\n\nmodule.exports = compressionPlugin\n\nfunction compressionPlugin() {\n\treturn {\n\t\tget: get,\n\t\tset: set,\n\t}\n\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn(key)\n\t\tif (!val) { return val }\n\t\tvar decompressed = LZString.decompress(val)\n\t\t// fallback to existing values that are not compressed\n\t\treturn (decompressed == null) ? val : this._deserialize(decompressed)\n\t}\n\n\tfunction set(super_fn, key, val) {\n\t\tvar compressed = LZString.compress(this._serialize(val))\n\t\tsuper_fn(key, compressed)\n\t}\n}\n"
  },
  {
    "path": "plugins/compression_test.js",
    "content": "var { deepEqual } = require('../tests/util')\n\nmodule.exports = {\n\tplugin: require('./compression'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\ttest('string compression size', function() {\n\t\tvar str = 'foo'\n\t\tvar serialized = store._serialize(str)\n\t\tstore.set('foo', str)\n\t\tassert(store.raw.get('foo').length < serialized.length, 'compressed string should be smaller than uncompressed')\n\t\tassert(deepEqual(store.get('foo'), str), 'value should be equal')\n\t})\n\n\ttest('object compression', function () {\n\t\tvar obj = { one: { two: 3 }}\n\t\tvar serialized = store._serialize(obj)\n\t\tstore.set('foo', obj)\n\t\tassert(store.raw.get('foo').length < serialized.length, 'compressed object should be smaller than uncompressed')\n\t\tassert(deepEqual(store.get('foo'), obj), 'should deep equal original object')\n\t\tstore.remove('foo')\n\t})\n\n\ttest('decompress uncopmressed data', function () {\n\t\tstore.raw.set('foo', 'baz')\n\t\tassert(store.get('foo') == 'baz', 'value should be baz')\n\t\tstore.remove('foo')\n\t})\n\n\ttest('decompress non-existing data', function () {\n\t\tassert(store.get('bar') == undefined, 'value should be undefined')\n\t\tstore.remove('bar')\n\t})\n\n}\n"
  },
  {
    "path": "plugins/defaults.js",
    "content": "module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"
  },
  {
    "path": "plugins/defaults_test.js",
    "content": "module.exports = {\n\tplugin: require('./defaults'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\t\n\ttest('defaults', function() {\n\t\tstore.defaults({ foo: 'bar' })\n\t\tassert(store.get('foo') == 'bar')\n\t\tstore.set('foo', 'bar2')\n\t\tassert(store.get('foo') == 'bar2')\n\t\tstore.remove('foo')\n\t\tassert(store.get('foo') == 'bar')\n\t})\n\n}\n"
  },
  {
    "path": "plugins/dump.js",
    "content": "module.exports = dumpPlugin\n\nfunction dumpPlugin() {\n\treturn {\n\t\tdump: dump\n\t}\n\t\n\tfunction dump(_) {\n\t\tvar res = {}\n\t\tthis.each(function(val, key) {\n\t\t\tres[key] = val\n\t\t})\n\t\treturn res\n\t}\n}\n"
  },
  {
    "path": "plugins/dump_test.js",
    "content": "var { each } = require('../src/util')\nvar { deepEqual } = require('../tests/util')\n\nmodule.exports = {\n\tplugin: require('./dump'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\t\n\ttest('dump', function() {\n\t\tvar allValues = {\n\t\t\t'foo': 'bar',\n\t\t\t'cat': { mat:true },\n\t\t\t'hat': 'bat'\n\t\t}\n\t\teach(allValues, function(val, key) {\n\t\t\tstore.set(key, val)\n\t\t})\n\t\t\n\t\tassert(deepEqual(store.dump(), allValues))\n\t\tstore.clearAll()\n\t\tassert(deepEqual(store.dump(), {}))\t\t\n\t})\n}\n"
  },
  {
    "path": "plugins/events.js",
    "content": "var util = require('../src/util')\nvar bind = util.bind\nvar each = util.each\nvar create = util.create\nvar slice = util.slice\n\nmodule.exports = eventsPlugin\n\nfunction eventsPlugin() {\n\tvar pubsub = _newPubSub()\n\n\treturn {\n\t\twatch: watch,\n\t\tunwatch: unwatch,\n\t\tonce: once,\n\n\t\tset: set,\n\t\tremove: remove,\n\t\tclearAll: clearAll\n\t}\n\n\t// new pubsub functions\n\tfunction watch(_, key, listener) {\n\t\treturn pubsub.on(key, bind(this, listener))\n\t}\n\tfunction unwatch(_, subId) {\n\t\tpubsub.off(subId)\n\t}\n\tfunction once(_, key, listener) {\n\t\tpubsub.once(key, bind(this, listener))\n\t}\n\n\t// overwrite function to fire when appropriate\n\tfunction set(super_fn, key, val) {\n\t\tvar oldVal = this.get(key)\n\t\tsuper_fn()\n\t\tpubsub.fire(key, val, oldVal)\n\t}\n\tfunction remove(super_fn, key) {\n\t\tvar oldVal = this.get(key)\n\t\tsuper_fn()\n\t\tpubsub.fire(key, undefined, oldVal)\n\t}\n\tfunction clearAll(super_fn) {\n\t\tvar oldVals = {}\n\t\tthis.each(function(val, key) {\n\t\t\toldVals[key] = val\n\t\t})\n\t\tsuper_fn()\n\t\teach(oldVals, function(oldVal, key) {\n\t\t\tpubsub.fire(key, undefined, oldVal)\n\t\t})\n\t}\n}\n\n\nfunction _newPubSub() {\n\treturn create(_pubSubBase, {\n\t\t_id: 0,\n\t\t_subSignals: {},\n\t\t_subCallbacks: {}\n\t})\n}\n\nvar _pubSubBase = {\n\t_id: null,\n\t_subCallbacks: null,\n\t_subSignals: null,\n\ton: function(signal, callback) {\n\t\tif (!this._subCallbacks[signal]) {\n\t\t\tthis._subCallbacks[signal] = {}\n\t\t}\n\t\tthis._id += 1\n\t\tthis._subCallbacks[signal][this._id] = callback\n\t\tthis._subSignals[this._id] = signal\n\t\treturn this._id\n\t},\n\toff: function(subId) {\n\t\tvar signal = this._subSignals[subId]\n\t\tdelete this._subCallbacks[signal][subId]\n\t\tdelete this._subSignals[subId]\n\t},\n\tonce: function(signal, callback) {\n\t\tvar subId = this.on(signal, bind(this, function() {\n\t\t\tcallback.apply(this, arguments)\n\t\t\tthis.off(subId)\n\t\t}))\n\t},\n\tfire: function(signal) {\n\t\tvar args = slice(arguments, 1)\n\t\teach(this._subCallbacks[signal], function(callback) {\n\t\t\tcallback.apply(this, args)\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "plugins/events_test.js",
    "content": "module.exports = {\n\tplugin: require('./events'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\t\n\ttest('events', function() {\n\t\tstore.set('foo', 'bar')\n\t\t\n\t\tvar expectationNone = _createExpectation('expectNone', undefined)\n\t\tstore.watch('foo', function(){})\n\t\tvar expectation1 = _createExpectation('foo', 'bar')\n\t\tvar expectationOnce = _createExpectation('foo', 'bar', true)\n\t\tstore.watch('foo', function(){})\n\t\t\n\t\texpectation1.add('bar2')\n\t\texpectationOnce.add('bar2')\n\t\tstore.set('foo', 'bar2')\n\t\t\n\t\texpectation1.add(undefined)\n\t\tstore.remove('foo')\n\t\t\n\t\texpectation1.add('bar3')\n\t\tstore.set('foo', 'bar3')\n\t\t\n\t\tvar expectation2 = _createExpectation('foo', 'bar3')\n\t\texpectation1.add(undefined)\n\t\texpectation2.add(undefined)\n\t\tstore.clearAll() // Should fire for foo\n\t\tstore.clearAll() // Should not fire anything\n\t\t\n\t\texpectation1.unwatch()\n\t\texpectation2.add('bar4')\n\t\tstore.set('foo', 'bar4') // Should only fire for expectation2\n\t\t\n\t\texpectation1.check()\n\t\texpectationOnce.check()\n\t\texpectation2.check()\n\t\texpectationNone.check()\n\t\texpectation2.unwatch()\n\t})\n\t\n\tfunction _createExpectation(key, firstOldVal, useOnce) {\n\t\tvar expectation = {\n\t\t\tvalues: [firstOldVal],\n\t\t\tcount: 0,\n\t\t\tadd: function(value) {\n\t\t\t\tthis.values.push(value)\n\t\t\t},\n\t\t\tcheck: function() {\n\t\t\t\tassert(expectation.count + 1 == expectation.values.length)\n\t\t\t},\n\t\t\tunwatch: function() {\n\t\t\t\tstore.unwatch(watchId)\n\t\t\t}\n\t\t}\n\t\t\n\t\tvar watchId = (useOnce\n\t\t\t? store.once(key, callback)\n\t\t\t: store.watch(key, callback)\n\t\t)\n\t\tfunction callback(val, oldVal) {\n\t\t\texpectation.count += 1\n\t\t\tassert(expectation.values[expectation.count] == val)\n\t\t\tassert(expectation.values[expectation.count - 1] == oldVal)\n\t\t}\n\t\t\n\t\treturn expectation\n\t}\t\n}\n"
  },
  {
    "path": "plugins/expire.js",
    "content": "var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i<keys.length; i++) {\n\t\t\t_checkExpiration.call(this, keys[i])\n\t\t}\n\t}\n\t\n\tfunction _checkExpiration(key) {\n\t\tvar expiration = expirations.get(key, Number.MAX_VALUE)\n\t\tif (expiration <= new Date().getTime()) {\n\t\t\tthis.raw.remove(key)\n\t\t\texpirations.remove(key)\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "plugins/expire_test.js",
    "content": "module.exports = {\n\tplugin: require('./expire'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\n\ttest('expire', function(done) {\n\t\t// Ive observed multiple times when legacy browsers in various\n\t\t// environments (saucelabs, VMs, etc) have executed a scheduled\n\t\t// timeout function too soon. The solution is to run a longer,\n\t\t// timeout, but this substantially slows down the test suite.\n\t\t// Instead, we allow multiple attempts with increasing durations.\n\t\tattempt(5, 10)\n\t\t\n\t\tfunction attempt(remaining, duration) {\n\t\t\trunTests(duration, function check(ok) {\n\t\t\t\tif (ok) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\tattempt(remaining - 1, duration * 2)\n\t\t\t\t\t}, 0)\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn assert(false)\n\t\t\t})\t\t\t\n\t\t}\n\n\t\tfunction runTests(duration, check) {\n\t\t\tvar expiration = new Date().getTime() + duration\n\t\t\tstore.set('foo', 'bar', expiration)\t\t\t\n\t\t\tif (!check(store.get('foo') == 'bar')) { return }\n\t\t\t\n\t\t\tsetTimeout(function() {\n\t\t\t\tif (!check(new Date().getTime() > expiration)) { return }\n\t\t\t\tif (!check(store.get('foo') == undefined)) { return }\n\t\t\t\t\n\t\t\t\tstore.set('foo', 'bar')\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tif (!check(store.get('foo') == 'bar')) { return }\n\t\t\t\t\t\n\t\t\t\t\tdone()\n\t\t\t\t}, 5)\n\t\t\t}, duration)\n\t\t}\n\t})\n\t\n\ttest('remove expired keys', function() {\n\t\tvar key = 'expired'\n\t\tstore.set(key, 'bar', new Date().getTime() - 1000)\n\t\tassert(store.getExpiration(key) > 0)\n\t\tstore.removeExpiredKeys()\n\t\tassert(!store.getExpiration(key))\n\t})\n}\n"
  },
  {
    "path": "plugins/json2.js",
    "content": "module.exports = json2Plugin\n\nfunction json2Plugin() {\n\trequire('./lib/json2')\n\treturn {}\n}\n"
  },
  {
    "path": "plugins/json2_test.js",
    "content": "module.exports = {\n\tplugin: require('./json2'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\t\n\ttest('serialization with json2', function() {\n\t\tstore.set('foo', { bar:'cat' })\n\t\tassert(store.get('foo').bar === 'cat')\n\t})\n}\n"
  },
  {
    "path": "plugins/lib/json2.js",
    "content": "/* eslint-disable */\n\n//  json2.js\n//  2016-10-28\n//  Public Domain.\n//  NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n//  See http://www.JSON.org/js.html\n//  This code should be minified before deployment.\n//  See http://javascript.crockford.com/jsmin.html\n\n//  USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n//  NOT CONTROL.\n\n//  This file creates a global JSON object containing two methods: stringify\n//  and parse. This file provides the ES5 JSON capability to ES3 systems.\n//  If a project might run on IE8 or earlier, then this file should be included.\n//  This file does nothing on ES5 systems.\n\n//      JSON.stringify(value, replacer, space)\n//          value       any JavaScript value, usually an object or array.\n//          replacer    an optional parameter that determines how object\n//                      values are stringified for objects. It can be a\n//                      function or an array of strings.\n//          space       an optional parameter that specifies the indentation\n//                      of nested structures. If it is omitted, the text will\n//                      be packed without extra whitespace. If it is a number,\n//                      it will specify the number of spaces to indent at each\n//                      level. If it is a string (such as \"\\t\" or \"&nbsp;\"),\n//                      it contains the characters used to indent at each level.\n//          This method produces a JSON text from a JavaScript value.\n//          When an object value is found, if the object contains a toJSON\n//          method, its toJSON method will be called and the result will be\n//          stringified. A toJSON method does not serialize: it returns the\n//          value represented by the name/value pair that should be serialized,\n//          or undefined if nothing should be serialized. The toJSON method\n//          will be passed the key associated with the value, and this will be\n//          bound to the value.\n\n//          For example, this would serialize Dates as ISO strings.\n\n//              Date.prototype.toJSON = function (key) {\n//                  function f(n) {\n//                      // Format integers to have at least two digits.\n//                      return (n < 10)\n//                          ? \"0\" + n\n//                          : n;\n//                  }\n//                  return this.getUTCFullYear()   + \"-\" +\n//                       f(this.getUTCMonth() + 1) + \"-\" +\n//                       f(this.getUTCDate())      + \"T\" +\n//                       f(this.getUTCHours())     + \":\" +\n//                       f(this.getUTCMinutes())   + \":\" +\n//                       f(this.getUTCSeconds())   + \"Z\";\n//              };\n\n//          You can provide an optional replacer method. It will be passed the\n//          key and value of each member, with this bound to the containing\n//          object. The value that is returned from your method will be\n//          serialized. If your method returns undefined, then the member will\n//          be excluded from the serialization.\n\n//          If the replacer parameter is an array of strings, then it will be\n//          used to select the members to be serialized. It filters the results\n//          such that only members with keys listed in the replacer array are\n//          stringified.\n\n//          Values that do not have JSON representations, such as undefined or\n//          functions, will not be serialized. Such values in objects will be\n//          dropped; in arrays they will be replaced with null. You can use\n//          a replacer function to replace those with JSON values.\n\n//          JSON.stringify(undefined) returns undefined.\n\n//          The optional space parameter produces a stringification of the\n//          value that is filled with line breaks and indentation to make it\n//          easier to read.\n\n//          If the space parameter is a non-empty string, then that string will\n//          be used for indentation. If the space parameter is a number, then\n//          the indentation will be that many spaces.\n\n//          Example:\n\n//          text = JSON.stringify([\"e\", {pluribus: \"unum\"}]);\n//          // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n//          text = JSON.stringify([\"e\", {pluribus: \"unum\"}], null, \"\\t\");\n//          // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n//          text = JSON.stringify([new Date()], function (key, value) {\n//              return this[key] instanceof Date\n//                  ? \"Date(\" + this[key] + \")\"\n//                  : value;\n//          });\n//          // text is '[\"Date(---current time---)\"]'\n\n//      JSON.parse(text, reviver)\n//          This method parses a JSON text to produce an object or array.\n//          It can throw a SyntaxError exception.\n\n//          The optional reviver parameter is a function that can filter and\n//          transform the results. It receives each of the keys and values,\n//          and its return value is used instead of the original value.\n//          If it returns what it received, then the structure is not modified.\n//          If it returns undefined then the member is deleted.\n\n//          Example:\n\n//          // Parse the text. Values that look like ISO date strings will\n//          // be converted to Date objects.\n\n//          myData = JSON.parse(text, function (key, value) {\n//              var a;\n//              if (typeof value === \"string\") {\n//                  a =\n//   /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n//                  if (a) {\n//                      return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n//                          +a[5], +a[6]));\n//                  }\n//              }\n//              return value;\n//          });\n\n//          myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n//              var d;\n//              if (typeof value === \"string\" &&\n//                      value.slice(0, 5) === \"Date(\" &&\n//                      value.slice(-1) === \")\") {\n//                  d = new Date(value.slice(5, -1));\n//                  if (d) {\n//                      return d;\n//                  }\n//              }\n//              return value;\n//          });\n\n//  This is a reference implementation. You are free to copy, modify, or\n//  redistribute.\n\n/*jslint\n    eval, for, this\n*/\n\n/*property\n    JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== \"object\") {\n    JSON = {};\n}\n\n(function () {\n    \"use strict\";\n\n    var rx_one = /^[\\],:{}\\s]*$/;\n    var rx_two = /\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g;\n    var rx_three = /\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g;\n    var rx_four = /(?:^|:|,)(?:\\s*\\[)+/g;\n    var rx_escapable = /[\\\\\"\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g;\n    var rx_dangerous = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g;\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10\n            ? \"0\" + n\n            : n;\n    }\n\n    function this_value() {\n        return this.valueOf();\n    }\n\n    if (typeof Date.prototype.toJSON !== \"function\") {\n\n        Date.prototype.toJSON = function () {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear() + \"-\" +\n                        f(this.getUTCMonth() + 1) + \"-\" +\n                        f(this.getUTCDate()) + \"T\" +\n                        f(this.getUTCHours()) + \":\" +\n                        f(this.getUTCMinutes()) + \":\" +\n                        f(this.getUTCSeconds()) + \"Z\"\n                : null;\n        };\n\n        Boolean.prototype.toJSON = this_value;\n        Number.prototype.toJSON = this_value;\n        String.prototype.toJSON = this_value;\n    }\n\n    var gap;\n    var indent;\n    var meta;\n    var rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        rx_escapable.lastIndex = 0;\n        return rx_escapable.test(string)\n            ? \"\\\"\" + string.replace(rx_escapable, function (a) {\n                var c = meta[a];\n                return typeof c === \"string\"\n                    ? c\n                    : \"\\\\u\" + (\"0000\" + a.charCodeAt(0).toString(16)).slice(-4);\n            }) + \"\\\"\"\n            : \"\\\"\" + string + \"\\\"\";\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i;          // The loop counter.\n        var k;          // The member key.\n        var v;          // The member value.\n        var length;\n        var mind = gap;\n        var partial;\n        var value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === \"object\" &&\n                typeof value.toJSON === \"function\") {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === \"function\") {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case \"string\":\n            return quote(value);\n\n        case \"number\":\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value)\n                ? String(value)\n                : \"null\";\n\n        case \"boolean\":\n        case \"null\":\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce \"null\". The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is \"object\", we might be dealing with an object or an array or\n// null.\n\n        case \"object\":\n\n// Due to a specification blunder in ECMAScript, typeof null is \"object\",\n// so watch out for that case.\n\n            if (!value) {\n                return \"null\";\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === \"[object Array]\") {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || \"null\";\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? \"[]\"\n                    : gap\n                        ? \"[\\n\" + gap + partial.join(\",\\n\" + gap) + \"\\n\" + mind + \"]\"\n                        : \"[\" + partial.join(\",\") + \"]\";\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === \"object\") {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === \"string\") {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (\n                                gap\n                                    ? \": \"\n                                    : \":\"\n                            ) + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (\n                                gap\n                                    ? \": \"\n                                    : \":\"\n                            ) + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? \"{}\"\n                : gap\n                    ? \"{\\n\" + gap + partial.join(\",\\n\" + gap) + \"\\n\" + mind + \"}\"\n                    : \"{\" + partial.join(\",\") + \"}\";\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== \"function\") {\n        meta = {    // table of character substitutions\n            \"\\b\": \"\\\\b\",\n            \"\\t\": \"\\\\t\",\n            \"\\n\": \"\\\\n\",\n            \"\\f\": \"\\\\f\",\n            \"\\r\": \"\\\\r\",\n            \"\\\"\": \"\\\\\\\"\",\n            \"\\\\\": \"\\\\\\\\\"\n        };\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = \"\";\n            indent = \"\";\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === \"number\") {\n                for (i = 0; i < space; i += 1) {\n                    indent += \" \";\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === \"string\") {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== \"function\" &&\n                    (typeof replacer !== \"object\" ||\n                    typeof replacer.length !== \"number\")) {\n                throw new Error(\"JSON.stringify\");\n            }\n\n// Make a fake root object containing our value under the key of \"\".\n// Return the result of stringifying the value.\n\n            return str(\"\", {\"\": value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== \"function\") {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k;\n                var v;\n                var value = holder[key];\n                if (value && typeof value === \"object\") {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            rx_dangerous.lastIndex = 0;\n            if (rx_dangerous.test(text)) {\n                text = text.replace(rx_dangerous, function (a) {\n                    return \"\\\\u\" +\n                            (\"0000\" + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with \"()\" and \"new\"\n// because they can cause invocation, and \"=\" because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with \"@\" (a non-JSON character). Second, we\n// replace all simple value tokens with \"]\" characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or \"]\" or\n// \",\" or \":\" or \"{\" or \"}\". If that is so, then the text is safe for eval.\n\n            if (\n                rx_one.test(\n                    text\n                        .replace(rx_two, \"@\")\n                        .replace(rx_three, \"]\")\n                        .replace(rx_four, \"\")\n                )\n            ) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The \"{\" operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval(\"(\" + text + \")\");\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return (typeof reviver === \"function\")\n                    ? walk({\"\": j}, \"\")\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError(\"JSON.parse\");\n        };\n    }\n}());"
  },
  {
    "path": "plugins/lib/lz-string.js",
    "content": "/* eslint-disable */\n// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>\n// This work is free. You can redistribute it and/or modify it\n// under the terms of the WTFPL, Version 2\n// For more information see LICENSE.txt or http://www.wtfpl.net/\n//\n// For more information, the home page:\n// http://pieroxy.net/blog/pages/lz-string/testing.html\n//\n// LZ-based compression algorithm, version 1.4.4\nvar LZString = (function() {\n\n// private property\nvar f = String.fromCharCode;\nvar keyStrBase64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\nvar keyStrUriSafe = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$\";\nvar baseReverseDic = {};\n\nfunction getBaseValue(alphabet, character) {\n  if (!baseReverseDic[alphabet]) {\n    baseReverseDic[alphabet] = {};\n    for (var i=0 ; i<alphabet.length ; i++) {\n      baseReverseDic[alphabet][alphabet.charAt(i)] = i;\n    }\n  }\n  return baseReverseDic[alphabet][character];\n}\n\nvar LZString = {\n  compressToBase64 : function (input) {\n    if (input == null) return \"\";\n    var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});\n    switch (res.length % 4) { // To produce valid Base64\n    default: // When could this happen ?\n    case 0 : return res;\n    case 1 : return res+\"===\";\n    case 2 : return res+\"==\";\n    case 3 : return res+\"=\";\n    }\n  },\n\n  decompressFromBase64 : function (input) {\n    if (input == null) return \"\";\n    if (input == \"\") return null;\n    return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });\n  },\n\n  compressToUTF16 : function (input) {\n    if (input == null) return \"\";\n    return LZString._compress(input, 15, function(a){return f(a+32);}) + \" \";\n  },\n\n  decompressFromUTF16: function (compressed) {\n    if (compressed == null) return \"\";\n    if (compressed == \"\") return null;\n    return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });\n  },\n\n  //compress into uint8array (UCS-2 big endian format)\n  compressToUint8Array: function (uncompressed) {\n    var compressed = LZString.compress(uncompressed);\n    var buf=new Uint8Array(compressed.length*2); // 2 bytes per character\n\n    for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {\n      var current_value = compressed.charCodeAt(i);\n      buf[i*2] = current_value >>> 8;\n      buf[i*2+1] = current_value % 256;\n    }\n    return buf;\n  },\n\n  //decompress from uint8array (UCS-2 big endian format)\n  decompressFromUint8Array:function (compressed) {\n    if (compressed===null || compressed===undefined){\n        return LZString.decompress(compressed);\n    } else {\n        var buf=new Array(compressed.length/2); // 2 bytes per character\n        for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {\n          buf[i]=compressed[i*2]*256+compressed[i*2+1];\n        }\n\n        var result = [];\n        buf.forEach(function (c) {\n          result.push(f(c));\n        });\n        return LZString.decompress(result.join(''));\n\n    }\n\n  },\n\n\n  //compress into a string that is already URI encoded\n  compressToEncodedURIComponent: function (input) {\n    if (input == null) return \"\";\n    return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});\n  },\n\n  //decompress from an output of compressToEncodedURIComponent\n  decompressFromEncodedURIComponent:function (input) {\n    if (input == null) return \"\";\n    if (input == \"\") return null;\n    input = input.replace(/ /g, \"+\");\n    return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });\n  },\n\n  compress: function (uncompressed) {\n    return LZString._compress(uncompressed, 16, function(a){return f(a);});\n  },\n  _compress: function (uncompressed, bitsPerChar, getCharFromInt) {\n    if (uncompressed == null) return \"\";\n    var i, value,\n        context_dictionary= {},\n        context_dictionaryToCreate= {},\n        context_c=\"\",\n        context_wc=\"\",\n        context_w=\"\",\n        context_enlargeIn= 2, // Compensate for the first entry which should not count\n        context_dictSize= 3,\n        context_numBits= 2,\n        context_data=[],\n        context_data_val=0,\n        context_data_position=0,\n        ii;\n\n    for (ii = 0; ii < uncompressed.length; ii += 1) {\n      context_c = uncompressed.charAt(ii);\n      if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {\n        context_dictionary[context_c] = context_dictSize++;\n        context_dictionaryToCreate[context_c] = true;\n      }\n\n      context_wc = context_w + context_c;\n      if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {\n        context_w = context_wc;\n      } else {\n        if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {\n          if (context_w.charCodeAt(0)<256) {\n            for (i=0 ; i<context_numBits ; i++) {\n              context_data_val = (context_data_val << 1);\n              if (context_data_position == bitsPerChar-1) {\n                context_data_position = 0;\n                context_data.push(getCharFromInt(context_data_val));\n                context_data_val = 0;\n              } else {\n                context_data_position++;\n              }\n            }\n            value = context_w.charCodeAt(0);\n            for (i=0 ; i<8 ; i++) {\n              context_data_val = (context_data_val << 1) | (value&1);\n              if (context_data_position == bitsPerChar-1) {\n                context_data_position = 0;\n                context_data.push(getCharFromInt(context_data_val));\n                context_data_val = 0;\n              } else {\n                context_data_position++;\n              }\n              value = value >> 1;\n            }\n          } else {\n            value = 1;\n            for (i=0 ; i<context_numBits ; i++) {\n              context_data_val = (context_data_val << 1) | value;\n              if (context_data_position ==bitsPerChar-1) {\n                context_data_position = 0;\n                context_data.push(getCharFromInt(context_data_val));\n                context_data_val = 0;\n              } else {\n                context_data_position++;\n              }\n              value = 0;\n            }\n            value = context_w.charCodeAt(0);\n            for (i=0 ; i<16 ; i++) {\n              context_data_val = (context_data_val << 1) | (value&1);\n              if (context_data_position == bitsPerChar-1) {\n                context_data_position = 0;\n                context_data.push(getCharFromInt(context_data_val));\n                context_data_val = 0;\n              } else {\n                context_data_position++;\n              }\n              value = value >> 1;\n            }\n          }\n          context_enlargeIn--;\n          if (context_enlargeIn == 0) {\n            context_enlargeIn = Math.pow(2, context_numBits);\n            context_numBits++;\n          }\n          delete context_dictionaryToCreate[context_w];\n        } else {\n          value = context_dictionary[context_w];\n          for (i=0 ; i<context_numBits ; i++) {\n            context_data_val = (context_data_val << 1) | (value&1);\n            if (context_data_position == bitsPerChar-1) {\n              context_data_position = 0;\n              context_data.push(getCharFromInt(context_data_val));\n              context_data_val = 0;\n            } else {\n              context_data_position++;\n            }\n            value = value >> 1;\n          }\n\n\n        }\n        context_enlargeIn--;\n        if (context_enlargeIn == 0) {\n          context_enlargeIn = Math.pow(2, context_numBits);\n          context_numBits++;\n        }\n        // Add wc to the dictionary.\n        context_dictionary[context_wc] = context_dictSize++;\n        context_w = String(context_c);\n      }\n    }\n\n    // Output the code for w.\n    if (context_w !== \"\") {\n      if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {\n        if (context_w.charCodeAt(0)<256) {\n          for (i=0 ; i<context_numBits ; i++) {\n            context_data_val = (context_data_val << 1);\n            if (context_data_position == bitsPerChar-1) {\n              context_data_position = 0;\n              context_data.push(getCharFromInt(context_data_val));\n              context_data_val = 0;\n            } else {\n              context_data_position++;\n            }\n          }\n          value = context_w.charCodeAt(0);\n          for (i=0 ; i<8 ; i++) {\n            context_data_val = (context_data_val << 1) | (value&1);\n            if (context_data_position == bitsPerChar-1) {\n              context_data_position = 0;\n              context_data.push(getCharFromInt(context_data_val));\n              context_data_val = 0;\n            } else {\n              context_data_position++;\n            }\n            value = value >> 1;\n          }\n        } else {\n          value = 1;\n          for (i=0 ; i<context_numBits ; i++) {\n            context_data_val = (context_data_val << 1) | value;\n            if (context_data_position == bitsPerChar-1) {\n              context_data_position = 0;\n              context_data.push(getCharFromInt(context_data_val));\n              context_data_val = 0;\n            } else {\n              context_data_position++;\n            }\n            value = 0;\n          }\n          value = context_w.charCodeAt(0);\n          for (i=0 ; i<16 ; i++) {\n            context_data_val = (context_data_val << 1) | (value&1);\n            if (context_data_position == bitsPerChar-1) {\n              context_data_position = 0;\n              context_data.push(getCharFromInt(context_data_val));\n              context_data_val = 0;\n            } else {\n              context_data_position++;\n            }\n            value = value >> 1;\n          }\n        }\n        context_enlargeIn--;\n        if (context_enlargeIn == 0) {\n          context_enlargeIn = Math.pow(2, context_numBits);\n          context_numBits++;\n        }\n        delete context_dictionaryToCreate[context_w];\n      } else {\n        value = context_dictionary[context_w];\n        for (i=0 ; i<context_numBits ; i++) {\n          context_data_val = (context_data_val << 1) | (value&1);\n          if (context_data_position == bitsPerChar-1) {\n            context_data_position = 0;\n            context_data.push(getCharFromInt(context_data_val));\n            context_data_val = 0;\n          } else {\n            context_data_position++;\n          }\n          value = value >> 1;\n        }\n\n\n      }\n      context_enlargeIn--;\n      if (context_enlargeIn == 0) {\n        context_enlargeIn = Math.pow(2, context_numBits);\n        context_numBits++;\n      }\n    }\n\n    // Mark the end of the stream\n    value = 2;\n    for (i=0 ; i<context_numBits ; i++) {\n      context_data_val = (context_data_val << 1) | (value&1);\n      if (context_data_position == bitsPerChar-1) {\n        context_data_position = 0;\n        context_data.push(getCharFromInt(context_data_val));\n        context_data_val = 0;\n      } else {\n        context_data_position++;\n      }\n      value = value >> 1;\n    }\n\n    // Flush the last char\n    while (true) {\n      context_data_val = (context_data_val << 1);\n      if (context_data_position == bitsPerChar-1) {\n        context_data.push(getCharFromInt(context_data_val));\n        break;\n      }\n      else context_data_position++;\n    }\n    return context_data.join('');\n  },\n\n  decompress: function (compressed) {\n    if (compressed == null) return \"\";\n    if (compressed == \"\") return null;\n    return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });\n  },\n\n  _decompress: function (length, resetValue, getNextValue) {\n    var dictionary = [],\n        next,\n        enlargeIn = 4,\n        dictSize = 4,\n        numBits = 3,\n        entry = \"\",\n        result = [],\n        i,\n        w,\n        bits, resb, maxpower, power,\n        c,\n        data = {val:getNextValue(0), position:resetValue, index:1};\n\n    for (i = 0; i < 3; i += 1) {\n      dictionary[i] = i;\n    }\n\n    bits = 0;\n    maxpower = Math.pow(2,2);\n    power=1;\n    while (power!=maxpower) {\n      resb = data.val & data.position;\n      data.position >>= 1;\n      if (data.position == 0) {\n        data.position = resetValue;\n        data.val = getNextValue(data.index++);\n      }\n      bits |= (resb>0 ? 1 : 0) * power;\n      power <<= 1;\n    }\n\n    switch (next = bits) {\n      case 0:\n          bits = 0;\n          maxpower = Math.pow(2,8);\n          power=1;\n          while (power!=maxpower) {\n            resb = data.val & data.position;\n            data.position >>= 1;\n            if (data.position == 0) {\n              data.position = resetValue;\n              data.val = getNextValue(data.index++);\n            }\n            bits |= (resb>0 ? 1 : 0) * power;\n            power <<= 1;\n          }\n        c = f(bits);\n        break;\n      case 1:\n          bits = 0;\n          maxpower = Math.pow(2,16);\n          power=1;\n          while (power!=maxpower) {\n            resb = data.val & data.position;\n            data.position >>= 1;\n            if (data.position == 0) {\n              data.position = resetValue;\n              data.val = getNextValue(data.index++);\n            }\n            bits |= (resb>0 ? 1 : 0) * power;\n            power <<= 1;\n          }\n        c = f(bits);\n        break;\n      case 2:\n        return \"\";\n    }\n    dictionary[3] = c;\n    w = c;\n    result.push(c);\n    while (true) {\n      if (data.index > length) {\n        return \"\";\n      }\n\n      bits = 0;\n      maxpower = Math.pow(2,numBits);\n      power=1;\n      while (power!=maxpower) {\n        resb = data.val & data.position;\n        data.position >>= 1;\n        if (data.position == 0) {\n          data.position = resetValue;\n          data.val = getNextValue(data.index++);\n        }\n        bits |= (resb>0 ? 1 : 0) * power;\n        power <<= 1;\n      }\n\n      switch (c = bits) {\n        case 0:\n          bits = 0;\n          maxpower = Math.pow(2,8);\n          power=1;\n          while (power!=maxpower) {\n            resb = data.val & data.position;\n            data.position >>= 1;\n            if (data.position == 0) {\n              data.position = resetValue;\n              data.val = getNextValue(data.index++);\n            }\n            bits |= (resb>0 ? 1 : 0) * power;\n            power <<= 1;\n          }\n\n          dictionary[dictSize++] = f(bits);\n          c = dictSize-1;\n          enlargeIn--;\n          break;\n        case 1:\n          bits = 0;\n          maxpower = Math.pow(2,16);\n          power=1;\n          while (power!=maxpower) {\n            resb = data.val & data.position;\n            data.position >>= 1;\n            if (data.position == 0) {\n              data.position = resetValue;\n              data.val = getNextValue(data.index++);\n            }\n            bits |= (resb>0 ? 1 : 0) * power;\n            power <<= 1;\n          }\n          dictionary[dictSize++] = f(bits);\n          c = dictSize-1;\n          enlargeIn--;\n          break;\n        case 2:\n          return result.join('');\n      }\n\n      if (enlargeIn == 0) {\n        enlargeIn = Math.pow(2, numBits);\n        numBits++;\n      }\n\n      if (dictionary[c]) {\n        entry = dictionary[c];\n      } else {\n        if (c === dictSize) {\n          entry = w + w.charAt(0);\n        } else {\n          return null;\n        }\n      }\n      result.push(entry);\n\n      // Add w+entry[0] to the dictionary.\n      dictionary[dictSize++] = w + entry.charAt(0);\n      enlargeIn--;\n\n      w = entry;\n\n      if (enlargeIn == 0) {\n        enlargeIn = Math.pow(2, numBits);\n        numBits++;\n      }\n\n    }\n  }\n};\n  return LZString;\n})();\n\nif (typeof define === 'function' && define.amd) {\n  define(function () { return LZString; });\n} else if( typeof module !== 'undefined' && module != null ) {\n  module.exports = LZString\n}\n"
  },
  {
    "path": "plugins/observe.js",
    "content": "var eventsPlugin = require('./events')\n\nmodule.exports = [eventsPlugin, observePlugin]\n\nfunction observePlugin() {\n\treturn {\n\t\tobserve: observe,\n\t\tunobserve: unobserve\n\t}\n\n\tfunction observe(_, key, callback) {\n\t\tvar subId = this.watch(key, callback)\n\t\tcallback(this.get(key))\n\t\treturn subId\n\t}\n\tfunction unobserve(_, subId) {\n\t\tthis.unwatch(subId)\n\t}\n}\n"
  },
  {
    "path": "plugins/observe_test.js",
    "content": "module.exports = {\n\tplugin: require('./observe'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\t\n\ttest('observe', function() {\n\t\tstore.clearAll()\n\t\tvar count = -1\n\t\tvar expect = [undefined]\n\t\tvar obsId = store.observe('foo', function(val, oldVal) {\n\t\t\tcount += 1\n\t\t\tassert(expect[count] == val)\n\t\t\tassert(expect[count - 1] == oldVal)\n\t\t}) // count == 1\n\t\tstore.unobserve(obsId)\n\n\t\texpect.push('bar')\n\t\tstore.set('foo', 'bar')\n\t\tstore.observe('foo', function(val, oldVal) {\n\t\t\tcount += 1\n\t\t\tassert(expect[count] == val)\n\t\t\tassert(expect[count - 1] == oldVal)\n\t\t}) // count == 2\n\n\t\texpect.push('bar2')\n\t\tstore.set('foo', 'bar2') // count == 3\n\t\tassert(count + 1 == expect.length)\n\t})\n}\n"
  },
  {
    "path": "plugins/operations.js",
    "content": "var util = require('../src/util')\nvar slice = util.slice\nvar assign = util.assign\n\nvar updatePlugin = require('./update')\n\nmodule.exports = [updatePlugin, operationsPlugin]\n\nfunction operationsPlugin() {\n\treturn {\n\t\t// array\n\t\tpush: push,\n\t\tpop: pop,\n\t\tshift: shift,\n\t\tunshift: unshift,\n\n\t\t// obj\n\t\tassign: assign_,\n\t}\n\n\t// array\n\tfunction push(_, key, val1, val2, val3, etc) {\n\t\treturn _arrayOp.call(this, 'push', arguments)\n\t}\n\tfunction pop(_, key) {\n\t\treturn _arrayOp.call(this, 'pop', arguments)\n\t}\n\tfunction shift(_, key) {\n\t\treturn _arrayOp.call(this, 'shift', arguments)\n\t}\n\tfunction unshift(_, key, val1, val2, val3, etc) {\n\t\treturn _arrayOp.call(this, 'unshift', arguments)\n\t}\n\n\t// obj\n\tfunction assign_(_, key, props1, props2, props3, etc) {\n\t\tvar varArgs = slice(arguments, 2)\n\t\treturn this.update(key, {}, function(val) {\n\t\t\tif (typeof val != 'object') {\n\t\t\t\tthrow new Error('store.assign called for non-object value with key \"'+key+'\"')\n\t\t\t}\n\t\t\tvarArgs.unshift(val)\n\t\t\treturn assign.apply(Object, varArgs)\n\t\t})\n\t}\n\n\t// internal\n\t///////////\n\tfunction _arrayOp(arrayFn, opArgs) {\n\t\tvar res\n\t\tvar key = opArgs[1]\n\t\tvar rest = slice(opArgs, 2)\n\t\tthis.update(key, [], function(arrVal) {\n\t\t\tres = Array.prototype[arrayFn].apply(arrVal, rest)\n\t\t})\n\t\treturn res\n\t}\n}\n"
  },
  {
    "path": "plugins/operations_test.js",
    "content": "var { each, map } = require('../src/util')\nvar { deepEqual } = require('../tests/util')\n\nmodule.exports = {\n\tplugin: require('./operations'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\n\ttest('push', function() {\n\t\t_testArrayOp('push', [], [\n\t\t\t[],\n\t\t\t['a'],\n\t\t\t['b','c'],\n\t\t\t[null],\n\t\t\t[[], {}]\n\t\t])\n\t})\n\n\ttest('unshift', function() {\n\t\t_testArrayOp('unshift', undefined, [\n\t\t\t[],\n\t\t\t['a'],\n\t\t\t['b','c'],\n\t\t\t[null],\n\t\t\t[[], {}]\n\t\t])\n\t})\n\n\ttest('pop', function() {\n\t\tvar arr = ['a', 'b', 'c', null, [[], {}]]\n\t\t// Call pop arr.length + 1 times. No args each time\n\t\tvar argsList = map(arr, function() { return [] }).concat([])\n\t\t_testArrayOp('pop', arr, argsList)\n\t})\n\n\ttest('shift', function() {\n\t\tvar arr = ['a', 'b', 'c', null, [[], {}]]\n\t\t// Call shift arr.length + 1 times. No args each time\n\t\tvar argsList = map(arr, function() { return [] }).concat([])\n\t\t_testArrayOp('shift', arr, argsList)\n\t})\n\n\ttest('assign', function() {\n\t\tstore.clearAll()\n\t\tvar expect = { bar:'cat', mat:{ hat:'bat', arr:[1,2,3] }}\n\t\tstore.assign('foo', expect)\n\t\tassert(deepEqual(store.get('foo'), expect))\n\t\tvar add = { bar:'cat2', mat:{ hat:'bat2' }, newProp:'newProp'}\n\t\tstore.assign('foo', add)\n\t\teach(add, function(val, key) {\n\t\t\texpect[key] = val\n\t\t})\n\t\tassert(deepEqual(store.get('foo'), expect))\n\t})\n\n\tfunction _testArrayOp(fnName, arr, argLists) {\n\t\tvar key = 'test-'+fnName\n\t\tstore.set(key, arr)\n\t\tarr = (arr || [])\n\t\tvar arrFn = arr[fnName]\n\t\tvar storeFn = store[fnName]\n\t\teach(argLists, function(args) {\n\t\t\tvar expectedFnResult = arrFn.apply(arr, args)\n\t\t\tvar actualFnResult = storeFn.apply(store, [key].concat(args))\n\t\t\tassert(deepEqual(expectedFnResult, actualFnResult))\n\t\t\tvar actual = store.get(key)\n\t\t\tassert(deepEqual(arr, actual))\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "plugins/update.js",
    "content": "module.exports = updatePlugin\n\nfunction updatePlugin() {\n\treturn {\n\t\tupdate: update\n\t}\n\t\n\tfunction update(_, key, optDefaultVal, updateFn) {\n\t\tif (arguments.length == 3) {\n\t\t\tupdateFn = optDefaultVal\n\t\t\toptDefaultVal = undefined\n\t\t}\n\t\tvar val = this.get(key, optDefaultVal)\n\t\tvar retVal = updateFn(val)\n\t\tthis.set(key, retVal != undefined ? retVal : val)\n\t}\n}\n"
  },
  {
    "path": "plugins/update_test.js",
    "content": "module.exports = {\n\tplugin: require('./update'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\n\ttest('update', function() {\n\t\tstore.set('foo', { cat:'mat' })\n\t\tassert(store.get('foo').cat == 'mat')\n\t\tstore.update('foo', function(foo) {\n\t\t\tfoo.cat = 'mat2'\n\t\t})\n\t\tassert(store.get('foo').cat == 'mat2')\n\t})\n\n\ttest('update return value', function() {\n\t\tstore.clearAll()\n\t\tstore.update('foo', function(foo) {\n\t\t\tassert(foo == undefined)\n\t\t\treturn { cat:'mat4' }\n\t\t})\n\t\tassert(store.get('foo').cat == 'mat4')\n\t})\n\n\ttest('update default value', function() {\n\t\tstore.clearAll()\n\t\tstore.update('foo2', {}, function(foo2) {\n\t\t\tfoo2.bar = 'cat'\n\t\t})\n\t\tassert(store.get('foo2').bar == 'cat')\n\t})\n\n\ttest('update default value + return', function() {\n\t\tstore.clearAll()\n\t\tstore.update('foo2', [], function(foor2) {\n\t\t\treturn { bar2:'cat2' }\n\t\t})\n\t\tassert(typeof store.get('foo2') == 'object')\n\t\tassert(store.get('foo2').bar == undefined)\n\t\tassert(store.get('foo2').bar2 == 'cat2')\t\n\t})\n}\n"
  },
  {
    "path": "plugins/v1-backcompat.js",
    "content": "var dumpPlugin = require('./dump')\nvar json2Plugin = require('./json2')\n\nmodule.exports = [dumpPlugin, json2Plugin, v1BackcompatPlugin]\n\nfunction v1BackcompatPlugin() {\n\tthis.disabled = !this.enabled\n\treturn {\n\t\thas: backcompat_has,\n\t\ttransact: backcompat_transact,\n\t\tclear: backcompat_clear,\n\t\tforEach: backcompat_forEach,\n\t\tgetAll: backcompat_getAll,\n\t\tserialize: backcompat_serialize,\n\t\tdeserialize: backcompat_deserialize,\n\t}\n}\n\nfunction backcompat_has(_, key) {\n\treturn this.get(key) !== undefined\n}\nfunction backcompat_transact(_, key, defaultVal, transactionFn) {\n\tif (transactionFn == null) {\n\t\ttransactionFn = defaultVal\n\t\tdefaultVal = null\n\t}\n\tif (defaultVal == null) {\n\t\tdefaultVal = {}\n\t}\n\tvar val = this.get(key, defaultVal)\n\tvar ret = transactionFn(val)\n\tthis.set(key, ret === undefined ? val : ret)\n}\nfunction backcompat_clear(_) {\n\treturn this.clearAll.call(this)\n}\nfunction backcompat_forEach(_, fn) {\n\treturn this.each.call(this, function(val, key) {\n\t\tfn(key, val)\n\t})\n}\nfunction backcompat_getAll(_) {\n\treturn this.dump.call(this)\n}\nfunction backcompat_serialize(_, value) {\n\treturn JSON.stringify(value)\n}\nfunction backcompat_deserialize(_, value) {\n\tif (typeof value != 'string') { return undefined }\n\ttry { return JSON.parse(value) }\n\tcatch(e) { return value || undefined }\n}\n"
  },
  {
    "path": "plugins/v1-backcompat_test.js",
    "content": "module.exports = {\n\tplugin: require('./v1-backcompat'),\n\tsetup: setup,\n}\n\nfunction setup(store) {\n\n\ttest('backwards compatability with v1', function() {\n\t\tstore.clear()\n\t\t\n\t\tassert(typeof store.disabled    == 'boolean')\n\t\tassert(typeof store.enabled     == 'boolean')\n\t\tassert(typeof store.version     == 'string')\n\t\tassert(typeof store.set         == 'function')\n\t\tassert(typeof store.get         == 'function')\n\t\tassert(typeof store.has         == 'function')\n\t\tassert(typeof store.remove      == 'function')\n\t\tassert(typeof store.clear       == 'function')\n\t\tassert(typeof store.transact    == 'function')\n\t\tassert(typeof store.getAll      == 'function')\n\t\tassert(typeof store.forEach     == 'function')\n\t\tassert(typeof store.serialize   == 'function')\n\t\tassert(typeof store.deserialize == 'function')\n\t\t\n\t\tstore.transact('foosact', function(val) {\n\t\t\tassert(typeof val == 'object', \"new key is not an object at beginning of transaction\")\n\t\t\tval.foo = 'foo'\n\t\t})\n\t\tstore.transact('foosact', function(val) {\n\t\t\tassert(val.foo == 'foo', \"first transaction did not register\")\n\t\t\tval.bar = 'bar'\n\t\t})\n\t\tassert(store.getAll().foosact.foo == 'foo')\n\t\tvar wasCalled = false\n\t\tstore.forEach(function(key, val) {\n\t\t\twasCalled = true\n\t\t\tassert(key == 'foosact')\n\t\t\tassert(val.foo == 'foo')\n\t\t})\n\t\tassert(wasCalled)\n\t\tassert(store.serialize({}) == '{}')\n\t\tassert(store.get('foosact').bar == 'bar', \"second transaction did not register\")\n\t})\n}\n"
  },
  {
    "path": "scripts/compile-builds.js",
    "content": "#!/usr/local/bin/node\n\nvar fs = require('fs')\nvar path = require('path')\nvar browserify = require('browserify')\nvar UglifyJS = require('uglify-js')\nvar base = __dirname + '/..'\n\nmodule.exports = {\n\trun: run,\n}\n\nif (require.main === module) {\n\tmain()\n}\n\nfunction main() {\n\trun(function(err) {\n\t\tif (err) { throw err }\n\t})\n}\n\nfunction run(callback) {\n\tvar dir = base+'/dist'\n\tfs.readdir(dir, function(err, items) {\n\t\tnext()\n\t\tfunction next() {\n\t\t\tvar item = items.shift()\n\t\t\tif (!item) {\n\t\t\t\treturn callback()\n\t\t\t}\n\t\t\tif (item[0] == '.') {\n\t\t\t\treturn next()\n\t\t\t}\n\t\t\tif (item.match(/\\.min\\.js$/)) {\n\t\t\t\treturn next()\n\t\t\t}\n\t\t\tvar input = path.resolve(dir+'/'+item)\n\t\t\tvar output = input.replace(/\\.js$/, '.min.js')\n\t\t\tconsole.log('compile', input, '->', output)\n\t\t\tcompileFile(input, output, function(err) {\n\t\t\t\tif (err) {\n\t\t\t\t\treturn callback(err)\n\t\t\t\t}\n\t\t\t\tnext()\n\t\t\t})\n\t\t}\n\t})\n}\n\nfunction compileFile(input, output, callback) {\n\tvar copyright = '/* store.js - Copyright (c) 2010-2017 Marcus Westin */'\n\t                                                             // TODO: sourcemaps - depends on https://github.com/mishoo/UglifyJS2/issues/520\n\tbrowserify([input], { standalone:'store', expose:'store' })  // TODO: sourcemaps - use `debug:true`\n\t\t.transform('babelify', { presets:['es2015'] })           // TODO: sourcemaps - use `sourceMaps:true`\n\t\t.bundle(processResult)\n\t\n\tfunction processResult(err, buf) {\n\t\tif (err) { return callback(err) }\n\t\tvar code = buf.toString()\n\t\tcode = minify(code)\n\t\tvar result = copyright+'\\n'+code\n\t\tfs.writeFile(output, result, function(err) {\n\t\t\tif (err) { return callback(err) }\n\t\t\tvar b = Buffer.byteLength(result, 'utf8')\n\t\t\tvar k = Math.round(b/1000)\n\t\t\tconsole.log(k+'k \\t('+b+')')\n\t\t\tcallback()\n\t\t})\n\t}\n}\n\nfunction minify(code) {\n\tvar minified = UglifyJS.minify(code, {\n\t\tfromString: true,\n\t\tcompress: { screw_ie8:false },\n\t\tmangle:   { screw_ie8:false },\n\t\toutput:   { screw_ie8:false },\n\t\t// warnings: true,\n\t\t// mangleProperties: { reserved:[] },\n\t})\n\treturn minified.code // TODO: sourcemaps - use `result.map`.\n}\n"
  },
  {
    "path": "scripts/create-tunnel.js",
    "content": "var port = 9575\nvar tunnel = require('./saucelabs/tunnel')\n\ntunnel.setup(port, function(err, url) {\n\tconsole.log(\"Tunnel up and running at\", url)\n})\n"
  },
  {
    "path": "scripts/release.sh",
    "content": "#!/bin/bash\nset -e\n\ncd \"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\" # scripts/\ncd ../ # store.js project root\n\nVERSION=$1\nif [[ ! $VERSION =~ ^[0-9]+\\.[0-9]+\\.[0-9]+$ ]]; then\n\techo \"$VERSION is not a valid semver (e.g 2.1.3)\"\n\texit -1\nfi\n\nGIT_BRANCH=`git rev-parse --abbrev-ref HEAD`\nif [ \"$GIT_BRANCH\" != \"master\" ]; then\n\techo \"release.sh must be called from branch master (current: $GIT_BRANCH)\"\n\texit -1\nfi\n\nif ! git diff-index --quiet HEAD --; then\n\techo \"git repo is dirty. Commit all changes before using release.sh\"\n\texit -1\nfi\n\necho\necho \"> Bump package.json version:\"\necho\nsed -E s/'\"version\"\\: \"[0-9]+\\.[0-9]+\\.[0-9]+\"'/'\"version\"\\: \"'$VERSION'\"'/ package.json \\\n\t> /tmp/package.json && \\\n\tmv /tmp/package.json package.json\ncat package.json | grep $VERSION -C 1\n\necho\necho \"> Bump store-engine.js version:\"\necho\nsed -E s/\"version\\: '[0-9]+\\.[0-9]+\\.[0-9]+'\"/\"version\\: '$VERSION'\"/ src/store-engine.js \\\n\t> /tmp/store-engine.js && \\\n\tmv /tmp/store-engine.js src/store-engine.js\ncat src/store-engine.js | grep $VERSION -C 1\n\nif [[ ! `git diff --stat` =~ \"2 files changed, 2 insertions(+), 2 deletions(-)\" ]]; then\n\techo \"WARNING! Expected exactly 2 changes in 2 files after replacing version number. Bailing! (check git status and git diff)\"\n\texit -1\nfi\n\necho\nwhile true; do\n    read -p \"> Ready to build, commit, tag and release v$VERSION? (y/n): \" yn\n    case $yn in\n        [Yy]* )   break;;\n        [NnQq]* ) exit;;\n\t\t* ) echo \"Please answer yes or no.\";;\n    esac\ndone\n\necho\necho \"> Build dists\"\nnode scripts/compile-builds.js\n\necho\necho \"> git commit/push/tag/push --tags\"\nset -x\ngit add dist/* package.json src/store-engine.js\ngit commit -m \"v$VERSION\"\ngit push $ORIGIN $BRANCH\ngit tag -a \"v$VERSION\" -m \"Tag v$VERSION\"\ngit push --tags\nset +x\n\necho\necho \"> npm publish\"\nnpm publish\n"
  },
  {
    "path": "scripts/run-browser-tests-live-reload.js",
    "content": "#!/usr/bin/env node\n\nvar budo = require('budo')\n\nbudo(__dirname+'/../dist/store.tests.js', {\n\tlive: true,\n\tstream: process.stdout,\n\tport: 9966,\n\tdebug: true,\n\topen: true,\n\ttitle: 'store.js browser tests',\n})\n"
  },
  {
    "path": "scripts/run-node-tests.js",
    "content": "#!/usr/local/bin/node\n\n// simulate localStorage - must be done before importing tests\nvar { Global } = require('../src/util')\nGlobal.localStorage = require('localStorage')\n\n// Import and run tests\nvar tests = require('../tests/tests')\n\ntests.runTests()\n"
  },
  {
    "path": "scripts/run-saucelabs-tests.js",
    "content": "#!/usr/local/bin/node\n\nvar port = 9574\nvar username = 'storejs'\nvar password = new Buffer('ZjhjMzUyNjgtNzc2ZC00ZjlkLWEwNWUtN2FkM2Q0ZDgyNzk5', 'base64').toString('utf8')\n\n// TODO: Contribute to npm-saucelabs? Create new module?\nvar saucelabs = require('./saucelabs/saucelabs')\nvar tunnel = require('./saucelabs/tunnel')\n\nmain(function(err) {\n\tif (err) { throw err }\n\tlog('All done!')\n})\n\nfunction main() {\n\tvar platformSetNames = process.argv.slice(2)\n\tvar platformSets = platformSetNames.map(function(platformSetName) {\n\t\tvar platformSet = saucelabs.platformSets[platformSetName]\n\t\tif (!platformSet) {\n\t\t\tthrow new Error(\"Unknown platform set: \"+platformSetName)\n\t\t}\n\t\treturn platformSet\n\t})\n\tif (platformSets.length == 0) {\n\t\tvar s = saucelabs.platformSets\n\t\tvar platformSets = [\n\t\t\t// All supported platforms:\n\t\t\t///////////////////////////\n\t\t\ts.ie,\n\t\t\ts.safari,\n\t\t\ts.firefox,\n\t\t\ts.chrome,\n\t\t\ts.android,\n\t\t\ts.ios,\n\t\t\ts.opera,\n\n\t\t\t// Specific test targets for development:\n\t\t\t/////////////////////////////////////////\n\t\t\t// s.fast,\n\t\t\t// s.ie6, s.ie7, s.ie8,\n\t\t\t// s.ie9, s.ie10, s.ie11,\n\t\t\t// s.firefox4, s.firefox5,\n\t\t\t// s.ie10,\n\t\t]\n\t}\n\t\n\ttunnel.setup(port, function(err, url) {\n\t\tif (err) { throw err }\n\t\tsaucelabs.setAuth(username, password)\n\t\tsaucelabs.runTest(url, platformSets, onDone)\n\t\tfunction onDone(err) {\n\t\t\tif (err) {\n\t\t\t\tconsole.log('Error', err)\n\t\t\t\tprocess.exit(1)\n\t\t\t} else {\n\t\t\t\tlog('All tests passed!')\n\t\t\t\tprocess.exit(0)\t\t\t\t\n\t\t\t}\n\t\t}\t\t\t\n\t})\n}\n\nfunction log() {\n\tconsole.log.apply(console, arguments)\n}\n"
  },
  {
    "path": "scripts/saucelabs/list-supported-browsers.js",
    "content": "#!/usr/local/bin/node\n\nvar username = 'storejs'\nvar password = new Buffer('ZjhjMzUyNjgtNzc2ZC00ZjlkLWEwNWUtN2FkM2Q0ZDgyNzk5', 'base64').toString('utf8')\nvar saucelabs = require('./saucelabs')\n\nsaucelabs.setAuth(username, password)\nsaucelabs.listAllSupportedPlatforms(function(err, res) {\n\tif (err) { throw err }\n\tfor (var i=0; i<res.length; i++) {\n\t\tconsole.log(res[i])\n\t}\n})\n"
  },
  {
    "path": "scripts/saucelabs/saucelabs-api.js",
    "content": "var request = require('request')\n\nmodule.exports = {\n\tsetAuth: setAuth,\n\tget: get,\n\tpost: post\n}\n\nvar auth = {\n\tuser: null,\n\tpassword: null,\n}\n\nfunction setAuth(saucelabsUsername, saucelabsToken) {\n\tauth.user = saucelabsUsername\n\tauth.password = saucelabsToken\n}\n\n\nfunction get(path, callback) {\n\tvar params = {\n\t\turl: 'https://saucelabs.com/rest/v1/'+path,\n\t\tauth: auth\n\t}\n\t// console.log(\"REQ\", params)\n\trequest.get(params, function(err, res, body) {\n\t\tif (err) {\n\t\t\tthrow err\n\t\t}\n\t\tif (res.statusCode != 200) {\n\t\t\tconsole.log(params)\n\t\t\tthrow new Error('Non-200 status code: '+body)\n\t\t}\n\t\t// console.log(\"RES\", params.url, body)\n\t\tcallback(JSON.parse(body))\n\t})\n}\n\n\nfunction post(path, data, callback) {\n\tvar params = {\n\t\turl: 'https://saucelabs.com/rest/v1/'+auth.user+'/'+path,\n\t\tauth: { user:auth.user, password:auth.password },\n\t\tjson: data\n\t}\n\t// console.log(\"REQ\", params)\n\trequest.post(params, function(err, res, body) {\n\t\tif (err) {\n\t\t\tthrow err\n\t\t}\n\t\tif (res.statusCode != 200) {\n\t\t\tthrow new Error('Non-200 status code: '+body)\n\t\t}\n\t\t// console.log(\"RES\", params.url, body)\n\t\tcallback(body)\n\t})\n}\n\n// https://wiki.saucelabs.com/display/DOCS/JavaScript+Unit+Testing+Methods#JavaScriptUnitTestingMethods-StartJSUnitTests\n"
  },
  {
    "path": "scripts/saucelabs/saucelabs-platformSets.js",
    "content": "// See https://wiki.saucelabs.com/display/DOCS/Platform+Configurator?_ga=1.24059122.934400320.1451142104#/\n// See ./list-saucelabs-platforms.js\nvar CURRENT_VERSION = ''\nvar BETA_VERSION = 'beta'\nvar CHROME_VERSIONS = ['31', CURRENT_VERSION]\nvar FIREFOX_VERSIONS = ['4', '5', '6', '7', CURRENT_VERSION]\nvar OPERA_VERSIONS = ['11', '12']\n\nvar platforms = module.exports = {\n\t// Fast trial runs\n\t//////////////////\n\tfast: {\n\t\t'Linux': { 'chrome': [CURRENT_VERSION] },\n\t},\n\n\t// Common browser sets\n\t//////////////////////\n\tie: {\n\t\t'Windows XP': { 'internet explorer': ['6', '7', '8'] },\n\t\t'Windows 7': { 'internet explorer': ['9'] },\n\t\t'Windows 8': { 'internet explorer': ['10'] },\n\t\t'Windows 10': { 'internet explorer': ['11'], 'microsoftedge': [CURRENT_VERSION] },\n\t},\n\tsafari: {\n\t\t'Windows 7': { 'safari': ['5'] },\n\t\t'OS X 10.8': { 'safari': ['6'] },\n\t\t'OS X 10.9': { 'safari': ['7'] },\n\t\t'OS X 10.10': { 'safari': ['8'] },\n\t\t'OS X 10.11': { 'safari': ['9'] },\n\t\t'OS X 10.12': { 'safari': ['10'] },\n\t},\n\tfirefox: {\n\t\t'Linux': { 'firefox': ['40'] },\n\t\t'Windows XP': { 'firefox': ['4', '5'] },\n\t\t'Windows 10': { 'firefox': [CURRENT_VERSION] },\n\t\t'Mac 10.12': { 'firefox': [CURRENT_VERSION] },\n\t},\n\tandroid: {\n\t\t'Linux': { 'android': ['4.4','5.0','5.1'] },\n\t},\n\tios: {\n\t\t'Mac 10.10': {\n\t\t\t'ipad':  ['8.4'],\n\t\t\t'iphone':['8.4'],\n\t\t},\n\t\t'Mac 10.11': {\n\t\t\t'ipad':  ['9.3', '10.0'],\n\t\t\t'iphone':['9.3', '10.0'],\n\t\t}\n\t},\n\tchrome: {\n\t\t'Mac 10.12': { 'chrome':['27', CURRENT_VERSION] },\n\t\t'Windows 10': { 'chrome':['26', CURRENT_VERSION] },\n\t},\n\topera: {\n\t\t'Windows XP': { 'opera':'11' },\n\t\t'Linux': { 'opera':'12' },\n\t},\n\n\t// Individual browser versions\n\t//////////////////////////////\n\tie6: { 'Windows XP': { 'internet explorer': ['6'] } },\n\tie7: { 'Windows XP': { 'internet explorer': ['7'] } },\n\tie8: { 'Windows XP': { 'internet explorer': ['8'] } },\n\tie9: { 'Windows 7':  { 'internet explorer': ['9'] } },\n\tie10:{ 'Windows 8':  { 'internet explorer': ['10'] } },\n\tie11:{ 'Windows 10': { 'internet explorer': ['11'] } },\n\n\tfirefox4: { 'Windows XP': { 'firefox': ['4'] } },\n\tfirefox5: { 'Windows XP': { 'firefox': ['5'] } },\n}\n"
  },
  {
    "path": "scripts/saucelabs/saucelabs.js",
    "content": "var _ = require('lodash')\nvar api = require('./saucelabs-api')\n\nmodule.exports = {\n\tsetAuth: api.setAuth,\n\tlistAllSupportedPlatforms: listAllSupportedPlatforms,\n\trunTest: runTest,\n\tplatformSets: require('./saucelabs-platformSets'),\n}\n\nfunction listAllSupportedPlatforms(callback) {\n\tapi.get('info/platforms/webdriver', function(platformsInfo) {\n\t\tvar platforms = _.map(platformsInfo, function(info) {\n\t\t\treturn [info['os'], info['api_name'], info['short_version']]\n\t\t})\n\t\tplatforms.sort(function(a, b) {\n\t\t\ta = a.join('-')\n\t\t\tb = b.join('-')\n\t\t\treturn a < b ? -1 : b < a ? 1 : 0\n\t\t})\n\t\tcallback(null, filterUniquePlatforms(platforms))\n\t})\n}\n\nfunction runTests(url, platforms, callback) {\n\tvar params = { maxDuration:1800, url:url, platforms:platforms, framework:'custom', recordVideo:false, recordScreenshots:false, recordLogs:true }\n\tapi.post('js-tests', params, callback)\n}\n\nfunction getPlatformId(platform) {\n\treturn platform.join('-')\n\t\t.replace('OS X', 'Mac')\n\t\t.replace('Windows XP', 'Windows 2003')\n\t\t.replace('Windows 7', 'Windows 2008')\n\t\t.replace('Windows 8', 'Windows 2012')\n}\n\nfunction filterUniquePlatforms(platforms) {\n\tvar seen = {}\n\treturn _.filter(platforms, function(platform) {\n\t\tvar platformId = getPlatformId(platform)\n\t\tif (seen[platformId]) { return false }\n\t\tseen[platformId] = true\n\t\treturn true\n\t})\n}\n\nfunction runTest(url, platformSets, callback) {\n\tgetPlatformsArg(platformSets, function(platforms) {\n\t\tvar runTestsRes\n\t\trunTests(url, platforms, function(res) {\n\t\t\trunTestsRes = res\n\t\t\tloopCheckStatus()\n\t\t})\n\t\tfunction loopCheckStatus() {\n\t\t\tgetTestsStatus(runTestsRes, function(res) {\n\t\t\t\tvar pending = []\n\t\t\t\tvar running = []\n\t\t\t\tvar passed = []\n\t\t\t\tvar failed = []\n\t\t\t\t_.each(res['js tests'], function(test) {\n\t\t\t\t\tvar status = getTestStatus(test)\n\t\t\t\t\tif (status == PENDING) { pending.push(test) }\n\t\t\t\t\telse if (status == PASSED) { passed.push(test) }\n\t\t\t\t\telse if (status == RUNNING) { running.push(test) }\n\t\t\t\t\telse if (status == FAILED) { failed.push(test) }\n\t\t\t\t\telse { throw new Error('Bad status') }\n\t\t\t\t})\n\t\t\t\t_.each(_.flatten([passed, pending, running, failed]), function(test) {\n\t\t\t\t\tconsole.log(getTestStatus(test), test.id, test.platform, test.status || 'test finished')\n\t\t\t\t})\n\t\t\t\tif (pending.length == 0 && running.length == 0) {\n\t\t\t\t\tconsole.log(\"Test suite completed\")\n\t\t\t\t\tcallback(checkTestResults(res))\n\t\t\t\t} else if (res.completed) {\n\t\t\t\t\tthrow new Error('No pending tests, but res.completed == true')\n\t\t\t\t} else {\n\t\t\t\t\tvar delay = 5\n\t\t\t\t\tconsole.log(\"Check again in\", delay, \"seconds\")\n\t\t\t\t\tsetTimeout(loopCheckStatus, delay * 1000)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n}\n\nfunction getPlatformsArg(platformSets, callback) {\n\tlistAllSupportedPlatforms(function(err, supportedPlatforms) {\n\t\tif (err) { return callback(err) }\n\t\tvar allSupportedPlatforms = {}\n\t\t_.each(supportedPlatforms, function(platform) {\n\t\t\tallSupportedPlatforms[getPlatformId(platform)] = true\n\t\t})\n\t\t\n\t\tvar platforms = _.flatten(_.flatten(_.flatten(\n\t\t\t_.map(platformSets, function(platformSet) {\n\t\t\t\treturn _.map(platformSet, function(browserSpecs, osName) {\n\t\t\t\t\treturn _.map(browserSpecs, function(browserVersions, browserName) {\n\t\t\t\t\t\tif (typeof browserVersions == 'string') {\n\t\t\t\t\t\t\tbrowserVersions = [browserVersions]\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _.map(browserVersions, function(browserVersion) {\n\t\t\t\t\t\t\treturn [osName, browserName, browserVersion]\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t})\n\t\t)))\n\t\t\n\t\t_.each(platforms, function(platform) {\n\t\t\tif (!platform[2]) { return } // Don't sanity-check CURRENT_VERSION\n\t\t\tvar platformId = getPlatformId(platform)\n\t\t\tif (!allSupportedPlatforms[platformId]) {\n\t\t\t\tthrow new Error('Unsupported platform: '+platform.join(', ')+' ('+platformId+')')\n\t\t\t}\n\t\t})\n\t\t\n\t\tcallback(filterUniquePlatforms(platforms))\n\t})\n}\n\nfunction getTestsStatus(runTestsRes, callback) {\n\tapi.post('js-tests/status', { 'js tests':runTestsRes['js tests'] }, function(res) {\n\t\tcallback(res)\n\t})\n}\n\nvar PENDING = 'PENDING'\nvar RUNNING = 'RUNNING'\nvar FAILED  = 'FAILED '\nvar PASSED  = 'PASSED '\nfunction getTestStatus(test) {\n\tif (test.status == 'test error') {\n\t\treturn FAILED\n\t} else if (test.status == 'test session in progress') {\n\t\treturn RUNNING\n\t} else if (test.result) {\n\t\treturn (test.result.failed ? FAILED : PASSED)\n\t} else {\n\t\treturn PENDING\n\t}\n}\n\nfunction checkTestResults(res) {\n\tvar failed = 0\n\t_.each(res['js tests'], function(test) {\n\t\tconsole.log(getTestStatus(test), test.id, test.status, test.platform, test.url)\n\t\tif (getTestStatus(test) == FAILED) {\n\t\t\tfailed += 1\n\t\t\tconsole.log('Result:', test.result)\n\t\t}\n\t})\n\treturn (failed ? failed+' tests failed' : null)\n}\n"
  },
  {
    "path": "scripts/saucelabs/tunnel.js",
    "content": "var http = require('http')\nvar fs = require('fs')\nvar ngrok = require('ngrok')\n\nmodule.exports = {\n\tsetup: setup,\n}\n\nfunction setup(port, callback) {\n\tstartServer(port, function(err) {\n\t\tif (err) { return callback(err) }\n\t\tconsole.log(\"Creating tunnel - this might take a few seconds\")\n\t\tstartTunnel(port, function(err, url) {\n\t\t\tif (err) { return callback(err) }\n\t\t\tconsole.log(\"tunnel up at\", url)\n\t\t\tcallback(null, url)\n\t\t})\n\t})\n}\n\nfunction startTunnel(port, callback) {\n\t// return callback(null, 'https://07f51ed4.ngrok.io')\n\tvar authtoken = new Buffer('NTJuelB1dUpVSDNycDNjZ3pldHVEXzVnWlNObkpuMlFaR013WjZ0eUZUQw==', 'base64').toString('utf8')\n\tngrok.connect({ addr:port, subdomain:'storejs-test', authtoken:authtoken }, function(err, url) {\n\t\tif (err) { return callback(err) }\n\t\turl = url.replace('https:', 'http:')\n\t\tcallback(null, url)\n\t})\n}\n\nfunction startServer(port, callback) {\n\tvar server = http.createServer(handleReq)\n\tserver.listen(port)\n\tserver.on('listening', function(err) {\n\t\tif (err) { return callback(err) }\n\t\tconsole.log('local server listening on http://localhost:'+port+'/')\n\t\tcallback()\n\t})\n\t\n\tfunction handleReq(req, res) {\n\t\tconsole.log(req.url)\n\t\tif (req.url == '/') {\n\t\t\tres.writeHead(200, { 'Content-Type':'text/html' })\n\t\t\tres.end(testRunnerHTML)\n\n\t\t} else if (req.url == '/store.tests.min.js') {\n\t\t\tvar headers = {\n\t\t\t\t'Content-Type':'application/javascript',\n\t\t\t\t'Cache-Control': 'no-cache, no-store, must-revalidate',\n\t\t\t\t'Pragma': 'no-cache',\n\t\t\t\t'Expires': '0'\n\t\t\t}\n\t\t\tres.writeHead(200, headers)\n\t\t\tfs.createReadStream(__dirname+'/../../dist/store.tests.min.js').pipe(res)\n\n\t\t} else {\n\t\t\tres.writeHead(404)\n\t\t\tres.end('Not found')\n\t\t}\n\t}\n\t\n\tvar testRunnerHTML = `\n\t\t<!doctype html>\n\t\t<head>\n\t\t\t<title>store.js test runner</title>\n\t\t</head>\n\t\t<body>\n\t\t\t<h1>store.js test runner</h1>\n\t\t\t<script src=\"/store.tests.min.js\"></script>\n\t\t</body>\n\t\t</html>\n\t`.replace(/\\n\\t\\t/g, '\\n').replace(/^\\n/, '')\n}\n"
  },
  {
    "path": "src/store-engine.js",
    "content": "var util = require('./util')\nvar slice = util.slice\nvar pluck = util.pluck\nvar each = util.each\nvar bind = util.bind\nvar create = util.create\nvar isList = util.isList\nvar isFunction = util.isFunction\nvar isObject = util.isObject\n\nmodule.exports = {\n\tcreateStore: createStore\n}\n\nvar storeAPI = {\n\tversion: '2.0.12',\n\tenabled: false,\n\t\n\t// get returns the value of the given key. If that value\n\t// is undefined, it returns optionalDefaultValue instead.\n\tget: function(key, optionalDefaultValue) {\n\t\tvar data = this.storage.read(this._namespacePrefix + key)\n\t\treturn this._deserialize(data, optionalDefaultValue)\n\t},\n\n\t// set will store the given value at key and returns value.\n\t// Calling set with value === undefined is equivalent to calling remove.\n\tset: function(key, value) {\n\t\tif (value === undefined) {\n\t\t\treturn this.remove(key)\n\t\t}\n\t\tthis.storage.write(this._namespacePrefix + key, this._serialize(value))\n\t\treturn value\n\t},\n\n\t// remove deletes the key and value stored at the given key.\n\tremove: function(key) {\n\t\tthis.storage.remove(this._namespacePrefix + key)\n\t},\n\n\t// each will call the given callback once for each key-value pair\n\t// in this store.\n\teach: function(callback) {\n\t\tvar self = this\n\t\tthis.storage.each(function(val, namespacedKey) {\n\t\t\tcallback.call(self, self._deserialize(val), (namespacedKey || '').replace(self._namespaceRegexp, ''))\n\t\t})\n\t},\n\n\t// clearAll will remove all the stored key-value pairs in this store.\n\tclearAll: function() {\n\t\tthis.storage.clearAll()\n\t},\n\n\t// additional functionality that can't live in plugins\n\t// ---------------------------------------------------\n\n\t// hasNamespace returns true if this store instance has the given namespace.\n\thasNamespace: function(namespace) {\n\t\treturn (this._namespacePrefix == '__storejs_'+namespace+'_')\n\t},\n\n\t// createStore creates a store.js instance with the first\n\t// functioning storage in the list of storage candidates,\n\t// and applies the the given mixins to the instance.\n\tcreateStore: function() {\n\t\treturn createStore.apply(this, arguments)\n\t},\n\t\n\taddPlugin: function(plugin) {\n\t\tthis._addPlugin(plugin)\n\t},\n\t\n\tnamespace: function(namespace) {\n\t\treturn createStore(this.storage, this.plugins, namespace)\n\t}\n}\n\nfunction _warn() {\n\tvar _console = (typeof console == 'undefined' ? null : console)\n\tif (!_console) { return }\n\tvar fn = (_console.warn ? _console.warn : _console.log)\n\tfn.apply(_console, arguments)\n}\n\nfunction createStore(storages, plugins, namespace) {\n\tif (!namespace) {\n\t\tnamespace = ''\n\t}\n\tif (storages && !isList(storages)) {\n\t\tstorages = [storages]\n\t}\n\tif (plugins && !isList(plugins)) {\n\t\tplugins = [plugins]\n\t}\n\n\tvar namespacePrefix = (namespace ? '__storejs_'+namespace+'_' : '')\n\tvar namespaceRegexp = (namespace ? new RegExp('^'+namespacePrefix) : null)\n\tvar legalNamespaces = /^[a-zA-Z0-9_\\-]*$/ // alpha-numeric + underscore and dash\n\tif (!legalNamespaces.test(namespace)) {\n\t\tthrow new Error('store.js namespaces can only have alphanumerics + underscores and dashes')\n\t}\n\t\n\tvar _privateStoreProps = {\n\t\t_namespacePrefix: namespacePrefix,\n\t\t_namespaceRegexp: namespaceRegexp,\n\n\t\t_testStorage: function(storage) {\n\t\t\ttry {\n\t\t\t\tvar testStr = '__storejs__test__'\n\t\t\t\tstorage.write(testStr, testStr)\n\t\t\t\tvar ok = (storage.read(testStr) === testStr)\n\t\t\t\tstorage.remove(testStr)\n\t\t\t\treturn ok\n\t\t\t} catch(e) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\n\t\t_assignPluginFnProp: function(pluginFnProp, propName) {\n\t\t\tvar oldFn = this[propName]\n\t\t\tthis[propName] = function pluginFn() {\n\t\t\t\tvar args = slice(arguments, 0)\n\t\t\t\tvar self = this\n\n\t\t\t\t// super_fn calls the old function which was overwritten by\n\t\t\t\t// this mixin.\n\t\t\t\tfunction super_fn() {\n\t\t\t\t\tif (!oldFn) { return }\n\t\t\t\t\teach(arguments, function(arg, i) {\n\t\t\t\t\t\targs[i] = arg\n\t\t\t\t\t})\n\t\t\t\t\treturn oldFn.apply(self, args)\n\t\t\t\t}\n\n\t\t\t\t// Give mixing function access to super_fn by prefixing all mixin function\n\t\t\t\t// arguments with super_fn.\n\t\t\t\tvar newFnArgs = [super_fn].concat(args)\n\n\t\t\t\treturn pluginFnProp.apply(self, newFnArgs)\n\t\t\t}\n\t\t},\n\n\t\t_serialize: function(obj) {\n\t\t\treturn JSON.stringify(obj)\n\t\t},\n\n\t\t_deserialize: function(strVal, defaultVal) {\n\t\t\tif (!strVal) { return defaultVal }\n\t\t\t// It is possible that a raw string value has been previously stored\n\t\t\t// in a storage without using store.js, meaning it will be a raw\n\t\t\t// string value instead of a JSON serialized string. By defaulting\n\t\t\t// to the raw string value in case of a JSON parse error, we allow\n\t\t\t// for past stored values to be forwards-compatible with store.js\n\t\t\tvar val = ''\n\t\t\ttry { val = JSON.parse(strVal) }\n\t\t\tcatch(e) { val = strVal }\n\n\t\t\treturn (val !== undefined ? val : defaultVal)\n\t\t},\n\t\t\n\t\t_addStorage: function(storage) {\n\t\t\tif (this.enabled) { return }\n\t\t\tif (this._testStorage(storage)) {\n\t\t\t\tthis.storage = storage\n\t\t\t\tthis.enabled = true\n\t\t\t}\n\t\t},\n\n\t\t_addPlugin: function(plugin) {\n\t\t\tvar self = this\n\n\t\t\t// If the plugin is an array, then add all plugins in the array.\n\t\t\t// This allows for a plugin to depend on other plugins.\n\t\t\tif (isList(plugin)) {\n\t\t\t\teach(plugin, function(plugin) {\n\t\t\t\t\tself._addPlugin(plugin)\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Keep track of all plugins we've seen so far, so that we\n\t\t\t// don't add any of them twice.\n\t\t\tvar seenPlugin = pluck(this.plugins, function(seenPlugin) {\n\t\t\t\treturn (plugin === seenPlugin)\n\t\t\t})\n\t\t\tif (seenPlugin) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.plugins.push(plugin)\n\n\t\t\t// Check that the plugin is properly formed\n\t\t\tif (!isFunction(plugin)) {\n\t\t\t\tthrow new Error('Plugins must be function values that return objects')\n\t\t\t}\n\n\t\t\tvar pluginProperties = plugin.call(this)\n\t\t\tif (!isObject(pluginProperties)) {\n\t\t\t\tthrow new Error('Plugins must return an object of function properties')\n\t\t\t}\n\n\t\t\t// Add the plugin function properties to this store instance.\n\t\t\teach(pluginProperties, function(pluginFnProp, propName) {\n\t\t\t\tif (!isFunction(pluginFnProp)) {\n\t\t\t\t\tthrow new Error('Bad plugin property: '+propName+' from plugin '+plugin.name+'. Plugins should only return functions.')\n\t\t\t\t}\n\t\t\t\tself._assignPluginFnProp(pluginFnProp, propName)\n\t\t\t})\n\t\t},\n\t\t\n\t\t// Put deprecated properties in the private API, so as to not expose it to accidential\n\t\t// discovery through inspection of the store object.\n\t\t\n\t\t// Deprecated: addStorage\n\t\taddStorage: function(storage) {\n\t\t\t_warn('store.addStorage(storage) is deprecated. Use createStore([storages])')\n\t\t\tthis._addStorage(storage)\n\t\t}\n\t}\n\n\tvar store = create(_privateStoreProps, storeAPI, {\n\t\tplugins: []\n\t})\n\tstore.raw = {}\n\teach(store, function(prop, propName) {\n\t\tif (isFunction(prop)) {\n\t\t\tstore.raw[propName] = bind(store, prop)\t\t\t\n\t\t}\n\t})\n\teach(storages, function(storage) {\n\t\tstore._addStorage(storage)\n\t})\n\teach(plugins, function(plugin) {\n\t\tstore._addPlugin(plugin)\n\t})\n\treturn store\n}\n"
  },
  {
    "path": "src/util.js",
    "content": "var assign = make_assign()\nvar create = make_create()\nvar trim = make_trim()\nvar Global = (typeof window !== 'undefined' ? window : global)\n\nmodule.exports = {\n\tassign: assign,\n\tcreate: create,\n\ttrim: trim,\n\tbind: bind,\n\tslice: slice,\n\teach: each,\n\tmap: map,\n\tpluck: pluck,\n\tisList: isList,\n\tisFunction: isFunction,\n\tisObject: isObject,\n\tGlobal: Global\n}\n\nfunction make_assign() {\n\tif (Object.assign) {\n\t\treturn Object.assign\n\t} else {\n\t\treturn function shimAssign(obj, props1, props2, etc) {\n\t\t\tfor (var i = 1; i < arguments.length; i++) {\n\t\t\t\teach(Object(arguments[i]), function(val, key) {\n\t\t\t\t\tobj[key] = val\n\t\t\t\t})\n\t\t\t}\t\t\t\n\t\t\treturn obj\n\t\t}\n\t}\n}\n\nfunction make_create() {\n\tif (Object.create) {\n\t\treturn function create(obj, assignProps1, assignProps2, etc) {\n\t\t\tvar assignArgsList = slice(arguments, 1)\n\t\t\treturn assign.apply(this, [Object.create(obj)].concat(assignArgsList))\n\t\t}\n\t} else {\n\t\tfunction F() {} // eslint-disable-line no-inner-declarations\n\t\treturn function create(obj, assignProps1, assignProps2, etc) {\n\t\t\tvar assignArgsList = slice(arguments, 1)\n\t\t\tF.prototype = obj\n\t\t\treturn assign.apply(this, [new F()].concat(assignArgsList))\n\t\t}\n\t}\n}\n\nfunction make_trim() {\n\tif (String.prototype.trim) {\n\t\treturn function trim(str) {\n\t\t\treturn String.prototype.trim.call(str)\n\t\t}\n\t} else {\n\t\treturn function trim(str) {\n\t\t\treturn str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '')\n\t\t}\n\t}\n}\n\nfunction bind(obj, fn) {\n\treturn function() {\n\t\treturn fn.apply(obj, Array.prototype.slice.call(arguments, 0))\n\t}\n}\n\nfunction slice(arr, index) {\n\treturn Array.prototype.slice.call(arr, index || 0)\n}\n\nfunction each(obj, fn) {\n\tpluck(obj, function(val, key) {\n\t\tfn(val, key)\n\t\treturn false\n\t})\n}\n\nfunction map(obj, fn) {\n\tvar res = (isList(obj) ? [] : {})\n\tpluck(obj, function(v, k) {\n\t\tres[k] = fn(v, k)\n\t\treturn false\n\t})\n\treturn res\n}\n\nfunction pluck(obj, fn) {\n\tif (isList(obj)) {\n\t\tfor (var i=0; i<obj.length; i++) {\n\t\t\tif (fn(obj[i], i)) {\n\t\t\t\treturn obj[i]\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (var key in obj) {\n\t\t\tif (obj.hasOwnProperty(key)) {\n\t\t\t\tif (fn(obj[key], key)) {\n\t\t\t\t\treturn obj[key]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isList(val) {\n\treturn (val != null && typeof val != 'function' && typeof val.length == 'number')\n}\n\nfunction isFunction(val) {\n\treturn val && {}.toString.call(val) === '[object Function]'\n}\n\nfunction isObject(val) {\n\treturn val && {}.toString.call(val) === '[object Object]'\n}\n"
  },
  {
    "path": "storages/all.js",
    "content": "module.exports = [\n\t// Listed in order of usage preference\n\trequire('./localStorage'),\n\trequire('./oldFF-globalStorage'),\n\trequire('./oldIE-userDataStorage'),\n\trequire('./cookieStorage'),\n\trequire('./sessionStorage'),\n\trequire('./memoryStorage')\n]\n"
  },
  {
    "path": "storages/cookieStorage.js",
    "content": "// cookieStorage is useful Safari private browser mode, where localStorage\n// doesn't work but cookies do. This implementation is adopted from\n// https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage\n\nvar util = require('../src/util')\nvar Global = util.Global\nvar trim = util.trim\n\nmodule.exports = {\n\tname: 'cookieStorage',\n\tread: read,\n\twrite: write,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll,\n}\n\nvar doc = Global.document\n\nfunction read(key) {\n\tif (!key || !_has(key)) { return null }\n\tvar regexpStr = \"(?:^|.*;\\\\s*)\" +\n\t\tescape(key).replace(/[\\-\\.\\+\\*]/g, \"\\\\$&\") +\n\t\t\"\\\\s*\\\\=\\\\s*((?:[^;](?!;))*[^;]?).*\"\n\treturn unescape(doc.cookie.replace(new RegExp(regexpStr), \"$1\"))\n}\n\nfunction each(callback) {\n\tvar cookies = doc.cookie.split(/; ?/g)\n\tfor (var i = cookies.length - 1; i >= 0; i--) {\n\t\tif (!trim(cookies[i])) {\n\t\t\tcontinue\n\t\t}\n\t\tvar kvp = cookies[i].split('=')\n\t\tvar key = unescape(kvp[0])\n\t\tvar val = unescape(kvp[1])\n\t\tcallback(val, key)\n\t}\n}\n\nfunction write(key, data) {\n\tif(!key) { return }\n\tdoc.cookie = escape(key) + \"=\" + escape(data) + \"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/\"\n}\n\nfunction remove(key) {\n\tif (!key || !_has(key)) {\n\t\treturn\n\t}\n\tdoc.cookie = escape(key) + \"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/\"\n}\n\nfunction clearAll() {\n\teach(function(_, key) {\n\t\tremove(key)\n\t})\n}\n\nfunction _has(key) {\n\treturn (new RegExp(\"(?:^|;\\\\s*)\" + escape(key).replace(/[\\-\\.\\+\\*]/g, \"\\\\$&\") + \"\\\\s*\\\\=\")).test(doc.cookie)\n}\n"
  },
  {
    "path": "storages/localStorage.js",
    "content": "var util = require('../src/util')\nvar Global = util.Global\n\nmodule.exports = {\n\tname: 'localStorage',\n\tread: read,\n\twrite: write,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll,\n}\n\nfunction localStorage() {\n\treturn Global.localStorage\n}\n\nfunction read(key) {\n\treturn localStorage().getItem(key)\n}\n\nfunction write(key, data) {\n\treturn localStorage().setItem(key, data)\n}\n\nfunction each(fn) {\n\tfor (var i = localStorage().length - 1; i >= 0; i--) {\n\t\tvar key = localStorage().key(i)\n\t\tfn(read(key), key)\n\t}\n}\n\nfunction remove(key) {\n\treturn localStorage().removeItem(key)\n}\n\nfunction clearAll() {\n\treturn localStorage().clear()\n}\n"
  },
  {
    "path": "storages/memoryStorage.js",
    "content": "// memoryStorage is a useful last fallback to ensure that the store\n// is functions (meaning store.get(), store.set(), etc will all function).\n// However, stored values will not persist when the browser navigates to\n// a new page or reloads the current page.\n\nmodule.exports = {\n\tname: 'memoryStorage',\n\tread: read,\n\twrite: write,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll,\n}\n\nvar memoryStorage = {}\n\nfunction read(key) {\n\treturn memoryStorage[key]\n}\n\nfunction write(key, data) {\n\tmemoryStorage[key] = data\n}\n\nfunction each(callback) {\n\tfor (var key in memoryStorage) {\n\t\tif (memoryStorage.hasOwnProperty(key)) {\n\t\t\tcallback(memoryStorage[key], key)\n\t\t}\n\t}\n}\n\nfunction remove(key) {\n\tdelete memoryStorage[key]\n}\n\nfunction clearAll(key) {\n\tmemoryStorage = {}\n}\n"
  },
  {
    "path": "storages/oldFF-globalStorage.js",
    "content": "// oldFF-globalStorage provides storage for Firefox\n// versions 6 and 7, where no localStorage, etc\n// is available.\n\nvar util = require('../src/util')\nvar Global = util.Global\n\nmodule.exports = {\n\tname: 'oldFF-globalStorage',\n\tread: read,\n\twrite: write,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll,\n}\n\nvar globalStorage = Global.globalStorage\n\nfunction read(key) {\n\treturn globalStorage[key]\n}\n\nfunction write(key, data) {\n\tglobalStorage[key] = data\n}\n\nfunction each(fn) {\n\tfor (var i = globalStorage.length - 1; i >= 0; i--) {\n\t\tvar key = globalStorage.key(i)\n\t\tfn(globalStorage[key], key)\n\t}\n}\n\nfunction remove(key) {\n\treturn globalStorage.removeItem(key)\n}\n\nfunction clearAll() {\n\teach(function(key, _) {\n\t\tdelete globalStorage[key]\n\t})\n}\n"
  },
  {
    "path": "storages/oldIE-userDataStorage.js",
    "content": "// oldIE-userDataStorage provides storage for Internet Explorer\n// versions 6 and 7, where no localStorage, sessionStorage, etc\n// is available.\n\nvar util = require('../src/util')\nvar Global = util.Global\n\nmodule.exports = {\n\tname: 'oldIE-userDataStorage',\n\twrite: write,\n\tread: read,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll,\n}\n\nvar storageName = 'storejs'\nvar doc = Global.document\nvar _withStorageEl = _makeIEStorageElFunction()\nvar disable = (Global.navigator ? Global.navigator.userAgent : '').match(/ (MSIE 8|MSIE 9|MSIE 10)\\./) // MSIE 9.x, MSIE 10.x\n\nfunction write(unfixedKey, data) {\n\tif (disable) { return }\n\tvar fixedKey = fixKey(unfixedKey)\n\t_withStorageEl(function(storageEl) {\n\t\tstorageEl.setAttribute(fixedKey, data)\n\t\tstorageEl.save(storageName)\n\t})\n}\n\nfunction read(unfixedKey) {\n\tif (disable) { return }\n\tvar fixedKey = fixKey(unfixedKey)\n\tvar res = null\n\t_withStorageEl(function(storageEl) {\n\t\tres = storageEl.getAttribute(fixedKey)\n\t})\n\treturn res\n}\n\nfunction each(callback) {\n\t_withStorageEl(function(storageEl) {\n\t\tvar attributes = storageEl.XMLDocument.documentElement.attributes\n\t\tfor (var i=attributes.length-1; i>=0; i--) {\n\t\t\tvar attr = attributes[i]\n\t\t\tcallback(storageEl.getAttribute(attr.name), attr.name)\n\t\t}\n\t})\n}\n\nfunction remove(unfixedKey) {\n\tvar fixedKey = fixKey(unfixedKey)\n\t_withStorageEl(function(storageEl) {\n\t\tstorageEl.removeAttribute(fixedKey)\n\t\tstorageEl.save(storageName)\n\t})\n}\n\nfunction clearAll() {\n\t_withStorageEl(function(storageEl) {\n\t\tvar attributes = storageEl.XMLDocument.documentElement.attributes\n\t\tstorageEl.load(storageName)\n\t\tfor (var i=attributes.length-1; i>=0; i--) {\n\t\t\tstorageEl.removeAttribute(attributes[i].name)\n\t\t}\n\t\tstorageEl.save(storageName)\n\t})\n}\n\n// Helpers\n//////////\n\n// In IE7, keys cannot start with a digit or contain certain chars.\n// See https://github.com/marcuswestin/store.js/issues/40\n// See https://github.com/marcuswestin/store.js/issues/83\nvar forbiddenCharsRegex = new RegExp(\"[!\\\"#$%&'()*+,/\\\\\\\\:;<=>?@[\\\\]^`{|}~]\", \"g\")\nfunction fixKey(key) {\n\treturn key.replace(/^\\d/, '___$&').replace(forbiddenCharsRegex, '___')\n}\n\nfunction _makeIEStorageElFunction() {\n\tif (!doc || !doc.documentElement || !doc.documentElement.addBehavior) {\n\t\treturn null\n\t}\n\tvar scriptTag = 'script',\n\t\tstorageOwner,\n\t\tstorageContainer,\n\t\tstorageEl\n\n\t// Since #userData storage applies only to specific paths, we need to\n\t// somehow link our data to a specific path.  We choose /favicon.ico\n\t// as a pretty safe option, since all browsers already make a request to\n\t// this URL anyway and being a 404 will not hurt us here.  We wrap an\n\t// iframe pointing to the favicon in an ActiveXObject(htmlfile) object\n\t// (see: http://msdn.microsoft.com/en-us/library/aa752574(v=VS.85).aspx)\n\t// since the iframe access rules appear to allow direct access and\n\t// manipulation of the document element, even for a 404 page.  This\n\t// document can be used instead of the current document (which would\n\t// have been limited to the current path) to perform #userData storage.\n\ttry {\n\t\t/* global ActiveXObject */\n\t\tstorageContainer = new ActiveXObject('htmlfile')\n\t\tstorageContainer.open()\n\t\tstorageContainer.write('<'+scriptTag+'>document.w=window</'+scriptTag+'><iframe src=\"/favicon.ico\"></iframe>')\n\t\tstorageContainer.close()\n\t\tstorageOwner = storageContainer.w.frames[0].document\n\t\tstorageEl = storageOwner.createElement('div')\n\t} catch(e) {\n\t\t// somehow ActiveXObject instantiation failed (perhaps some special\n\t\t// security settings or otherwse), fall back to per-path storage\n\t\tstorageEl = doc.createElement('div')\n\t\tstorageOwner = doc.body\n\t}\n\n\treturn function(storeFunction) {\n\t\tvar args = [].slice.call(arguments, 0)\n\t\targs.unshift(storageEl)\n\t\t// See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx\n\t\t// and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx\n\t\tstorageOwner.appendChild(storageEl)\n\t\tstorageEl.addBehavior('#default#userData')\n\t\tstorageEl.load(storageName)\n\t\tstoreFunction.apply(this, args)\n\t\tstorageOwner.removeChild(storageEl)\n\t\treturn\n\t}\n}\n"
  },
  {
    "path": "storages/sessionStorage.js",
    "content": "var util = require('../src/util')\nvar Global = util.Global\n\nmodule.exports = {\n\tname: 'sessionStorage',\n\tread: read,\n\twrite: write,\n\teach: each,\n\tremove: remove,\n\tclearAll: clearAll\n}\n\nfunction sessionStorage() {\n\treturn Global.sessionStorage\n}\n\nfunction read(key) {\n\treturn sessionStorage().getItem(key)\n}\n\nfunction write(key, data) {\n\treturn sessionStorage().setItem(key, data)\n}\n\nfunction each(fn) {\n\tfor (var i = sessionStorage().length - 1; i >= 0; i--) {\n\t\tvar key = sessionStorage().key(i)\n\t\tfn(read(key), key)\n\t}\n}\n\nfunction remove(key) {\n\treturn sessionStorage().removeItem(key)\n}\n\nfunction clearAll() {\n\treturn sessionStorage().clear()\n}\n"
  },
  {
    "path": "sublime-storejs.sublime-project",
    "content": "{\n\t\"settings\": {\n\t\t\"tab_size\": 4\n\t},\n\t\"folders\": [{\n\t\t\"path\": \"./\",\n\t\t\"folder_exclude_patterns\": [\"node_modules\"],\n\t\t\"file_exclude_patterns\": [\"*.min.js\"],\n\t}]\n}\n"
  },
  {
    "path": "tests/bugs/all.js",
    "content": "test.group('bugs', function() {\n\ttest('gh-215: \"Expire plugin doesn\\'t factor custom namespaces\"', function() {\n\t\trequire('./gh-215')\n\t})\n\ttest('gh-235: \"Expire and Events plugins conflict with each other\"', function() {\n\t\trequire('./gh-235')\n\t})\n\ttest('gh-236: \"No supported storage has been added\"', function() {\n\t\trequire('./gh-236')\n\t})\n\ttest('gh-239: \"No supported storage has been added! Add one\"', function() {\n\t\trequire('./gh-239')\n\t})\n})\n"
  },
  {
    "path": "tests/bugs/gh-215.js",
    "content": "/* eslint semi: \"off\", indent: \"off\" */\n// https://github.com/marcuswestin/store.js/issues/215\n\nvar engine = require('../../src/store-engine');\nvar storages = [require('../../storages/memoryStorage')];\nvar plugins = [require('../../plugins/expire')];\n\nconst store1 = engine.createStore(storages, plugins, '');\nconst store2 = store1.namespace('store2')\nconst store3 = store1.namespace('store3')\n\nvar time = Math.floor(new Date().getTime() / 10) * 10\nvar expiration1 = time + 1001\nvar expiration2 = null\nvar expiration3 = time + 3003\n\nvar key = 'foo'\nvar val = 'bar'\n\nstore1.set(key, val, expiration1)\nstore2.set(key, val, expiration2)\nstore3.set(key, val, expiration3)\n\nassert(store1.getExpiration(key) == expiration1)\nassert(store2.getExpiration(key) == expiration2)\nassert(store3.getExpiration(key) == expiration3)\n"
  },
  {
    "path": "tests/bugs/gh-235.js",
    "content": "/* eslint semi: \"off\", indent: \"off\" */\n// https://github.com/marcuswestin/store.js/issues/235\n\nvar engine = require('../../src/store-engine');\n\nconst store = engine.createStore(\n\t[ require('../../storages/localStorage'), require('../../storages/memoryStorage') ],\n\t[ require('../../plugins/expire'), require('../../plugins/events') ]\n);\n\nstore.set('foo', 'bar', new Date().getTime() - 1);\nstore.set('foo', 'bar');\n\nstore.set('foo', 'bar');\n"
  },
  {
    "path": "tests/bugs/gh-236.js",
    "content": "/* eslint semi: \"off\", no-unused-vars: \"off\" */\n\nvar store = require('../..');\n\nconst token = store.get('token'); // or set ...\n"
  },
  {
    "path": "tests/bugs/gh-239.js",
    "content": "/* eslint semi: \"off\", no-unused-vars: \"off\" */\n\nvar store = require('../..');\nconst set = (key, value) => store.set(key, value); \nconst get = key => store.get(key);"
  },
  {
    "path": "tests/tests.js",
    "content": "var tinytest = require('tinytest')\n\ntinytest.hijackConsoleLog()\n\nvar { createStore } = require('../src/store-engine')\nvar { each } = require('../src/util')\nvar storages = require('../storages/all')\nvar allPluginTests = require('../plugins/all_tests')\n\nmodule.exports = {\n\toutput:null,\n\toutputError:null,\n\trunTests: runTests,\n\tfailed:false\n}\n\nfunction runTests() {\n\tsetupEngineTests()\n\teach(storages, function(storage) {\n\t\ttest.group(storage.name, function() {\n\t\t\tif (!_checkEnabled(storage)) {\n\t\t\t\ttest.skip('disabled')\n\t\t\t}\n\t\t\ttest('Storage tests', function() {\n\t\t\t\tvar store = createStore([storage])\n\t\t\t\trunStorageTests(store)\n\t\t\t})\n\t\t\teach(allPluginTests, function(pluginTest, pluginName) {\n\t\t\t\tvar plugin = pluginTest.plugin\n\t\t\t\ttest.group('plugin: '+pluginName, function() {\n\t\t\t\t\tvar store = createStore([storage], [plugin])\n\t\t\t\t\tpluginTest.setup(store)\n\t\t\t\t})\n\t\t\t})\n\t\t})\n\t})\n\t\n\trequire('./bugs/all')\n\t\n\ttinytest.runTests({\n\t\tfailFast: false\n\t})\n}\n\nfunction _checkEnabled(storage) {\n\tif (!storage) {\n\t\tprint('Skip unsupported storage:', storage.name)\n\t\treturn false\n\t}\n\tvar store = createStore([storage])\n\tif (!store.enabled) {\n\t\tprint('Skip disabled storage:', storage.name)\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunction setupEngineTests(store) {\n\ttest('Addon super_fn args', function() {\n\t\tfunction underlyingPlugin() {\n\t\t\treturn {\n\t\t\t\tset: function(super_fn, key, val, customArg1, customArg2) {\n\t\t\t\t\tassert(key == 'key'+'appended')\n\t\t\t\t\tassert(val == 'val')\n\t\t\t\t\tassert(customArg1 == 'overridden-customArg1')\n\t\t\t\t\tassert(customArg2 == 'customArg2')\n\t\t\t\t\tcalls++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfunction overlyingPlugin() {\n\t\t\treturn {\n\t\t\t\tset: function(super_fn, key, val) {\n\t\t\t\t\tsuper_fn(key+'appended', val, 'overridden-customArg1')\n\t\t\t\t\tcalls++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvar store = createStore(storages.memoryStorage, [underlyingPlugin, overlyingPlugin])\n\t\tvar calls = 0\n\t\tstore.set('key', 'val', 'customArg1', 'customArg2')\n\t\tassert(calls == 2)\n\t})\n}\n\nfunction runStorageTests(store) {\n\tassert(store.enabled && store.enabled, \"store should be enabled\")\n\tstore.clearAll()\n\n\tstore.get('unsetValue') // see https://github.com/marcuswestin/store.js/issues/63\n\n\tstore.set('foo', 'bar')\n\tassert(store.get('foo') == 'bar', \"stored key 'foo' not equal to stored value 'bar'\")\n\n\tstore.remove('foo')\n\tassert(store.get('foo') === undefined, \"removed key 'foo' not undefined\")\n\n\tassert(store.get('foo') === undefined, \"key 'foo' exists when it shouldn't\")\n\tassert(store.set('foo','value') == 'value', \"store#set returns the stored value\")\n\tassert(store.get('foo') !== undefined, \"key 'foo' doesn't exist when it should\")\n\n\tstore.set('foo', 'bar1')\n\tstore.set('foo', 'bar2')\n\tassert(store.get('foo') == 'bar2', \"key 'foo' is not equal to second value set 'bar2'\")\n\n\tstore.set('foo', 'bar')\n\tstore.set('bar', 'foo')\n\tstore.remove('foo')\n\tassert(store.get('foo') === undefined, \"key 'foo' exists when it shouldn't\")\n\tassert(store.get('bar') == 'foo', \"removing key 'foo' also removed key 'bar'\")\n\n\tstore.set('foo', 'bar')\n\tstore.set('bar', 'foo')\n\tstore.clearAll()\n\tassert(store.get('foo') === undefined && store.get('bar') === undefined, \"keys foo and bar not cleared after store cleared\")\n\n\tassert(store.get('defaultVal', 123) == 123, \"store.get should return default value\")\n\n\tstore.set('foo', { name: 'marcus', arr: [1,2,3] })\n\tassert(typeof store.get('foo') == 'object', \"type of stored object 'foo' is not 'object'\")\n\tassert(store.get('foo') instanceof Object, \"stored object 'foo' is not an instance of Object\")\n\tassert(store.get('foo').name == 'marcus', \"property 'name' of stored object 'foo' is not 'marcus'\")\n\tassert(store.get('foo').arr instanceof Array, \"Array property 'arr' of stored object 'foo' is not an instance of Array\")\n\tassert(store.get('foo').arr.length == 3, \"The length of Array property 'arr' stored on object 'foo' is not 3\")\n\n\tstore.remove('circularReference')\n\tvar circularOne = {}\n\tvar circularTwo = { one:circularOne }\n\tcircularOne.two = circularTwo\n\tvar threw = false\n\ttry { store.set('circularReference', circularOne) }\n\tcatch(e) { threw = true }\n\tassert(threw, \"storing object with circular reference did not throw\")\n\tassert(!store.get('circularReference'), \"attempting to store object with circular reference which should have faile affected store state\")\n\n\t// If plain local storage was used before store.js, we should attempt to JSON.parse them into javascript values.\n\t// Store values using vanilla localStorage, then read them out using store.js\n\tvar promoteValues = {\n\t\t'int'         : 42,\n\t\t'bool'        : true,\n\t\t'float'       : 3.141592653,\n\t\t'string'      : \"Don't Panic\",\n\t\t'odd_string'  : \"{ZYX'} abc:;::)))\"\n\t}\n\tfor (var key in promoteValues) {\n\t\tstore.storage.write(key, promoteValues[key])\n\t\tassert(store.get(key) == promoteValues[key], key+\" was not correctly promoted to valid JSON\")\n\t\tstore.remove(key)\n\t}\n\tstore.clearAll()\n\tvar count = 0\n\tstore.each(function() {\n\t\tcount += 1\n\t})\n\tassert(count === 0)\n}\n"
  },
  {
    "path": "tests/util.js",
    "content": "module.exports = {\n\tdeepEqual: deepEqual\n}\n\nfunction deepEqual(a,b) {\n\tif (typeof a != typeof b) {\n\t\treturn false\n\t}\n\tif (typeof a != 'object') {\n\t\treturn a === b\n\t}\n\tvar key\n\tfor (key in a) {\n\t\tif (!deepEqual(a[key], b[key])) {\n\t\t\treturn false\n\t\t}\n\t}\n\tfor (key in b) {\n\t\tif (!deepEqual(b[key], a[key])) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"
  }
]