测试版

This commit is contained in:
liuyuan
2025-03-05 15:16:45 +08:00
parent 8dbdce6d3f
commit 9accfddbe5
3849 changed files with 365801 additions and 0 deletions

3
node_modules/store/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules
npm-debug.log
*.sublime-workspace

3
node_modules/store/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
language: node_js
node_js:
- '6'

93
node_modules/store/Changelog generated vendored Normal file
View File

@@ -0,0 +1,93 @@
v2.0.0
+ New pluggable architecture!
+ New storages: localStorage, cookieStorage, memoryStorage, sessionStorage, oldFF-globalStorage, oldIE-userDataStorage.
+ New plugins: defaults, dump, events, expire, json2, observe, operations, update, v1-backcompat.
+ New builds: everything, legacy, modern, v1-backcompat, minimal (17k, 13k, 12k, 6k respectively)
v1.3.20
+ Fully automated test framework
+ Fix infinite loop in IE
v1.3.19
+ Use umdjs to export store.js (#116, #111, #96, #91, #78, ...)
+ Make compatible with "use strict" mode (#111)
+ Fix store.clear in legacy-IE code path (#103)
+ Roadmap for v1.4.x and v2.x.x
v1.3.17
+ Add store.has
+ Add store.get default value, e.g `store.get('foo', 1)`
+ Fix IE strict mode compatability issue (#105)
+ Added store.version
v1.3.16
+ Improve environment/module.exports detection (#88, github.com/benrudolph)
v1.3.15
+ Enable inlining the minified build
+ Fix AMD issue (https://github.com/marcuswestin/store.js/issues/85)
+ Fix for keys starting with a digit in IE7 (https://github.com/marcuswestin/store.js/issues/83)
v1.3.14
+ Makefile
+ Fix old-IE getAll/forEach, actually this time. I think
v1.3.12
+ Fix old-IE forEach again. Hrm...
v1.3.11
+ Fix old-IE forEach
v1.3.10
+ Add store.forEach
+ Add bower.json (sign, I know, yet another package file to maintain)
+ Add MIT license header
v1.3.9
+ Make store.js work in Node.js (using any working localStorage shim for Node.js)
v1.3.8
+ Fix closing </iframe> tag for IE7 (GH issue #68)
v1.3.7
+ Fix store.getAll for IE6
v1.3.6
+ Remove globalStorage and drop FF 2.0/3.0 support (See https://github.com/marcuswestin/store.js/issues/44)
v1.3.5
+ Now store.set returns the set value: `store.set(key, value) == value`
+ Values previously set with localStorage directly are now parsed handler by store.js: `localStorage['foo'] = 1; assert(store.get('foo') == 1)`
v1.3.4
+ Add store.enabled
+ Deprecate store.disabled
+ Add link to Jack Franklin's screencast
v1.3.3
+ Fix IE keys beginning with numeric characters (nice find @pauldwaite)
v1.3.2
+ Implement store.getAll() (patch by @blq)
v1.3.0
+ Use uglify.js for minifying store.min.js and store+json.min.js
+ Add build script
v1.2.0
+ Remove same-path restrictions in IE6/7! (Thanks @mjpizz!)
+ Support CommonJS and AMD module systems (Thanks @pereckerdal!)
+ Fix: store.set('foo', undefined); store.get('foo') no longer throws (Thanks @buger!)
v1.1.1
+ Publish in npm as "store" rather than "store.js"
+ Add commonjs export for require support
+ Add supported browsers Chrome 6-11, Firefox 4.0
v1.1.0
+ First versioned version.
+ API: store.set, store.get, store.remove, store.clear, store.transact
+ Minified versions are included: store.min.js for store.js only, and store+json2.min.js for store.js and json2.js
TODO
- 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

21
node_modules/store/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2010-2017 Marcus Westin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

34
node_modules/store/Makefile generated vendored Normal file
View File

@@ -0,0 +1,34 @@
test: test-node lint
test-node:
node scripts/run-node-tests.js
test-browser:
node scripts/run-browser-tests-live-reload.js
test-full: build test
node scripts/run-saucelabs-tests.js
test-ie: build test
node scripts/run-saucelabs-tests.js ie
test-safari: build test
node scripts/run-saucelabs-tests.js safari
test-firefox: build test
node scripts/run-saucelabs-tests.js firefox
test-chrome: build test
node scripts/run-saucelabs-tests.js chrome
test-android: build test
node scripts/run-saucelabs-tests.js android
test-ios: build test
node scripts/run-saucelabs-tests.js ios
test-opera: build test
node scripts/run-saucelabs-tests.js opera
tunnel:
node scripts/create-tunnel.js
build:
node scripts/compile-builds.js
lint:
./node_modules/.bin/eslint tests/* src/* plugins/* storages/* \
--ignore-pattern src/addon/lib/json2.js \

169
node_modules/store/README-More.md generated vendored Normal file
View File

@@ -0,0 +1,169 @@
How does it work?
------------------
store.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.
store.js depends on JSON for serialization to disk.
Installation
------------
Just grab [store.min.js] or [store+json2.min.js] and include them with a script tag.
`store.enabled` flag
--------------------
If your product depends on store.js, you must check the `store.enabled` flag first:
```html
<script src="store.min.js"></script>
<script>
init()
function init() {
if (!store.enabled) {
alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.')
return
}
var user = store.get('user')
// ... and so on ...
}
</script>
```
LocalStorage 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.
Screencast
-----------
[Introductory Screencast to Store.js](http://javascriptplayground.com/blog/2012/06/javascript-local-storage-store-js-tutorial) by Jack Franklin.
Contributors & Forks
--------------------
Contributors: https://github.com/marcuswestin/store.js/graphs/contributors
Forks: https://github.com/marcuswestin/store.js/network/members
In node.js
----------
store.js works as expected in node.js, assuming that global.localStorage has been set:
```
global.localStorage = require('localStorage')
var store = require('./store')
store.set('foo', 1)
console.log(store.get('foo'))
```
Supported browsers
------------------
- Tested in iOS 4+
- Tested in Firefox 3.5
- Tested in Firefox 3.6
- Tested in Firefox 4.0+
- Support dropped for Firefox < 3.5 (see notes below)
- Tested in Chrome 5
- Tested in Chrome 6
- Tested in Chrome 7
- Tested in Chrome 8
- Tested in Chrome 10
- Tested in Chrome 11+
- Tested in Safari 4
- Tested in Safari 5
- Tested in IE6
- Tested in IE7
- Tested in IE8
- Tested in IE9
- Tested in IE10
- Tested in Opera 10
- Tested in Opera 11
- Tested in Opera 12
- Tested in Node.js v0.10.4 (with https://github.com/coolaj86/node-localStorage 1.0.2)
*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.
*Saucelabs.com rocks* Extensive browser testing of store.js is possible thanks to Saucelabs.com. Check them out, they're awesome.
*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.
*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 "___".
Storage limits
--------------
- IE6 & IE7: 1MB total, but 128kb per "path" or "document" (see http://msdn.microsoft.com/en-us/library/ms531424(v=vs.85).aspx)
- See http://dev-test.nemikor.com/web-storage/support-test/ for a list of limits per browser
Unsupported browsers
-------------------
- Firefox 1.0: no means (beside cookies and flash)
- Safari 2: no means (beside cookies and flash)
- Safari 3: no synchronous api (has asynch sqlite api, but store.js is synch)
- Opera 9: don't know if there is synchronous api for storing data locally
- Firefox 1.5: don't know if there is synchronous api for storing data locally
- Microsoft IIS & IE7: With meta tag & "charset=iso-8859-1", things stop working. See issue #47.
Some notes on serialization
---------------------------
localStorage, 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:
```js
localStorage.myage = 24
localStorage.myage !== 24
localStorage.myage === '24'
localStorage.user = { name: 'marcus', likes: 'javascript' }
localStorage.user === "[object Object]"
localStorage.tags = ['javascript', 'localStorage', 'store.js']
localStorage.tags.length === 32
localStorage.tags === "javascript,localStorage,store.js"
```
What we want (and get with store.js) is
```js
store.set('myage', 24)
store.get('myage') === 24
store.set('user', { name: 'marcus', likes: 'javascript' })
alert("Hi my name is " + store.get('user').name + "!")
store.set('tags', ['javascript', 'localStorage', 'store.js'])
alert("We've got " + store.get('tags').length + " tags here")
```
The 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.
Some browsers do not have native support for JSON. For those browsers you should include [JSON2.js] \(non-minified copy is included in this repo).
No sessionStorage/auto-expiration?
----------------------------------
No. 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:
```js
var storeWithExpiration = {
set: function(key, val, exp) {
store.set(key, { val:val, exp:exp, time:new Date().getTime() })
},
get: function(key) {
var info = store.get(key)
if (!info) { return null }
if (new Date().getTime() - info.time > info.exp) { return null }
return info.val
}
}
storeWithExpiration.set('foo', 'bar', 1000)
setTimeout(function() { console.log(storeWithExpiration.get('foo')) }, 500) // -> "bar"
setTimeout(function() { console.log(storeWithExpiration.get('foo')) }, 1500) // -> null
```
[JSON2.js]: https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js
[store.min.js]: https://raw.github.com/marcuswestin/store.js/master/store.min.js
[store+json2.min.js]: https://raw.github.com/marcuswestin/store.js/master/store+json2.min.js

279
node_modules/store/README.md generated vendored Normal file
View File

@@ -0,0 +1,279 @@
Store.js
========
[![Build Status](https://travis-ci.org/marcuswestin/store.js.svg?branch=master)](https://travis-ci.org/marcuswestin/store.js)
[![npm version](https://badge.fury.io/js/store.svg)](https://badge.fury.io/js/store)
[![npm](https://img.shields.io/npm/dm/store.svg?maxAge=2592000)](https://npm-stat.com/charts.html?package=store)
1. [Version 2.0](#user-content-version-20)
- What's new?
2. [Basic Usage](#user-content-basic-usage)
- All you need to get started
- [API](#user-content-api)
- [Installation](#user-content-installation)
3. [Supported Browsers](#user-content-supported-browsers)
- All of them, pretty much :)
- [List of supported browsers](#user-content-list-of-supported-browsers)
4. [Plugins](#user-content-plugins)
- Additional common functionality
- [List of all Plugins](#user-content-list-of-all-plugins)
- [Using Plugins](#user-content-using-plugins)
- [Write your own Plugin](#user-content-write-your-own-plugin)
5. [Builds](#user-content-builds)
- Choose which build is right for you
- [List of default Builds](#user-content-list-of-default-builds)
- [Make your own Build](#user-content-make-your-own-build)
6. [Storages](#user-content-storages)
- Storages provide underlying persistence
- [List of all Storages](#user-content-list-of-all-storages)
- [Storages limits](#user-content-storages-limits)
- [Write your own Storage](#user-content-write-your-own-storage)
Version 2.0
-----------
Store.js has been around since 2010 ([first commit](https://github.com/marcuswestin/store.js/commit/cb0198c2c02ff5f17c084276eeb4f28c79849d5e)! [HN discussion](https://news.ycombinator.com/item?id=1468802)!), and is live on tens of thousands of websites - like cnn.com!
For many years v1.x provided basic cross-browser persistent storage, and over time more and more people [started asking](https://github.com/marcuswestin/store.js/issues?q=is%3Aissue+is%3Aclosed) for additional functionality.
Store.js version 2 is a full revamp with pluggable storage (it will automatically fall back to one that works in every scenario by default), pluggable extra functionality (like [expirations](plugins/expire.js), [default values](plugins/defaults.js), common [array/object operations](plugins/operations.js), etc), and fully cross-browser automatic testing using saucelabs.com.
Basic Usage
-----------
All you need to know to get started:
### API
store.js exposes a simple API for cross-browser local storage:
```js
// Store current user
store.set('user', { name:'Marcus' })
// Get current user
store.get('user')
// Remove current user
store.remove('user')
// Clear all keys
store.clearAll()
// Loop over all stored values
store.each(function(value, key) {
console.log(key, '==', value)
})
```
### Installation
Using npm:
```js
// Example store.js usage with npm
var store = require('store')
store.set('user', { name:'Marcus' })
store.get('user').name == 'Marcus'
```
Using script tag (first download one of the [builds](dist/)):
```html
<!-- Example store.js usage with script tag -->
<script src="path/to/my/store.legacy.min.js"></script>
<script>
var store = require('store')
store.set('user', { name:'Marcus' })
store.get('user').name == 'Marcus'
</script>
```
Supported Browsers
------------------
All of them, pretty much :)
To 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).
To 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.
### List of supported browsers
- Tested on IE6+
- Tested on iOS 8+
- Tested on Android 4+
- Tested on Firefox 4+
- Tested on Chrome 27+
- Tested on Safari 5+
- Tested on Opera 11+
- Tested on Node (with https://github.com/coolaj86/node-localStorage)
Plugins
-------
Plugins provide additional common functionality that some users might need:
### List of all Plugins
- [all.js](plugins/all.js): All the plugins in one handy place.
- [defaults.js](plugins/defaults.js): Declare default values. [Example usage](plugins/defaults_test.js)
- [dump.js](plugins/dump.js): Dump all stored values. [Example usage](plugins/dump_test.js)
- [events.js](plugins/events.js): Get notified when stored values change. [Example usage](plugins/events_test.js)
- [expire.js](plugins/expire.js): Expire stored values at a given time. [Example usage](plugins/expire_test.js)
- [observe.js](plugins/observe.js): Observe stored values and their changes. [Example usage](plugins/observe_test.js)
- [operations.js](plugins/operations.js): Useful operations like push, shift & assign. [Example usage](plugins/operations_test.js)
- [update.js](plugins/update.js): Update a stored object, or create it if null. [Example usage](plugins/update_test.js)
- [v1-backcompat.js](plugins/v1-backcompat.js): Full backwards compatibility with store.js v1. [Example usage](plugins/v1-backcompat_test.js)
### Using Plugins
With npm:
```js
// Example plugin usage:
var expirePlugin = require('store/plugins/expire')
store.addPlugin(expirePlugin)
```
If you're using script tags, you can either use [store.everything.min.js](dist/store.everything.min.js) (which
has all plugins built-in), or clone this repo to add or modify a build and run `make build`.
### Write your own plugin
A store.js plugin is a function that returns an object that gets added to the store.
If any of the plugin functions overrides existing functions, the plugin function can still call
the original function using the first argument (super_fn).
```js
// Example plugin that stores a version history of every value
var versionHistoryPlugin = function() {
var historyStore = this.namespace('history')
return {
set: function(super_fn, key, value) {
var history = historyStore.get(key) || []
history.push(value)
historyStore.set(key, history)
return super_fn()
},
getHistory: function(key) {
return historyStore.get(key)
}
}
}
store.addPlugin(versionHistoryPlugin)
store.set('foo', 'bar 1')
store.set('foo', 'bar 2')
store.getHistory('foo') == ['bar 1', 'bar 2']
```
Let me know if you need more info on writing plugins. For the moment I recommend
taking a look at the [current plugins](plugins/). Good example plugins are
[plugins/defaults](plugins/defaults.js), [plugins/expire](plugins/expire.js) and
[plugins/events](plugins/events.js).
Builds
------
Choose which build is right for you!
### List of default builds
- [store.everything.min.js](dist/store.everything.min.js): All the plugins, all the storages. [Source](dist/store.everything.js)
- [store.legacy.min.js](dist/store.legacy.min.js): Full support for all tested browsers. Add plugins separately. [Source](dist/store.legacy.js)
- [store.modern.min.js](dist/store.modern.min.js): Full support for all modern browsers. Add plugins separately. [Source](dist/store.modern.js)
- [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)
### Make your own Build
If you're using npm you can create your own build:
```js
// Example custom build usage:
var engine = require('store/src/store-engine')
var storages = [
require('store/storages/localStorage'),
require('store/storages/cookieStorage')
]
var plugins = [
require('store/plugins/defaults'),
require('store/plugins/expire')
]
var store = engine.createStore(storages, plugins)
store.set('foo', 'bar', new Date().getTime() + 3000) // Using expire plugin to expire in 3 seconds
```
Storages
--------
Store.js will pick the best available storage, and automatically falls back to the first available storage that works:
### List of all Storages
- [all.js](storages/all.js) All the storages in one handy place.
- [localStorage.js](storages/localStorage.js) Store values in localStorage. Great for all modern browsers.
- [sessionStorage.js](storages/sessionStorage.js) Store values in sessionStorage.
- [cookieStorage.js](storages/cookieStorage.js) Store values in cookies. Useful for Safari Private mode.
- [memoryStorage.js](storages/memoryStorage.js) Store values in memory. Great fallback to ensure store functionality at all times.
- [oldFF-globalStorage.js](storages/oldFF-globalStorage.js) Store values in globalStorage. Only useful for legacy Firefox 3+.
- [oldIE-userDataStorage.js](storages/oldIE-userDataStorage.js) Store values in userData. Only useful for legacy IE 6+.
### Storages limits
Each 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.
To simplify things we provide these recommendations to ensure cross browser behavior:
| Storage | Targets | Recommendations | More info |
|:----------------|:-----------------------|:--------------------------------|:-------------------------------------------------|
| all | All browsers | Store < 1 million characters | (Except Safari Private mode) |
| all | All & Private mode | Store < 32 thousand characters | (Including Safari Private mode) |
| localStorage | Modern browsers | Max 2mb (~1M chars) | [limits][local-limits], [android][local-android] |
| sessionStorage | Modern browsers | Max 5mb (~2M chars) | [limits][session-limits] |
| cookieStorage | Safari Private mode | Max 4kb (~2K chars) | [limits][cookie-limits] |
| userDataStorage | IE5, IE6 & IE7 | Max 64kb (~32K chars) | [limits][userdata-limits] |
| globalStorage | Firefox 2-5 | Max 5mb (~2M chars) | [limits][global-limits] |
| memoryStorage | All browsers, fallback | Does not persist across pages! | |
[local-limits]: https://arty.name/localstorage.html
[local-android]: http://dev-test.nemikor.com/web-storage/support-test/
[session-limits]: http://stackoverflow.com/questions/15840976/how-large-is-html5-session-storage
[cookie-limits]: http://browsercookielimits.squawky.net/
[userdata-limits]: https://msdn.microsoft.com/en-us/library/ms533015(v=vs.85).aspx
[global-limits]: https://github.com/jeremydurham/persist-js/blob/master/README.md#4-size-limits
[more]: https://www.html5rocks.com/en/tutorials/offline/quota-research/
### Write your own Storage
Chances are you won't ever need another storage. But if you do...
See [storages/](storages/) for examples. Two good examples are [memoryStorage](storages/memoryStorage.js) and [localStorage](storages/localStorage.js).
Basically, you just need an object that looks like this:
```js
// Example custom storage
var storage = {
name: 'myStorage',
read: function(key) { ... },
write: function(key, value) { ... },
each: function(fn) { ... },
remove: function(key) { ... },
clearAll: function() { ... }
}
var store = require('store').createStore(storage)
```

6
node_modules/store/dist/store.everything.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
var engine = require('../src/store-engine')
var storages = require('../storages/all')
var plugins = require('../plugins/all')
module.exports = engine.createStore(storages, plugins)

2
node_modules/store/dist/store.everything.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/store/dist/store.legacy.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
var engine = require('../src/store-engine')
var storages = require('../storages/all')
var plugins = [require('../plugins/json2')]
module.exports = engine.createStore(storages, plugins)

2
node_modules/store/dist/store.legacy.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

11
node_modules/store/dist/store.modern.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
var engine = require('../src/store-engine')
var storages = [
require('../storages/localStorage'),
require('../storages/sessionStorage'),
require('../storages/cookieStorage'),
require('../storages/memoryStorage'),
]
var plugins = []
module.exports = engine.createStore(storages, plugins)

2
node_modules/store/dist/store.modern.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/store/dist/store.tests.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
// store-test-suite will run all the store.js tests
// and report the results.
var tests = require('../tests/tests')
tests.runTests()

3
node_modules/store/dist/store.tests.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/store/dist/store.v1-backcompat.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
var engine = require('../src/store-engine')
var storages = require('../storages/all')
var plugins = [require('../plugins/v1-backcompat')]
module.exports = engine.createStore(storages, plugins)

2
node_modules/store/dist/store.v1-backcompat.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

109
node_modules/store/package.json generated vendored Normal file
View File

@@ -0,0 +1,109 @@
{
"_from": "store@^2.0.12",
"_id": "store@2.0.12",
"_inBundle": false,
"_integrity": "sha512-eO9xlzDpXLiMr9W1nQ3Nfp9EzZieIQc10zPPMP5jsVV7bLOziSFFBP0XoDXACEIFtdI+rIz0NwWVA/QVJ8zJtw==",
"_location": "/store",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "store@^2.0.12",
"name": "store",
"escapedName": "store",
"rawSpec": "^2.0.12",
"saveSpec": null,
"fetchSpec": "^2.0.12"
},
"_requiredBy": [
"/tcplayer.js"
],
"_resolved": "https://registry.npmmirror.com/store/-/store-2.0.12.tgz",
"_shasum": "8c534e2a0b831f72b75fc5f1119857c44ef5d593",
"_spec": "store@^2.0.12",
"_where": "/Users/liuyuan/Desktop/soulspace_app/node_modules/tcplayer.js",
"author": {
"name": "Marcus Westin",
"email": "narcvs@gmail.com"
},
"bugs": {
"url": "http://github.com/marcuswestin/store.js/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "A localStorage wrapper for all browsers without using cookies or flash. Uses localStorage, globalStorage, and userData behavior under the hood",
"devDependencies": {
"babel-preset-es2015": "^6.22.0",
"babelify": "^7.3.0",
"browserify": "^14.1.0",
"budo": "^7.1.0",
"eslint": "^3.12.2",
"localStorage": "^1.0.3",
"lodash": "^3.10.1",
"ngrok": "^2.2.6",
"request": "^2.67.0",
"tinytest": "^1.1.3",
"uglify-js": "^2.7.5"
},
"directories": {
"lib": "."
},
"engines": {
"node": "*"
},
"eslintConfig": {
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"globals": {
"test": false,
"assert": false,
"print": false
},
"rules": {
"comma-dangle": [
"error",
"only-multiline"
],
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "none",
"varsIgnorePattern": "^_$"
}
],
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"semi": [
"error",
"never"
]
}
},
"homepage": "https://github.com/marcuswestin/store.js#readme",
"license": "MIT",
"main": "dist/store.legacy.js",
"name": "store",
"repository": {
"type": "git",
"url": "git://github.com/marcuswestin/store.js.git"
},
"scripts": {
"test": "make test"
},
"version": "2.0.12"
}

12
node_modules/store/plugins/all.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
module.exports = [
require('./compression'),
require('./defaults'),
require('./dump'),
require('./events'),
require('./observe'),
require('./expire'),
require('./json2'),
require('./operations'),
require('./update'),
require('./v1-backcompat'),
]

12
node_modules/store/plugins/all_tests.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
module.exports = {
"compression": require('./compression_test'),
"defaults": require('./defaults_test'),
"dump": require('./dump_test'),
"events": require('./events_test'),
"observe": require('./observe_test'),
"expire": require('./expire_test'),
"json2": require('./json2_test'),
"operations": require('./operations_test'),
"update": require('./update_test'),
"v1-backcompat": require('./v1-backcompat_test'),
}

23
node_modules/store/plugins/compression.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
const LZString = require('./lib/lz-string')
module.exports = compressionPlugin
function compressionPlugin() {
return {
get: get,
set: set,
}
function get(super_fn, key) {
var val = super_fn(key)
if (!val) { return val }
var decompressed = LZString.decompress(val)
// fallback to existing values that are not compressed
return (decompressed == null) ? val : this._deserialize(decompressed)
}
function set(super_fn, key, val) {
var compressed = LZString.compress(this._serialize(val))
super_fn(key, compressed)
}
}

37
node_modules/store/plugins/compression_test.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var { deepEqual } = require('../tests/util')
module.exports = {
plugin: require('./compression'),
setup: setup,
}
function setup(store) {
test('string compression size', function() {
var str = 'foo'
var serialized = store._serialize(str)
store.set('foo', str)
assert(store.raw.get('foo').length < serialized.length, 'compressed string should be smaller than uncompressed')
assert(deepEqual(store.get('foo'), str), 'value should be equal')
})
test('object compression', function () {
var obj = { one: { two: 3 }}
var serialized = store._serialize(obj)
store.set('foo', obj)
assert(store.raw.get('foo').length < serialized.length, 'compressed object should be smaller than uncompressed')
assert(deepEqual(store.get('foo'), obj), 'should deep equal original object')
store.remove('foo')
})
test('decompress uncopmressed data', function () {
store.raw.set('foo', 'baz')
assert(store.get('foo') == 'baz', 'value should be baz')
store.remove('foo')
})
test('decompress non-existing data', function () {
assert(store.get('bar') == undefined, 'value should be undefined')
store.remove('bar')
})
}

19
node_modules/store/plugins/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
module.exports = defaultsPlugin
function defaultsPlugin() {
var defaultValues = {}
return {
defaults: defaults,
get: get
}
function defaults(_, values) {
defaultValues = values
}
function get(super_fn, key) {
var val = super_fn()
return (val !== undefined ? val : defaultValues[key])
}
}

17
node_modules/store/plugins/defaults_test.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
plugin: require('./defaults'),
setup: setup,
}
function setup(store) {
test('defaults', function() {
store.defaults({ foo: 'bar' })
assert(store.get('foo') == 'bar')
store.set('foo', 'bar2')
assert(store.get('foo') == 'bar2')
store.remove('foo')
assert(store.get('foo') == 'bar')
})
}

15
node_modules/store/plugins/dump.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
module.exports = dumpPlugin
function dumpPlugin() {
return {
dump: dump
}
function dump(_) {
var res = {}
this.each(function(val, key) {
res[key] = val
})
return res
}
}

25
node_modules/store/plugins/dump_test.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var { each } = require('../src/util')
var { deepEqual } = require('../tests/util')
module.exports = {
plugin: require('./dump'),
setup: setup,
}
function setup(store) {
test('dump', function() {
var allValues = {
'foo': 'bar',
'cat': { mat:true },
'hat': 'bat'
}
each(allValues, function(val, key) {
store.set(key, val)
})
assert(deepEqual(store.dump(), allValues))
store.clearAll()
assert(deepEqual(store.dump(), {}))
})
}

95
node_modules/store/plugins/events.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
var util = require('../src/util')
var bind = util.bind
var each = util.each
var create = util.create
var slice = util.slice
module.exports = eventsPlugin
function eventsPlugin() {
var pubsub = _newPubSub()
return {
watch: watch,
unwatch: unwatch,
once: once,
set: set,
remove: remove,
clearAll: clearAll
}
// new pubsub functions
function watch(_, key, listener) {
return pubsub.on(key, bind(this, listener))
}
function unwatch(_, subId) {
pubsub.off(subId)
}
function once(_, key, listener) {
pubsub.once(key, bind(this, listener))
}
// overwrite function to fire when appropriate
function set(super_fn, key, val) {
var oldVal = this.get(key)
super_fn()
pubsub.fire(key, val, oldVal)
}
function remove(super_fn, key) {
var oldVal = this.get(key)
super_fn()
pubsub.fire(key, undefined, oldVal)
}
function clearAll(super_fn) {
var oldVals = {}
this.each(function(val, key) {
oldVals[key] = val
})
super_fn()
each(oldVals, function(oldVal, key) {
pubsub.fire(key, undefined, oldVal)
})
}
}
function _newPubSub() {
return create(_pubSubBase, {
_id: 0,
_subSignals: {},
_subCallbacks: {}
})
}
var _pubSubBase = {
_id: null,
_subCallbacks: null,
_subSignals: null,
on: function(signal, callback) {
if (!this._subCallbacks[signal]) {
this._subCallbacks[signal] = {}
}
this._id += 1
this._subCallbacks[signal][this._id] = callback
this._subSignals[this._id] = signal
return this._id
},
off: function(subId) {
var signal = this._subSignals[subId]
delete this._subCallbacks[signal][subId]
delete this._subSignals[subId]
},
once: function(signal, callback) {
var subId = this.on(signal, bind(this, function() {
callback.apply(this, arguments)
this.off(subId)
}))
},
fire: function(signal) {
var args = slice(arguments, 1)
each(this._subCallbacks[signal], function(callback) {
callback.apply(this, args)
})
}
}

71
node_modules/store/plugins/events_test.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
module.exports = {
plugin: require('./events'),
setup: setup,
}
function setup(store) {
test('events', function() {
store.set('foo', 'bar')
var expectationNone = _createExpectation('expectNone', undefined)
store.watch('foo', function(){})
var expectation1 = _createExpectation('foo', 'bar')
var expectationOnce = _createExpectation('foo', 'bar', true)
store.watch('foo', function(){})
expectation1.add('bar2')
expectationOnce.add('bar2')
store.set('foo', 'bar2')
expectation1.add(undefined)
store.remove('foo')
expectation1.add('bar3')
store.set('foo', 'bar3')
var expectation2 = _createExpectation('foo', 'bar3')
expectation1.add(undefined)
expectation2.add(undefined)
store.clearAll() // Should fire for foo
store.clearAll() // Should not fire anything
expectation1.unwatch()
expectation2.add('bar4')
store.set('foo', 'bar4') // Should only fire for expectation2
expectation1.check()
expectationOnce.check()
expectation2.check()
expectationNone.check()
expectation2.unwatch()
})
function _createExpectation(key, firstOldVal, useOnce) {
var expectation = {
values: [firstOldVal],
count: 0,
add: function(value) {
this.values.push(value)
},
check: function() {
assert(expectation.count + 1 == expectation.values.length)
},
unwatch: function() {
store.unwatch(watchId)
}
}
var watchId = (useOnce
? store.once(key, callback)
: store.watch(key, callback)
)
function callback(val, oldVal) {
expectation.count += 1
assert(expectation.values[expectation.count] == val)
assert(expectation.values[expectation.count - 1] == oldVal)
}
return expectation
}
}

59
node_modules/store/plugins/expire.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
var namespace = 'expire_mixin'
module.exports = expirePlugin
function expirePlugin() {
var expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)
return {
set: expire_set,
get: expire_get,
remove: expire_remove,
getExpiration: getExpiration,
removeExpiredKeys: removeExpiredKeys
}
function expire_set(super_fn, key, val, expiration) {
if (!this.hasNamespace(namespace)) {
expirations.set(key, expiration)
}
return super_fn()
}
function expire_get(super_fn, key) {
if (!this.hasNamespace(namespace)) {
_checkExpiration.call(this, key)
}
return super_fn()
}
function expire_remove(super_fn, key) {
if (!this.hasNamespace(namespace)) {
expirations.remove(key)
}
return super_fn()
}
function getExpiration(_, key) {
return expirations.get(key)
}
function removeExpiredKeys(_) {
var keys = []
this.each(function(val, key) {
keys.push(key)
})
for (var i=0; i<keys.length; i++) {
_checkExpiration.call(this, keys[i])
}
}
function _checkExpiration(key) {
var expiration = expirations.get(key, Number.MAX_VALUE)
if (expiration <= new Date().getTime()) {
this.raw.remove(key)
expirations.remove(key)
}
}
}

59
node_modules/store/plugins/expire_test.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
module.exports = {
plugin: require('./expire'),
setup: setup,
}
function setup(store) {
test('expire', function(done) {
// Ive observed multiple times when legacy browsers in various
// environments (saucelabs, VMs, etc) have executed a scheduled
// timeout function too soon. The solution is to run a longer,
// timeout, but this substantially slows down the test suite.
// Instead, we allow multiple attempts with increasing durations.
attempt(5, 10)
function attempt(remaining, duration) {
runTests(duration, function check(ok) {
if (ok) {
return true
}
if (remaining > 0) {
setTimeout(function() {
attempt(remaining - 1, duration * 2)
}, 0)
return false
}
return assert(false)
})
}
function runTests(duration, check) {
var expiration = new Date().getTime() + duration
store.set('foo', 'bar', expiration)
if (!check(store.get('foo') == 'bar')) { return }
setTimeout(function() {
if (!check(new Date().getTime() > expiration)) { return }
if (!check(store.get('foo') == undefined)) { return }
store.set('foo', 'bar')
setTimeout(function() {
if (!check(store.get('foo') == 'bar')) { return }
done()
}, 5)
}, duration)
}
})
test('remove expired keys', function() {
var key = 'expired'
store.set(key, 'bar', new Date().getTime() - 1000)
assert(store.getExpiration(key) > 0)
store.removeExpiredKeys()
assert(!store.getExpiration(key))
})
}

6
node_modules/store/plugins/json2.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
module.exports = json2Plugin
function json2Plugin() {
require('./lib/json2')
return {}
}

12
node_modules/store/plugins/json2_test.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
module.exports = {
plugin: require('./json2'),
setup: setup,
}
function setup(store) {
test('serialization with json2', function() {
store.set('foo', { bar:'cat' })
assert(store.get('foo').bar === 'cat')
})
}

508
node_modules/store/plugins/lib/json2.js generated vendored Normal file
View File

@@ -0,0 +1,508 @@
/* eslint-disable */
// json2.js
// 2016-10-28
// Public Domain.
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
// See http://www.JSON.org/js.html
// This code should be minified before deployment.
// See http://javascript.crockford.com/jsmin.html
// USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
// NOT CONTROL.
// This file creates a global JSON object containing two methods: stringify
// and parse. This file provides the ES5 JSON capability to ES3 systems.
// If a project might run on IE8 or earlier, then this file should be included.
// This file does nothing on ES5 systems.
// JSON.stringify(value, replacer, space)
// value any JavaScript value, usually an object or array.
// replacer an optional parameter that determines how object
// values are stringified for objects. It can be a
// function or an array of strings.
// space an optional parameter that specifies the indentation
// of nested structures. If it is omitted, the text will
// be packed without extra whitespace. If it is a number,
// it will specify the number of spaces to indent at each
// level. If it is a string (such as "\t" or "&nbsp;"),
// it contains the characters used to indent at each level.
// This method produces a JSON text from a JavaScript value.
// When an object value is found, if the object contains a toJSON
// method, its toJSON method will be called and the result will be
// stringified. A toJSON method does not serialize: it returns the
// value represented by the name/value pair that should be serialized,
// or undefined if nothing should be serialized. The toJSON method
// will be passed the key associated with the value, and this will be
// bound to the value.
// For example, this would serialize Dates as ISO strings.
// Date.prototype.toJSON = function (key) {
// function f(n) {
// // Format integers to have at least two digits.
// return (n < 10)
// ? "0" + n
// : n;
// }
// return this.getUTCFullYear() + "-" +
// f(this.getUTCMonth() + 1) + "-" +
// f(this.getUTCDate()) + "T" +
// f(this.getUTCHours()) + ":" +
// f(this.getUTCMinutes()) + ":" +
// f(this.getUTCSeconds()) + "Z";
// };
// You can provide an optional replacer method. It will be passed the
// key and value of each member, with this bound to the containing
// object. The value that is returned from your method will be
// serialized. If your method returns undefined, then the member will
// be excluded from the serialization.
// If the replacer parameter is an array of strings, then it will be
// used to select the members to be serialized. It filters the results
// such that only members with keys listed in the replacer array are
// stringified.
// Values that do not have JSON representations, such as undefined or
// functions, will not be serialized. Such values in objects will be
// dropped; in arrays they will be replaced with null. You can use
// a replacer function to replace those with JSON values.
// JSON.stringify(undefined) returns undefined.
// The optional space parameter produces a stringification of the
// value that is filled with line breaks and indentation to make it
// easier to read.
// If the space parameter is a non-empty string, then that string will
// be used for indentation. If the space parameter is a number, then
// the indentation will be that many spaces.
// Example:
// text = JSON.stringify(["e", {pluribus: "unum"}]);
// // text is '["e",{"pluribus":"unum"}]'
// text = JSON.stringify(["e", {pluribus: "unum"}], null, "\t");
// // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
// text = JSON.stringify([new Date()], function (key, value) {
// return this[key] instanceof Date
// ? "Date(" + this[key] + ")"
// : value;
// });
// // text is '["Date(---current time---)"]'
// JSON.parse(text, reviver)
// This method parses a JSON text to produce an object or array.
// It can throw a SyntaxError exception.
// The optional reviver parameter is a function that can filter and
// transform the results. It receives each of the keys and values,
// and its return value is used instead of the original value.
// If it returns what it received, then the structure is not modified.
// If it returns undefined then the member is deleted.
// Example:
// // Parse the text. Values that look like ISO date strings will
// // be converted to Date objects.
// myData = JSON.parse(text, function (key, value) {
// var a;
// if (typeof value === "string") {
// a =
// /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
// if (a) {
// return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
// +a[5], +a[6]));
// }
// }
// return value;
// });
// myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
// var d;
// if (typeof value === "string" &&
// value.slice(0, 5) === "Date(" &&
// value.slice(-1) === ")") {
// d = new Date(value.slice(5, -1));
// if (d) {
// return d;
// }
// }
// return value;
// });
// This is a reference implementation. You are free to copy, modify, or
// redistribute.
/*jslint
eval, for, this
*/
/*property
JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== "object") {
JSON = {};
}
(function () {
"use strict";
var rx_one = /^[\],:{}\s]*$/;
var rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
var rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
var rx_four = /(?:^|:|,)(?:\s*\[)+/g;
var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
var rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
function f(n) {
// Format integers to have at least two digits.
return n < 10
? "0" + n
: n;
}
function this_value() {
return this.valueOf();
}
if (typeof Date.prototype.toJSON !== "function") {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + "-" +
f(this.getUTCMonth() + 1) + "-" +
f(this.getUTCDate()) + "T" +
f(this.getUTCHours()) + ":" +
f(this.getUTCMinutes()) + ":" +
f(this.getUTCSeconds()) + "Z"
: null;
};
Boolean.prototype.toJSON = this_value;
Number.prototype.toJSON = this_value;
String.prototype.toJSON = this_value;
}
var gap;
var indent;
var meta;
var rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
rx_escapable.lastIndex = 0;
return rx_escapable.test(string)
? "\"" + string.replace(rx_escapable, function (a) {
var c = meta[a];
return typeof c === "string"
? c
: "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
}) + "\""
: "\"" + string + "\"";
}
function str(key, holder) {
// Produce a string from holder[key].
var i; // The loop counter.
var k; // The member key.
var v; // The member value.
var length;
var mind = gap;
var partial;
var value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === "object" &&
typeof value.toJSON === "function") {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === "function") {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case "string":
return quote(value);
case "number":
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value)
? String(value)
: "null";
case "boolean":
case "null":
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce "null". The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is "object", we might be dealing with an object or an array or
// null.
case "object":
// Due to a specification blunder in ECMAScript, typeof null is "object",
// so watch out for that case.
if (!value) {
return "null";
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === "[object Array]") {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || "null";
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? "[]"
: gap
? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]"
: "[" + partial.join(",") + "]";
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === "object") {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === "string") {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (
gap
? ": "
: ":"
) + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (
gap
? ": "
: ":"
) + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? "{}"
: gap
? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}"
: "{" + partial.join(",") + "}";
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== "function") {
meta = { // table of character substitutions
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
"\"": "\\\"",
"\\": "\\\\"
};
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = "";
indent = "";
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === "number") {
for (i = 0; i < space; i += 1) {
indent += " ";
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === "string") {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== "function" &&
(typeof replacer !== "object" ||
typeof replacer.length !== "number")) {
throw new Error("JSON.stringify");
}
// Make a fake root object containing our value under the key of "".
// Return the result of stringifying the value.
return str("", {"": value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== "function") {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k;
var v;
var value = holder[key];
if (value && typeof value === "object") {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
rx_dangerous.lastIndex = 0;
if (rx_dangerous.test(text)) {
text = text.replace(rx_dangerous, function (a) {
return "\\u" +
("0000" + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with "()" and "new"
// because they can cause invocation, and "=" because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with "@" (a non-JSON character). Second, we
// replace all simple value tokens with "]" characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or "]" or
// "," or ":" or "{" or "}". If that is so, then the text is safe for eval.
if (
rx_one.test(
text
.replace(rx_two, "@")
.replace(rx_three, "]")
.replace(rx_four, "")
)
) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The "{" operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval("(" + text + ")");
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return (typeof reviver === "function")
? walk({"": j}, "")
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError("JSON.parse");
};
}
}());

502
node_modules/store/plugins/lib/lz-string.js generated vendored Normal file
View File

@@ -0,0 +1,502 @@
/* eslint-disable */
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
// This work is free. You can redistribute it and/or modify it
// under the terms of the WTFPL, Version 2
// For more information see LICENSE.txt or http://www.wtfpl.net/
//
// For more information, the home page:
// http://pieroxy.net/blog/pages/lz-string/testing.html
//
// LZ-based compression algorithm, version 1.4.4
var LZString = (function() {
// private property
var f = String.fromCharCode;
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
var baseReverseDic = {};
function getBaseValue(alphabet, character) {
if (!baseReverseDic[alphabet]) {
baseReverseDic[alphabet] = {};
for (var i=0 ; i<alphabet.length ; i++) {
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
}
}
return baseReverseDic[alphabet][character];
}
var LZString = {
compressToBase64 : function (input) {
if (input == null) return "";
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
switch (res.length % 4) { // To produce valid Base64
default: // When could this happen ?
case 0 : return res;
case 1 : return res+"===";
case 2 : return res+"==";
case 3 : return res+"=";
}
},
decompressFromBase64 : function (input) {
if (input == null) return "";
if (input == "") return null;
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
},
compressToUTF16 : function (input) {
if (input == null) return "";
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
},
decompressFromUTF16: function (compressed) {
if (compressed == null) return "";
if (compressed == "") return null;
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
},
//compress into uint8array (UCS-2 big endian format)
compressToUint8Array: function (uncompressed) {
var compressed = LZString.compress(uncompressed);
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
var current_value = compressed.charCodeAt(i);
buf[i*2] = current_value >>> 8;
buf[i*2+1] = current_value % 256;
}
return buf;
},
//decompress from uint8array (UCS-2 big endian format)
decompressFromUint8Array:function (compressed) {
if (compressed===null || compressed===undefined){
return LZString.decompress(compressed);
} else {
var buf=new Array(compressed.length/2); // 2 bytes per character
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
buf[i]=compressed[i*2]*256+compressed[i*2+1];
}
var result = [];
buf.forEach(function (c) {
result.push(f(c));
});
return LZString.decompress(result.join(''));
}
},
//compress into a string that is already URI encoded
compressToEncodedURIComponent: function (input) {
if (input == null) return "";
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
},
//decompress from an output of compressToEncodedURIComponent
decompressFromEncodedURIComponent:function (input) {
if (input == null) return "";
if (input == "") return null;
input = input.replace(/ /g, "+");
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
},
compress: function (uncompressed) {
return LZString._compress(uncompressed, 16, function(a){return f(a);});
},
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
if (uncompressed == null) return "";
var i, value,
context_dictionary= {},
context_dictionaryToCreate= {},
context_c="",
context_wc="",
context_w="",
context_enlargeIn= 2, // Compensate for the first entry which should not count
context_dictSize= 3,
context_numBits= 2,
context_data=[],
context_data_val=0,
context_data_position=0,
ii;
for (ii = 0; ii < uncompressed.length; ii += 1) {
context_c = uncompressed.charAt(ii);
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
context_dictionary[context_c] = context_dictSize++;
context_dictionaryToCreate[context_c] = true;
}
context_wc = context_w + context_c;
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
context_w = context_wc;
} else {
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
if (context_w.charCodeAt(0)<256) {
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
}
value = context_w.charCodeAt(0);
for (i=0 ; i<8 ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
} else {
value = 1;
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1) | value;
if (context_data_position ==bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = 0;
}
value = context_w.charCodeAt(0);
for (i=0 ; i<16 ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0) {
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
delete context_dictionaryToCreate[context_w];
} else {
value = context_dictionary[context_w];
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0) {
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
// Add wc to the dictionary.
context_dictionary[context_wc] = context_dictSize++;
context_w = String(context_c);
}
}
// Output the code for w.
if (context_w !== "") {
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
if (context_w.charCodeAt(0)<256) {
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
}
value = context_w.charCodeAt(0);
for (i=0 ; i<8 ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
} else {
value = 1;
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1) | value;
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = 0;
}
value = context_w.charCodeAt(0);
for (i=0 ; i<16 ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0) {
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
delete context_dictionaryToCreate[context_w];
} else {
value = context_dictionary[context_w];
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0) {
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
}
// Mark the end of the stream
value = 2;
for (i=0 ; i<context_numBits ; i++) {
context_data_val = (context_data_val << 1) | (value&1);
if (context_data_position == bitsPerChar-1) {
context_data_position = 0;
context_data.push(getCharFromInt(context_data_val));
context_data_val = 0;
} else {
context_data_position++;
}
value = value >> 1;
}
// Flush the last char
while (true) {
context_data_val = (context_data_val << 1);
if (context_data_position == bitsPerChar-1) {
context_data.push(getCharFromInt(context_data_val));
break;
}
else context_data_position++;
}
return context_data.join('');
},
decompress: function (compressed) {
if (compressed == null) return "";
if (compressed == "") return null;
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
},
_decompress: function (length, resetValue, getNextValue) {
var dictionary = [],
next,
enlargeIn = 4,
dictSize = 4,
numBits = 3,
entry = "",
result = [],
i,
w,
bits, resb, maxpower, power,
c,
data = {val:getNextValue(0), position:resetValue, index:1};
for (i = 0; i < 3; i += 1) {
dictionary[i] = i;
}
bits = 0;
maxpower = Math.pow(2,2);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
switch (next = bits) {
case 0:
bits = 0;
maxpower = Math.pow(2,8);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
c = f(bits);
break;
case 1:
bits = 0;
maxpower = Math.pow(2,16);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
c = f(bits);
break;
case 2:
return "";
}
dictionary[3] = c;
w = c;
result.push(c);
while (true) {
if (data.index > length) {
return "";
}
bits = 0;
maxpower = Math.pow(2,numBits);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
switch (c = bits) {
case 0:
bits = 0;
maxpower = Math.pow(2,8);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
dictionary[dictSize++] = f(bits);
c = dictSize-1;
enlargeIn--;
break;
case 1:
bits = 0;
maxpower = Math.pow(2,16);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
dictionary[dictSize++] = f(bits);
c = dictSize-1;
enlargeIn--;
break;
case 2:
return result.join('');
}
if (enlargeIn == 0) {
enlargeIn = Math.pow(2, numBits);
numBits++;
}
if (dictionary[c]) {
entry = dictionary[c];
} else {
if (c === dictSize) {
entry = w + w.charAt(0);
} else {
return null;
}
}
result.push(entry);
// Add w+entry[0] to the dictionary.
dictionary[dictSize++] = w + entry.charAt(0);
enlargeIn--;
w = entry;
if (enlargeIn == 0) {
enlargeIn = Math.pow(2, numBits);
numBits++;
}
}
}
};
return LZString;
})();
if (typeof define === 'function' && define.amd) {
define(function () { return LZString; });
} else if( typeof module !== 'undefined' && module != null ) {
module.exports = LZString
}

19
node_modules/store/plugins/observe.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
var eventsPlugin = require('./events')
module.exports = [eventsPlugin, observePlugin]
function observePlugin() {
return {
observe: observe,
unobserve: unobserve
}
function observe(_, key, callback) {
var subId = this.watch(key, callback)
callback(this.get(key))
return subId
}
function unobserve(_, subId) {
this.unwatch(subId)
}
}

31
node_modules/store/plugins/observe_test.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
module.exports = {
plugin: require('./observe'),
setup: setup,
}
function setup(store) {
test('observe', function() {
store.clearAll()
var count = -1
var expect = [undefined]
var obsId = store.observe('foo', function(val, oldVal) {
count += 1
assert(expect[count] == val)
assert(expect[count - 1] == oldVal)
}) // count == 1
store.unobserve(obsId)
expect.push('bar')
store.set('foo', 'bar')
store.observe('foo', function(val, oldVal) {
count += 1
assert(expect[count] == val)
assert(expect[count - 1] == oldVal)
}) // count == 2
expect.push('bar2')
store.set('foo', 'bar2') // count == 3
assert(count + 1 == expect.length)
})
}

58
node_modules/store/plugins/operations.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
var util = require('../src/util')
var slice = util.slice
var assign = util.assign
var updatePlugin = require('./update')
module.exports = [updatePlugin, operationsPlugin]
function operationsPlugin() {
return {
// array
push: push,
pop: pop,
shift: shift,
unshift: unshift,
// obj
assign: assign_,
}
// array
function push(_, key, val1, val2, val3, etc) {
return _arrayOp.call(this, 'push', arguments)
}
function pop(_, key) {
return _arrayOp.call(this, 'pop', arguments)
}
function shift(_, key) {
return _arrayOp.call(this, 'shift', arguments)
}
function unshift(_, key, val1, val2, val3, etc) {
return _arrayOp.call(this, 'unshift', arguments)
}
// obj
function assign_(_, key, props1, props2, props3, etc) {
var varArgs = slice(arguments, 2)
return this.update(key, {}, function(val) {
if (typeof val != 'object') {
throw new Error('store.assign called for non-object value with key "'+key+'"')
}
varArgs.unshift(val)
return assign.apply(Object, varArgs)
})
}
// internal
///////////
function _arrayOp(arrayFn, opArgs) {
var res
var key = opArgs[1]
var rest = slice(opArgs, 2)
this.update(key, [], function(arrVal) {
res = Array.prototype[arrayFn].apply(arrVal, rest)
})
return res
}
}

72
node_modules/store/plugins/operations_test.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
var { each, map } = require('../src/util')
var { deepEqual } = require('../tests/util')
module.exports = {
plugin: require('./operations'),
setup: setup,
}
function setup(store) {
test('push', function() {
_testArrayOp('push', [], [
[],
['a'],
['b','c'],
[null],
[[], {}]
])
})
test('unshift', function() {
_testArrayOp('unshift', undefined, [
[],
['a'],
['b','c'],
[null],
[[], {}]
])
})
test('pop', function() {
var arr = ['a', 'b', 'c', null, [[], {}]]
// Call pop arr.length + 1 times. No args each time
var argsList = map(arr, function() { return [] }).concat([])
_testArrayOp('pop', arr, argsList)
})
test('shift', function() {
var arr = ['a', 'b', 'c', null, [[], {}]]
// Call shift arr.length + 1 times. No args each time
var argsList = map(arr, function() { return [] }).concat([])
_testArrayOp('shift', arr, argsList)
})
test('assign', function() {
store.clearAll()
var expect = { bar:'cat', mat:{ hat:'bat', arr:[1,2,3] }}
store.assign('foo', expect)
assert(deepEqual(store.get('foo'), expect))
var add = { bar:'cat2', mat:{ hat:'bat2' }, newProp:'newProp'}
store.assign('foo', add)
each(add, function(val, key) {
expect[key] = val
})
assert(deepEqual(store.get('foo'), expect))
})
function _testArrayOp(fnName, arr, argLists) {
var key = 'test-'+fnName
store.set(key, arr)
arr = (arr || [])
var arrFn = arr[fnName]
var storeFn = store[fnName]
each(argLists, function(args) {
var expectedFnResult = arrFn.apply(arr, args)
var actualFnResult = storeFn.apply(store, [key].concat(args))
assert(deepEqual(expectedFnResult, actualFnResult))
var actual = store.get(key)
assert(deepEqual(arr, actual))
})
}
}

17
node_modules/store/plugins/update.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
module.exports = updatePlugin
function updatePlugin() {
return {
update: update
}
function update(_, key, optDefaultVal, updateFn) {
if (arguments.length == 3) {
updateFn = optDefaultVal
optDefaultVal = undefined
}
var val = this.get(key, optDefaultVal)
var retVal = updateFn(val)
this.set(key, retVal != undefined ? retVal : val)
}
}

43
node_modules/store/plugins/update_test.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
module.exports = {
plugin: require('./update'),
setup: setup,
}
function setup(store) {
test('update', function() {
store.set('foo', { cat:'mat' })
assert(store.get('foo').cat == 'mat')
store.update('foo', function(foo) {
foo.cat = 'mat2'
})
assert(store.get('foo').cat == 'mat2')
})
test('update return value', function() {
store.clearAll()
store.update('foo', function(foo) {
assert(foo == undefined)
return { cat:'mat4' }
})
assert(store.get('foo').cat == 'mat4')
})
test('update default value', function() {
store.clearAll()
store.update('foo2', {}, function(foo2) {
foo2.bar = 'cat'
})
assert(store.get('foo2').bar == 'cat')
})
test('update default value + return', function() {
store.clearAll()
store.update('foo2', [], function(foor2) {
return { bar2:'cat2' }
})
assert(typeof store.get('foo2') == 'object')
assert(store.get('foo2').bar == undefined)
assert(store.get('foo2').bar2 == 'cat2')
})
}

52
node_modules/store/plugins/v1-backcompat.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
var dumpPlugin = require('./dump')
var json2Plugin = require('./json2')
module.exports = [dumpPlugin, json2Plugin, v1BackcompatPlugin]
function v1BackcompatPlugin() {
this.disabled = !this.enabled
return {
has: backcompat_has,
transact: backcompat_transact,
clear: backcompat_clear,
forEach: backcompat_forEach,
getAll: backcompat_getAll,
serialize: backcompat_serialize,
deserialize: backcompat_deserialize,
}
}
function backcompat_has(_, key) {
return this.get(key) !== undefined
}
function backcompat_transact(_, key, defaultVal, transactionFn) {
if (transactionFn == null) {
transactionFn = defaultVal
defaultVal = null
}
if (defaultVal == null) {
defaultVal = {}
}
var val = this.get(key, defaultVal)
var ret = transactionFn(val)
this.set(key, ret === undefined ? val : ret)
}
function backcompat_clear(_) {
return this.clearAll.call(this)
}
function backcompat_forEach(_, fn) {
return this.each.call(this, function(val, key) {
fn(key, val)
})
}
function backcompat_getAll(_) {
return this.dump.call(this)
}
function backcompat_serialize(_, value) {
return JSON.stringify(value)
}
function backcompat_deserialize(_, value) {
if (typeof value != 'string') { return undefined }
try { return JSON.parse(value) }
catch(e) { return value || undefined }
}

44
node_modules/store/plugins/v1-backcompat_test.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
module.exports = {
plugin: require('./v1-backcompat'),
setup: setup,
}
function setup(store) {
test('backwards compatability with v1', function() {
store.clear()
assert(typeof store.disabled == 'boolean')
assert(typeof store.enabled == 'boolean')
assert(typeof store.version == 'string')
assert(typeof store.set == 'function')
assert(typeof store.get == 'function')
assert(typeof store.has == 'function')
assert(typeof store.remove == 'function')
assert(typeof store.clear == 'function')
assert(typeof store.transact == 'function')
assert(typeof store.getAll == 'function')
assert(typeof store.forEach == 'function')
assert(typeof store.serialize == 'function')
assert(typeof store.deserialize == 'function')
store.transact('foosact', function(val) {
assert(typeof val == 'object', "new key is not an object at beginning of transaction")
val.foo = 'foo'
})
store.transact('foosact', function(val) {
assert(val.foo == 'foo', "first transaction did not register")
val.bar = 'bar'
})
assert(store.getAll().foosact.foo == 'foo')
var wasCalled = false
store.forEach(function(key, val) {
wasCalled = true
assert(key == 'foosact')
assert(val.foo == 'foo')
})
assert(wasCalled)
assert(store.serialize({}) == '{}')
assert(store.get('foosact').bar == 'bar', "second transaction did not register")
})
}

83
node_modules/store/scripts/compile-builds.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
#!/usr/local/bin/node
var fs = require('fs')
var path = require('path')
var browserify = require('browserify')
var UglifyJS = require('uglify-js')
var base = __dirname + '/..'
module.exports = {
run: run,
}
if (require.main === module) {
main()
}
function main() {
run(function(err) {
if (err) { throw err }
})
}
function run(callback) {
var dir = base+'/dist'
fs.readdir(dir, function(err, items) {
next()
function next() {
var item = items.shift()
if (!item) {
return callback()
}
if (item[0] == '.') {
return next()
}
if (item.match(/\.min\.js$/)) {
return next()
}
var input = path.resolve(dir+'/'+item)
var output = input.replace(/\.js$/, '.min.js')
console.log('compile', input, '->', output)
compileFile(input, output, function(err) {
if (err) {
return callback(err)
}
next()
})
}
})
}
function compileFile(input, output, callback) {
var copyright = '/* store.js - Copyright (c) 2010-2017 Marcus Westin */'
// TODO: sourcemaps - depends on https://github.com/mishoo/UglifyJS2/issues/520
browserify([input], { standalone:'store', expose:'store' }) // TODO: sourcemaps - use `debug:true`
.transform('babelify', { presets:['es2015'] }) // TODO: sourcemaps - use `sourceMaps:true`
.bundle(processResult)
function processResult(err, buf) {
if (err) { return callback(err) }
var code = buf.toString()
code = minify(code)
var result = copyright+'\n'+code
fs.writeFile(output, result, function(err) {
if (err) { return callback(err) }
var b = Buffer.byteLength(result, 'utf8')
var k = Math.round(b/1000)
console.log(k+'k \t('+b+')')
callback()
})
}
}
function minify(code) {
var minified = UglifyJS.minify(code, {
fromString: true,
compress: { screw_ie8:false },
mangle: { screw_ie8:false },
output: { screw_ie8:false },
// warnings: true,
// mangleProperties: { reserved:[] },
})
return minified.code // TODO: sourcemaps - use `result.map`.
}

6
node_modules/store/scripts/create-tunnel.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
var port = 9575
var tunnel = require('./saucelabs/tunnel')
tunnel.setup(port, function(err, url) {
console.log("Tunnel up and running at", url)
})

71
node_modules/store/scripts/release.sh generated vendored Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/bash
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # scripts/
cd ../ # store.js project root
VERSION=$1
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$VERSION is not a valid semver (e.g 2.1.3)"
exit -1
fi
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ "$GIT_BRANCH" != "master" ]; then
echo "release.sh must be called from branch master (current: $GIT_BRANCH)"
exit -1
fi
if ! git diff-index --quiet HEAD --; then
echo "git repo is dirty. Commit all changes before using release.sh"
exit -1
fi
echo
echo "> Bump package.json version:"
echo
sed -E s/'"version"\: "[0-9]+\.[0-9]+\.[0-9]+"'/'"version"\: "'$VERSION'"'/ package.json \
> /tmp/package.json && \
mv /tmp/package.json package.json
cat package.json | grep $VERSION -C 1
echo
echo "> Bump store-engine.js version:"
echo
sed -E s/"version\: '[0-9]+\.[0-9]+\.[0-9]+'"/"version\: '$VERSION'"/ src/store-engine.js \
> /tmp/store-engine.js && \
mv /tmp/store-engine.js src/store-engine.js
cat src/store-engine.js | grep $VERSION -C 1
if [[ ! `git diff --stat` =~ "2 files changed, 2 insertions(+), 2 deletions(-)" ]]; then
echo "WARNING! Expected exactly 2 changes in 2 files after replacing version number. Bailing! (check git status and git diff)"
exit -1
fi
echo
while true; do
read -p "> Ready to build, commit, tag and release v$VERSION? (y/n): " yn
case $yn in
[Yy]* ) break;;
[NnQq]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo
echo "> Build dists"
node scripts/compile-builds.js
echo
echo "> git commit/push/tag/push --tags"
set -x
git add dist/* package.json src/store-engine.js
git commit -m "v$VERSION"
git push $ORIGIN $BRANCH
git tag -a "v$VERSION" -m "Tag v$VERSION"
git push --tags
set +x
echo
echo "> npm publish"
npm publish

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env node
var budo = require('budo')
budo(__dirname+'/../dist/store.tests.js', {
live: true,
stream: process.stdout,
port: 9966,
debug: true,
open: true,
title: 'store.js browser tests',
})

10
node_modules/store/scripts/run-node-tests.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/local/bin/node
// simulate localStorage - must be done before importing tests
var { Global } = require('../src/util')
Global.localStorage = require('localStorage')
// Import and run tests
var tests = require('../tests/tests')
tests.runTests()

66
node_modules/store/scripts/run-saucelabs-tests.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/local/bin/node
var port = 9574
var username = 'storejs'
var password = new Buffer('ZjhjMzUyNjgtNzc2ZC00ZjlkLWEwNWUtN2FkM2Q0ZDgyNzk5', 'base64').toString('utf8')
// TODO: Contribute to npm-saucelabs? Create new module?
var saucelabs = require('./saucelabs/saucelabs')
var tunnel = require('./saucelabs/tunnel')
main(function(err) {
if (err) { throw err }
log('All done!')
})
function main() {
var platformSetNames = process.argv.slice(2)
var platformSets = platformSetNames.map(function(platformSetName) {
var platformSet = saucelabs.platformSets[platformSetName]
if (!platformSet) {
throw new Error("Unknown platform set: "+platformSetName)
}
return platformSet
})
if (platformSets.length == 0) {
var s = saucelabs.platformSets
var platformSets = [
// All supported platforms:
///////////////////////////
s.ie,
s.safari,
s.firefox,
s.chrome,
s.android,
s.ios,
s.opera,
// Specific test targets for development:
/////////////////////////////////////////
// s.fast,
// s.ie6, s.ie7, s.ie8,
// s.ie9, s.ie10, s.ie11,
// s.firefox4, s.firefox5,
// s.ie10,
]
}
tunnel.setup(port, function(err, url) {
if (err) { throw err }
saucelabs.setAuth(username, password)
saucelabs.runTest(url, platformSets, onDone)
function onDone(err) {
if (err) {
console.log('Error', err)
process.exit(1)
} else {
log('All tests passed!')
process.exit(0)
}
}
})
}
function log() {
console.log.apply(console, arguments)
}

View File

@@ -0,0 +1,13 @@
#!/usr/local/bin/node
var username = 'storejs'
var password = new Buffer('ZjhjMzUyNjgtNzc2ZC00ZjlkLWEwNWUtN2FkM2Q0ZDgyNzk5', 'base64').toString('utf8')
var saucelabs = require('./saucelabs')
saucelabs.setAuth(username, password)
saucelabs.listAllSupportedPlatforms(function(err, res) {
if (err) { throw err }
for (var i=0; i<res.length; i++) {
console.log(res[i])
}
})

59
node_modules/store/scripts/saucelabs/saucelabs-api.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
var request = require('request')
module.exports = {
setAuth: setAuth,
get: get,
post: post
}
var auth = {
user: null,
password: null,
}
function setAuth(saucelabsUsername, saucelabsToken) {
auth.user = saucelabsUsername
auth.password = saucelabsToken
}
function get(path, callback) {
var params = {
url: 'https://saucelabs.com/rest/v1/'+path,
auth: auth
}
// console.log("REQ", params)
request.get(params, function(err, res, body) {
if (err) {
throw err
}
if (res.statusCode != 200) {
console.log(params)
throw new Error('Non-200 status code: '+body)
}
// console.log("RES", params.url, body)
callback(JSON.parse(body))
})
}
function post(path, data, callback) {
var params = {
url: 'https://saucelabs.com/rest/v1/'+auth.user+'/'+path,
auth: { user:auth.user, password:auth.password },
json: data
}
// console.log("REQ", params)
request.post(params, function(err, res, body) {
if (err) {
throw err
}
if (res.statusCode != 200) {
throw new Error('Non-200 status code: '+body)
}
// console.log("RES", params.url, body)
callback(body)
})
}
// https://wiki.saucelabs.com/display/DOCS/JavaScript+Unit+Testing+Methods#JavaScriptUnitTestingMethods-StartJSUnitTests

View File

@@ -0,0 +1,71 @@
// See https://wiki.saucelabs.com/display/DOCS/Platform+Configurator?_ga=1.24059122.934400320.1451142104#/
// See ./list-saucelabs-platforms.js
var CURRENT_VERSION = ''
var BETA_VERSION = 'beta'
var CHROME_VERSIONS = ['31', CURRENT_VERSION]
var FIREFOX_VERSIONS = ['4', '5', '6', '7', CURRENT_VERSION]
var OPERA_VERSIONS = ['11', '12']
var platforms = module.exports = {
// Fast trial runs
//////////////////
fast: {
'Linux': { 'chrome': [CURRENT_VERSION] },
},
// Common browser sets
//////////////////////
ie: {
'Windows XP': { 'internet explorer': ['6', '7', '8'] },
'Windows 7': { 'internet explorer': ['9'] },
'Windows 8': { 'internet explorer': ['10'] },
'Windows 10': { 'internet explorer': ['11'], 'microsoftedge': [CURRENT_VERSION] },
},
safari: {
'Windows 7': { 'safari': ['5'] },
'OS X 10.8': { 'safari': ['6'] },
'OS X 10.9': { 'safari': ['7'] },
'OS X 10.10': { 'safari': ['8'] },
'OS X 10.11': { 'safari': ['9'] },
'OS X 10.12': { 'safari': ['10'] },
},
firefox: {
'Linux': { 'firefox': ['40'] },
'Windows XP': { 'firefox': ['4', '5'] },
'Windows 10': { 'firefox': [CURRENT_VERSION] },
'Mac 10.12': { 'firefox': [CURRENT_VERSION] },
},
android: {
'Linux': { 'android': ['4.4','5.0','5.1'] },
},
ios: {
'Mac 10.10': {
'ipad': ['8.4'],
'iphone':['8.4'],
},
'Mac 10.11': {
'ipad': ['9.3', '10.0'],
'iphone':['9.3', '10.0'],
}
},
chrome: {
'Mac 10.12': { 'chrome':['27', CURRENT_VERSION] },
'Windows 10': { 'chrome':['26', CURRENT_VERSION] },
},
opera: {
'Windows XP': { 'opera':'11' },
'Linux': { 'opera':'12' },
},
// Individual browser versions
//////////////////////////////
ie6: { 'Windows XP': { 'internet explorer': ['6'] } },
ie7: { 'Windows XP': { 'internet explorer': ['7'] } },
ie8: { 'Windows XP': { 'internet explorer': ['8'] } },
ie9: { 'Windows 7': { 'internet explorer': ['9'] } },
ie10:{ 'Windows 8': { 'internet explorer': ['10'] } },
ie11:{ 'Windows 10': { 'internet explorer': ['11'] } },
firefox4: { 'Windows XP': { 'firefox': ['4'] } },
firefox5: { 'Windows XP': { 'firefox': ['5'] } },
}

154
node_modules/store/scripts/saucelabs/saucelabs.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
var _ = require('lodash')
var api = require('./saucelabs-api')
module.exports = {
setAuth: api.setAuth,
listAllSupportedPlatforms: listAllSupportedPlatforms,
runTest: runTest,
platformSets: require('./saucelabs-platformSets'),
}
function listAllSupportedPlatforms(callback) {
api.get('info/platforms/webdriver', function(platformsInfo) {
var platforms = _.map(platformsInfo, function(info) {
return [info['os'], info['api_name'], info['short_version']]
})
platforms.sort(function(a, b) {
a = a.join('-')
b = b.join('-')
return a < b ? -1 : b < a ? 1 : 0
})
callback(null, filterUniquePlatforms(platforms))
})
}
function runTests(url, platforms, callback) {
var params = { maxDuration:1800, url:url, platforms:platforms, framework:'custom', recordVideo:false, recordScreenshots:false, recordLogs:true }
api.post('js-tests', params, callback)
}
function getPlatformId(platform) {
return platform.join('-')
.replace('OS X', 'Mac')
.replace('Windows XP', 'Windows 2003')
.replace('Windows 7', 'Windows 2008')
.replace('Windows 8', 'Windows 2012')
}
function filterUniquePlatforms(platforms) {
var seen = {}
return _.filter(platforms, function(platform) {
var platformId = getPlatformId(platform)
if (seen[platformId]) { return false }
seen[platformId] = true
return true
})
}
function runTest(url, platformSets, callback) {
getPlatformsArg(platformSets, function(platforms) {
var runTestsRes
runTests(url, platforms, function(res) {
runTestsRes = res
loopCheckStatus()
})
function loopCheckStatus() {
getTestsStatus(runTestsRes, function(res) {
var pending = []
var running = []
var passed = []
var failed = []
_.each(res['js tests'], function(test) {
var status = getTestStatus(test)
if (status == PENDING) { pending.push(test) }
else if (status == PASSED) { passed.push(test) }
else if (status == RUNNING) { running.push(test) }
else if (status == FAILED) { failed.push(test) }
else { throw new Error('Bad status') }
})
_.each(_.flatten([passed, pending, running, failed]), function(test) {
console.log(getTestStatus(test), test.id, test.platform, test.status || 'test finished')
})
if (pending.length == 0 && running.length == 0) {
console.log("Test suite completed")
callback(checkTestResults(res))
} else if (res.completed) {
throw new Error('No pending tests, but res.completed == true')
} else {
var delay = 5
console.log("Check again in", delay, "seconds")
setTimeout(loopCheckStatus, delay * 1000)
}
})
}
})
}
function getPlatformsArg(platformSets, callback) {
listAllSupportedPlatforms(function(err, supportedPlatforms) {
if (err) { return callback(err) }
var allSupportedPlatforms = {}
_.each(supportedPlatforms, function(platform) {
allSupportedPlatforms[getPlatformId(platform)] = true
})
var platforms = _.flatten(_.flatten(_.flatten(
_.map(platformSets, function(platformSet) {
return _.map(platformSet, function(browserSpecs, osName) {
return _.map(browserSpecs, function(browserVersions, browserName) {
if (typeof browserVersions == 'string') {
browserVersions = [browserVersions]
}
return _.map(browserVersions, function(browserVersion) {
return [osName, browserName, browserVersion]
})
})
})
})
)))
_.each(platforms, function(platform) {
if (!platform[2]) { return } // Don't sanity-check CURRENT_VERSION
var platformId = getPlatformId(platform)
if (!allSupportedPlatforms[platformId]) {
throw new Error('Unsupported platform: '+platform.join(', ')+' ('+platformId+')')
}
})
callback(filterUniquePlatforms(platforms))
})
}
function getTestsStatus(runTestsRes, callback) {
api.post('js-tests/status', { 'js tests':runTestsRes['js tests'] }, function(res) {
callback(res)
})
}
var PENDING = 'PENDING'
var RUNNING = 'RUNNING'
var FAILED = 'FAILED '
var PASSED = 'PASSED '
function getTestStatus(test) {
if (test.status == 'test error') {
return FAILED
} else if (test.status == 'test session in progress') {
return RUNNING
} else if (test.result) {
return (test.result.failed ? FAILED : PASSED)
} else {
return PENDING
}
}
function checkTestResults(res) {
var failed = 0
_.each(res['js tests'], function(test) {
console.log(getTestStatus(test), test.id, test.status, test.platform, test.url)
if (getTestStatus(test) == FAILED) {
failed += 1
console.log('Result:', test.result)
}
})
return (failed ? failed+' tests failed' : null)
}

73
node_modules/store/scripts/saucelabs/tunnel.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
var http = require('http')
var fs = require('fs')
var ngrok = require('ngrok')
module.exports = {
setup: setup,
}
function setup(port, callback) {
startServer(port, function(err) {
if (err) { return callback(err) }
console.log("Creating tunnel - this might take a few seconds")
startTunnel(port, function(err, url) {
if (err) { return callback(err) }
console.log("tunnel up at", url)
callback(null, url)
})
})
}
function startTunnel(port, callback) {
// return callback(null, 'https://07f51ed4.ngrok.io')
var authtoken = new Buffer('NTJuelB1dUpVSDNycDNjZ3pldHVEXzVnWlNObkpuMlFaR013WjZ0eUZUQw==', 'base64').toString('utf8')
ngrok.connect({ addr:port, subdomain:'storejs-test', authtoken:authtoken }, function(err, url) {
if (err) { return callback(err) }
url = url.replace('https:', 'http:')
callback(null, url)
})
}
function startServer(port, callback) {
var server = http.createServer(handleReq)
server.listen(port)
server.on('listening', function(err) {
if (err) { return callback(err) }
console.log('local server listening on http://localhost:'+port+'/')
callback()
})
function handleReq(req, res) {
console.log(req.url)
if (req.url == '/') {
res.writeHead(200, { 'Content-Type':'text/html' })
res.end(testRunnerHTML)
} else if (req.url == '/store.tests.min.js') {
var headers = {
'Content-Type':'application/javascript',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'
}
res.writeHead(200, headers)
fs.createReadStream(__dirname+'/../../dist/store.tests.min.js').pipe(res)
} else {
res.writeHead(404)
res.end('Not found')
}
}
var testRunnerHTML = `
<!doctype html>
<head>
<title>store.js test runner</title>
</head>
<body>
<h1>store.js test runner</h1>
<script src="/store.tests.min.js"></script>
</body>
</html>
`.replace(/\n\t\t/g, '\n').replace(/^\n/, '')
}

237
node_modules/store/src/store-engine.js generated vendored Normal file
View File

@@ -0,0 +1,237 @@
var util = require('./util')
var slice = util.slice
var pluck = util.pluck
var each = util.each
var bind = util.bind
var create = util.create
var isList = util.isList
var isFunction = util.isFunction
var isObject = util.isObject
module.exports = {
createStore: createStore
}
var storeAPI = {
version: '2.0.12',
enabled: false,
// get returns the value of the given key. If that value
// is undefined, it returns optionalDefaultValue instead.
get: function(key, optionalDefaultValue) {
var data = this.storage.read(this._namespacePrefix + key)
return this._deserialize(data, optionalDefaultValue)
},
// set will store the given value at key and returns value.
// Calling set with value === undefined is equivalent to calling remove.
set: function(key, value) {
if (value === undefined) {
return this.remove(key)
}
this.storage.write(this._namespacePrefix + key, this._serialize(value))
return value
},
// remove deletes the key and value stored at the given key.
remove: function(key) {
this.storage.remove(this._namespacePrefix + key)
},
// each will call the given callback once for each key-value pair
// in this store.
each: function(callback) {
var self = this
this.storage.each(function(val, namespacedKey) {
callback.call(self, self._deserialize(val), (namespacedKey || '').replace(self._namespaceRegexp, ''))
})
},
// clearAll will remove all the stored key-value pairs in this store.
clearAll: function() {
this.storage.clearAll()
},
// additional functionality that can't live in plugins
// ---------------------------------------------------
// hasNamespace returns true if this store instance has the given namespace.
hasNamespace: function(namespace) {
return (this._namespacePrefix == '__storejs_'+namespace+'_')
},
// createStore creates a store.js instance with the first
// functioning storage in the list of storage candidates,
// and applies the the given mixins to the instance.
createStore: function() {
return createStore.apply(this, arguments)
},
addPlugin: function(plugin) {
this._addPlugin(plugin)
},
namespace: function(namespace) {
return createStore(this.storage, this.plugins, namespace)
}
}
function _warn() {
var _console = (typeof console == 'undefined' ? null : console)
if (!_console) { return }
var fn = (_console.warn ? _console.warn : _console.log)
fn.apply(_console, arguments)
}
function createStore(storages, plugins, namespace) {
if (!namespace) {
namespace = ''
}
if (storages && !isList(storages)) {
storages = [storages]
}
if (plugins && !isList(plugins)) {
plugins = [plugins]
}
var namespacePrefix = (namespace ? '__storejs_'+namespace+'_' : '')
var namespaceRegexp = (namespace ? new RegExp('^'+namespacePrefix) : null)
var legalNamespaces = /^[a-zA-Z0-9_\-]*$/ // alpha-numeric + underscore and dash
if (!legalNamespaces.test(namespace)) {
throw new Error('store.js namespaces can only have alphanumerics + underscores and dashes')
}
var _privateStoreProps = {
_namespacePrefix: namespacePrefix,
_namespaceRegexp: namespaceRegexp,
_testStorage: function(storage) {
try {
var testStr = '__storejs__test__'
storage.write(testStr, testStr)
var ok = (storage.read(testStr) === testStr)
storage.remove(testStr)
return ok
} catch(e) {
return false
}
},
_assignPluginFnProp: function(pluginFnProp, propName) {
var oldFn = this[propName]
this[propName] = function pluginFn() {
var args = slice(arguments, 0)
var self = this
// super_fn calls the old function which was overwritten by
// this mixin.
function super_fn() {
if (!oldFn) { return }
each(arguments, function(arg, i) {
args[i] = arg
})
return oldFn.apply(self, args)
}
// Give mixing function access to super_fn by prefixing all mixin function
// arguments with super_fn.
var newFnArgs = [super_fn].concat(args)
return pluginFnProp.apply(self, newFnArgs)
}
},
_serialize: function(obj) {
return JSON.stringify(obj)
},
_deserialize: function(strVal, defaultVal) {
if (!strVal) { return defaultVal }
// It is possible that a raw string value has been previously stored
// in a storage without using store.js, meaning it will be a raw
// string value instead of a JSON serialized string. By defaulting
// to the raw string value in case of a JSON parse error, we allow
// for past stored values to be forwards-compatible with store.js
var val = ''
try { val = JSON.parse(strVal) }
catch(e) { val = strVal }
return (val !== undefined ? val : defaultVal)
},
_addStorage: function(storage) {
if (this.enabled) { return }
if (this._testStorage(storage)) {
this.storage = storage
this.enabled = true
}
},
_addPlugin: function(plugin) {
var self = this
// If the plugin is an array, then add all plugins in the array.
// This allows for a plugin to depend on other plugins.
if (isList(plugin)) {
each(plugin, function(plugin) {
self._addPlugin(plugin)
})
return
}
// Keep track of all plugins we've seen so far, so that we
// don't add any of them twice.
var seenPlugin = pluck(this.plugins, function(seenPlugin) {
return (plugin === seenPlugin)
})
if (seenPlugin) {
return
}
this.plugins.push(plugin)
// Check that the plugin is properly formed
if (!isFunction(plugin)) {
throw new Error('Plugins must be function values that return objects')
}
var pluginProperties = plugin.call(this)
if (!isObject(pluginProperties)) {
throw new Error('Plugins must return an object of function properties')
}
// Add the plugin function properties to this store instance.
each(pluginProperties, function(pluginFnProp, propName) {
if (!isFunction(pluginFnProp)) {
throw new Error('Bad plugin property: '+propName+' from plugin '+plugin.name+'. Plugins should only return functions.')
}
self._assignPluginFnProp(pluginFnProp, propName)
})
},
// Put deprecated properties in the private API, so as to not expose it to accidential
// discovery through inspection of the store object.
// Deprecated: addStorage
addStorage: function(storage) {
_warn('store.addStorage(storage) is deprecated. Use createStore([storages])')
this._addStorage(storage)
}
}
var store = create(_privateStoreProps, storeAPI, {
plugins: []
})
store.raw = {}
each(store, function(prop, propName) {
if (isFunction(prop)) {
store.raw[propName] = bind(store, prop)
}
})
each(storages, function(storage) {
store._addStorage(storage)
})
each(plugins, function(plugin) {
store._addPlugin(plugin)
})
return store
}

118
node_modules/store/src/util.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
var assign = make_assign()
var create = make_create()
var trim = make_trim()
var Global = (typeof window !== 'undefined' ? window : global)
module.exports = {
assign: assign,
create: create,
trim: trim,
bind: bind,
slice: slice,
each: each,
map: map,
pluck: pluck,
isList: isList,
isFunction: isFunction,
isObject: isObject,
Global: Global
}
function make_assign() {
if (Object.assign) {
return Object.assign
} else {
return function shimAssign(obj, props1, props2, etc) {
for (var i = 1; i < arguments.length; i++) {
each(Object(arguments[i]), function(val, key) {
obj[key] = val
})
}
return obj
}
}
}
function make_create() {
if (Object.create) {
return function create(obj, assignProps1, assignProps2, etc) {
var assignArgsList = slice(arguments, 1)
return assign.apply(this, [Object.create(obj)].concat(assignArgsList))
}
} else {
function F() {} // eslint-disable-line no-inner-declarations
return function create(obj, assignProps1, assignProps2, etc) {
var assignArgsList = slice(arguments, 1)
F.prototype = obj
return assign.apply(this, [new F()].concat(assignArgsList))
}
}
}
function make_trim() {
if (String.prototype.trim) {
return function trim(str) {
return String.prototype.trim.call(str)
}
} else {
return function trim(str) {
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '')
}
}
}
function bind(obj, fn) {
return function() {
return fn.apply(obj, Array.prototype.slice.call(arguments, 0))
}
}
function slice(arr, index) {
return Array.prototype.slice.call(arr, index || 0)
}
function each(obj, fn) {
pluck(obj, function(val, key) {
fn(val, key)
return false
})
}
function map(obj, fn) {
var res = (isList(obj) ? [] : {})
pluck(obj, function(v, k) {
res[k] = fn(v, k)
return false
})
return res
}
function pluck(obj, fn) {
if (isList(obj)) {
for (var i=0; i<obj.length; i++) {
if (fn(obj[i], i)) {
return obj[i]
}
}
} else {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (fn(obj[key], key)) {
return obj[key]
}
}
}
}
}
function isList(val) {
return (val != null && typeof val != 'function' && typeof val.length == 'number')
}
function isFunction(val) {
return val && {}.toString.call(val) === '[object Function]'
}
function isObject(val) {
return val && {}.toString.call(val) === '[object Object]'
}

9
node_modules/store/storages/all.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
module.exports = [
// Listed in order of usage preference
require('./localStorage'),
require('./oldFF-globalStorage'),
require('./oldIE-userDataStorage'),
require('./cookieStorage'),
require('./sessionStorage'),
require('./memoryStorage')
]

61
node_modules/store/storages/cookieStorage.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
// cookieStorage is useful Safari private browser mode, where localStorage
// doesn't work but cookies do. This implementation is adopted from
// https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage
var util = require('../src/util')
var Global = util.Global
var trim = util.trim
module.exports = {
name: 'cookieStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll,
}
var doc = Global.document
function read(key) {
if (!key || !_has(key)) { return null }
var regexpStr = "(?:^|.*;\\s*)" +
escape(key).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"
return unescape(doc.cookie.replace(new RegExp(regexpStr), "$1"))
}
function each(callback) {
var cookies = doc.cookie.split(/; ?/g)
for (var i = cookies.length - 1; i >= 0; i--) {
if (!trim(cookies[i])) {
continue
}
var kvp = cookies[i].split('=')
var key = unescape(kvp[0])
var val = unescape(kvp[1])
callback(val, key)
}
}
function write(key, data) {
if(!key) { return }
doc.cookie = escape(key) + "=" + escape(data) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"
}
function remove(key) {
if (!key || !_has(key)) {
return
}
doc.cookie = escape(key) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"
}
function clearAll() {
each(function(_, key) {
remove(key)
})
}
function _has(key) {
return (new RegExp("(?:^|;\\s*)" + escape(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(doc.cookie)
}

38
node_modules/store/storages/localStorage.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
var util = require('../src/util')
var Global = util.Global
module.exports = {
name: 'localStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll,
}
function localStorage() {
return Global.localStorage
}
function read(key) {
return localStorage().getItem(key)
}
function write(key, data) {
return localStorage().setItem(key, data)
}
function each(fn) {
for (var i = localStorage().length - 1; i >= 0; i--) {
var key = localStorage().key(i)
fn(read(key), key)
}
}
function remove(key) {
return localStorage().removeItem(key)
}
function clearAll() {
return localStorage().clear()
}

39
node_modules/store/storages/memoryStorage.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
// memoryStorage is a useful last fallback to ensure that the store
// is functions (meaning store.get(), store.set(), etc will all function).
// However, stored values will not persist when the browser navigates to
// a new page or reloads the current page.
module.exports = {
name: 'memoryStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll,
}
var memoryStorage = {}
function read(key) {
return memoryStorage[key]
}
function write(key, data) {
memoryStorage[key] = data
}
function each(callback) {
for (var key in memoryStorage) {
if (memoryStorage.hasOwnProperty(key)) {
callback(memoryStorage[key], key)
}
}
}
function remove(key) {
delete memoryStorage[key]
}
function clearAll(key) {
memoryStorage = {}
}

42
node_modules/store/storages/oldFF-globalStorage.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
// oldFF-globalStorage provides storage for Firefox
// versions 6 and 7, where no localStorage, etc
// is available.
var util = require('../src/util')
var Global = util.Global
module.exports = {
name: 'oldFF-globalStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll,
}
var globalStorage = Global.globalStorage
function read(key) {
return globalStorage[key]
}
function write(key, data) {
globalStorage[key] = data
}
function each(fn) {
for (var i = globalStorage.length - 1; i >= 0; i--) {
var key = globalStorage.key(i)
fn(globalStorage[key], key)
}
}
function remove(key) {
return globalStorage.removeItem(key)
}
function clearAll() {
each(function(key, _) {
delete globalStorage[key]
})
}

127
node_modules/store/storages/oldIE-userDataStorage.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
// oldIE-userDataStorage provides storage for Internet Explorer
// versions 6 and 7, where no localStorage, sessionStorage, etc
// is available.
var util = require('../src/util')
var Global = util.Global
module.exports = {
name: 'oldIE-userDataStorage',
write: write,
read: read,
each: each,
remove: remove,
clearAll: clearAll,
}
var storageName = 'storejs'
var doc = Global.document
var _withStorageEl = _makeIEStorageElFunction()
var disable = (Global.navigator ? Global.navigator.userAgent : '').match(/ (MSIE 8|MSIE 9|MSIE 10)\./) // MSIE 9.x, MSIE 10.x
function write(unfixedKey, data) {
if (disable) { return }
var fixedKey = fixKey(unfixedKey)
_withStorageEl(function(storageEl) {
storageEl.setAttribute(fixedKey, data)
storageEl.save(storageName)
})
}
function read(unfixedKey) {
if (disable) { return }
var fixedKey = fixKey(unfixedKey)
var res = null
_withStorageEl(function(storageEl) {
res = storageEl.getAttribute(fixedKey)
})
return res
}
function each(callback) {
_withStorageEl(function(storageEl) {
var attributes = storageEl.XMLDocument.documentElement.attributes
for (var i=attributes.length-1; i>=0; i--) {
var attr = attributes[i]
callback(storageEl.getAttribute(attr.name), attr.name)
}
})
}
function remove(unfixedKey) {
var fixedKey = fixKey(unfixedKey)
_withStorageEl(function(storageEl) {
storageEl.removeAttribute(fixedKey)
storageEl.save(storageName)
})
}
function clearAll() {
_withStorageEl(function(storageEl) {
var attributes = storageEl.XMLDocument.documentElement.attributes
storageEl.load(storageName)
for (var i=attributes.length-1; i>=0; i--) {
storageEl.removeAttribute(attributes[i].name)
}
storageEl.save(storageName)
})
}
// Helpers
//////////
// In IE7, keys cannot start with a digit or contain certain chars.
// See https://github.com/marcuswestin/store.js/issues/40
// See https://github.com/marcuswestin/store.js/issues/83
var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g")
function fixKey(key) {
return key.replace(/^\d/, '___$&').replace(forbiddenCharsRegex, '___')
}
function _makeIEStorageElFunction() {
if (!doc || !doc.documentElement || !doc.documentElement.addBehavior) {
return null
}
var scriptTag = 'script',
storageOwner,
storageContainer,
storageEl
// Since #userData storage applies only to specific paths, we need to
// somehow link our data to a specific path. We choose /favicon.ico
// as a pretty safe option, since all browsers already make a request to
// this URL anyway and being a 404 will not hurt us here. We wrap an
// iframe pointing to the favicon in an ActiveXObject(htmlfile) object
// (see: http://msdn.microsoft.com/en-us/library/aa752574(v=VS.85).aspx)
// since the iframe access rules appear to allow direct access and
// manipulation of the document element, even for a 404 page. This
// document can be used instead of the current document (which would
// have been limited to the current path) to perform #userData storage.
try {
/* global ActiveXObject */
storageContainer = new ActiveXObject('htmlfile')
storageContainer.open()
storageContainer.write('<'+scriptTag+'>document.w=window</'+scriptTag+'><iframe src="/favicon.ico"></iframe>')
storageContainer.close()
storageOwner = storageContainer.w.frames[0].document
storageEl = storageOwner.createElement('div')
} catch(e) {
// somehow ActiveXObject instantiation failed (perhaps some special
// security settings or otherwse), fall back to per-path storage
storageEl = doc.createElement('div')
storageOwner = doc.body
}
return function(storeFunction) {
var args = [].slice.call(arguments, 0)
args.unshift(storageEl)
// See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx
// and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx
storageOwner.appendChild(storageEl)
storageEl.addBehavior('#default#userData')
storageEl.load(storageName)
storeFunction.apply(this, args)
storageOwner.removeChild(storageEl)
return
}
}

38
node_modules/store/storages/sessionStorage.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
var util = require('../src/util')
var Global = util.Global
module.exports = {
name: 'sessionStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll
}
function sessionStorage() {
return Global.sessionStorage
}
function read(key) {
return sessionStorage().getItem(key)
}
function write(key, data) {
return sessionStorage().setItem(key, data)
}
function each(fn) {
for (var i = sessionStorage().length - 1; i >= 0; i--) {
var key = sessionStorage().key(i)
fn(read(key), key)
}
}
function remove(key) {
return sessionStorage().removeItem(key)
}
function clearAll() {
return sessionStorage().clear()
}

10
node_modules/store/sublime-storejs.sublime-project generated vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"settings": {
"tab_size": 4
},
"folders": [{
"path": "./",
"folder_exclude_patterns": ["node_modules"],
"file_exclude_patterns": ["*.min.js"],
}]
}

14
node_modules/store/tests/bugs/all.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
test.group('bugs', function() {
test('gh-215: "Expire plugin doesn\'t factor custom namespaces"', function() {
require('./gh-215')
})
test('gh-235: "Expire and Events plugins conflict with each other"', function() {
require('./gh-235')
})
test('gh-236: "No supported storage has been added"', function() {
require('./gh-236')
})
test('gh-239: "No supported storage has been added! Add one"', function() {
require('./gh-239')
})
})

26
node_modules/store/tests/bugs/gh-215.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* eslint semi: "off", indent: "off" */
// https://github.com/marcuswestin/store.js/issues/215
var engine = require('../../src/store-engine');
var storages = [require('../../storages/memoryStorage')];
var plugins = [require('../../plugins/expire')];
const store1 = engine.createStore(storages, plugins, '');
const store2 = store1.namespace('store2')
const store3 = store1.namespace('store3')
var time = Math.floor(new Date().getTime() / 10) * 10
var expiration1 = time + 1001
var expiration2 = null
var expiration3 = time + 3003
var key = 'foo'
var val = 'bar'
store1.set(key, val, expiration1)
store2.set(key, val, expiration2)
store3.set(key, val, expiration3)
assert(store1.getExpiration(key) == expiration1)
assert(store2.getExpiration(key) == expiration2)
assert(store3.getExpiration(key) == expiration3)

14
node_modules/store/tests/bugs/gh-235.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
/* eslint semi: "off", indent: "off" */
// https://github.com/marcuswestin/store.js/issues/235
var engine = require('../../src/store-engine');
const store = engine.createStore(
[ require('../../storages/localStorage'), require('../../storages/memoryStorage') ],
[ require('../../plugins/expire'), require('../../plugins/events') ]
);
store.set('foo', 'bar', new Date().getTime() - 1);
store.set('foo', 'bar');
store.set('foo', 'bar');

5
node_modules/store/tests/bugs/gh-236.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/* eslint semi: "off", no-unused-vars: "off" */
var store = require('../..');
const token = store.get('token'); // or set ...

5
node_modules/store/tests/bugs/gh-239.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/* eslint semi: "off", no-unused-vars: "off" */
var store = require('../..');
const set = (key, value) => store.set(key, value);
const get = key => store.get(key);

157
node_modules/store/tests/tests.js generated vendored Normal file
View File

@@ -0,0 +1,157 @@
var tinytest = require('tinytest')
tinytest.hijackConsoleLog()
var { createStore } = require('../src/store-engine')
var { each } = require('../src/util')
var storages = require('../storages/all')
var allPluginTests = require('../plugins/all_tests')
module.exports = {
output:null,
outputError:null,
runTests: runTests,
failed:false
}
function runTests() {
setupEngineTests()
each(storages, function(storage) {
test.group(storage.name, function() {
if (!_checkEnabled(storage)) {
test.skip('disabled')
}
test('Storage tests', function() {
var store = createStore([storage])
runStorageTests(store)
})
each(allPluginTests, function(pluginTest, pluginName) {
var plugin = pluginTest.plugin
test.group('plugin: '+pluginName, function() {
var store = createStore([storage], [plugin])
pluginTest.setup(store)
})
})
})
})
require('./bugs/all')
tinytest.runTests({
failFast: false
})
}
function _checkEnabled(storage) {
if (!storage) {
print('Skip unsupported storage:', storage.name)
return false
}
var store = createStore([storage])
if (!store.enabled) {
print('Skip disabled storage:', storage.name)
return false
}
return true
}
function setupEngineTests(store) {
test('Addon super_fn args', function() {
function underlyingPlugin() {
return {
set: function(super_fn, key, val, customArg1, customArg2) {
assert(key == 'key'+'appended')
assert(val == 'val')
assert(customArg1 == 'overridden-customArg1')
assert(customArg2 == 'customArg2')
calls++
}
}
}
function overlyingPlugin() {
return {
set: function(super_fn, key, val) {
super_fn(key+'appended', val, 'overridden-customArg1')
calls++
}
}
}
var store = createStore(storages.memoryStorage, [underlyingPlugin, overlyingPlugin])
var calls = 0
store.set('key', 'val', 'customArg1', 'customArg2')
assert(calls == 2)
})
}
function runStorageTests(store) {
assert(store.enabled && store.enabled, "store should be enabled")
store.clearAll()
store.get('unsetValue') // see https://github.com/marcuswestin/store.js/issues/63
store.set('foo', 'bar')
assert(store.get('foo') == 'bar', "stored key 'foo' not equal to stored value 'bar'")
store.remove('foo')
assert(store.get('foo') === undefined, "removed key 'foo' not undefined")
assert(store.get('foo') === undefined, "key 'foo' exists when it shouldn't")
assert(store.set('foo','value') == 'value', "store#set returns the stored value")
assert(store.get('foo') !== undefined, "key 'foo' doesn't exist when it should")
store.set('foo', 'bar1')
store.set('foo', 'bar2')
assert(store.get('foo') == 'bar2', "key 'foo' is not equal to second value set 'bar2'")
store.set('foo', 'bar')
store.set('bar', 'foo')
store.remove('foo')
assert(store.get('foo') === undefined, "key 'foo' exists when it shouldn't")
assert(store.get('bar') == 'foo', "removing key 'foo' also removed key 'bar'")
store.set('foo', 'bar')
store.set('bar', 'foo')
store.clearAll()
assert(store.get('foo') === undefined && store.get('bar') === undefined, "keys foo and bar not cleared after store cleared")
assert(store.get('defaultVal', 123) == 123, "store.get should return default value")
store.set('foo', { name: 'marcus', arr: [1,2,3] })
assert(typeof store.get('foo') == 'object', "type of stored object 'foo' is not 'object'")
assert(store.get('foo') instanceof Object, "stored object 'foo' is not an instance of Object")
assert(store.get('foo').name == 'marcus', "property 'name' of stored object 'foo' is not 'marcus'")
assert(store.get('foo').arr instanceof Array, "Array property 'arr' of stored object 'foo' is not an instance of Array")
assert(store.get('foo').arr.length == 3, "The length of Array property 'arr' stored on object 'foo' is not 3")
store.remove('circularReference')
var circularOne = {}
var circularTwo = { one:circularOne }
circularOne.two = circularTwo
var threw = false
try { store.set('circularReference', circularOne) }
catch(e) { threw = true }
assert(threw, "storing object with circular reference did not throw")
assert(!store.get('circularReference'), "attempting to store object with circular reference which should have faile affected store state")
// If plain local storage was used before store.js, we should attempt to JSON.parse them into javascript values.
// Store values using vanilla localStorage, then read them out using store.js
var promoteValues = {
'int' : 42,
'bool' : true,
'float' : 3.141592653,
'string' : "Don't Panic",
'odd_string' : "{ZYX'} abc:;::)))"
}
for (var key in promoteValues) {
store.storage.write(key, promoteValues[key])
assert(store.get(key) == promoteValues[key], key+" was not correctly promoted to valid JSON")
store.remove(key)
}
store.clearAll()
var count = 0
store.each(function() {
count += 1
})
assert(count === 0)
}

24
node_modules/store/tests/util.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
module.exports = {
deepEqual: deepEqual
}
function deepEqual(a,b) {
if (typeof a != typeof b) {
return false
}
if (typeof a != 'object') {
return a === b
}
var key
for (key in a) {
if (!deepEqual(a[key], b[key])) {
return false
}
}
for (key in b) {
if (!deepEqual(b[key], a[key])) {
return false
}
}
return true
}