Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstjules committed Jul 26, 2016
1 parent 31baa28 commit d562ceb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .zuul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ browsers:
version: latest
platform: Linux
- name: safari
version: 5..7
version: 7
- name: ie
version: 8..latest
- name: android
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ storage.onConnect().then(function() {
});
```

**Breaking Changes**

API breaking changes were introduced in both 0.6 and 1.0. Refer to
[releases](https://github.com/zendesk/cross-storage/releases) for details.

**Notes on Safari 7+ (OSX, iOS)**

All cross-domain local storage access is disabled by default with Safari 7+.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cross-storage",
"version": "0.8.2",
"version": "1.0.0",
"description": "Cross domain local storage",
"license": "Apache-2.0",
"authors": [
Expand Down
15 changes: 6 additions & 9 deletions dist/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* cross-storage - Cross domain local storage
*
* @version 0.8.2
* @version 1.0.0
* @link https://github.com/zendesk/cross-storage
* @author Daniel St. Jules <danielst.jules@gmail.com>
* @copyright Zendesk
Expand Down Expand Up @@ -172,21 +172,18 @@
};

/**
* Sets a key to the specified value, optionally accepting a ttl to passively
* expire the key after a number of milliseconds. Returns a promise that is
* fulfilled on success, or rejected if any errors setting the key occurred,
* or the request timed out.
* Sets a key to the specified value. Returns a promise that is fulfilled on
* success, or rejected if any errors setting the key occurred, or the request
* timed out.
*
* @param {string} key The key to set
* @param {*} value The value to assign
* @param {int} ttl Time to live in milliseconds
* @returns {Promise} A promise that is settled on hub response or timeout
*/
CrossStorageClient.prototype.set = function(key, value, ttl) {
CrossStorageClient.prototype.set = function(key, value) {
return this._request('set', {
key: key,
value: value,
ttl: ttl
value: value
});
};

Expand Down
4 changes: 2 additions & 2 deletions dist/client.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 9 additions & 32 deletions dist/hub.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* cross-storage - Cross domain local storage
*
* @version 0.8.2
* @version 1.0.0
* @link https://github.com/zendesk/cross-storage
* @author Daniel St. Jules <danielst.jules@gmail.com>
* @copyright Zendesk
Expand Down Expand Up @@ -160,59 +160,36 @@
};

/**
* Sets a key to the specified value. If a ttl is provided, an expiration
* timestamp is added to the object to be stored, prior to serialization.
* Sets a key to the specified value.
*
* @param {object} params An object with key, value and optional ttl
* @param {object} params An object with key and value
*/
CrossStorageHub._set = function(params) {
var ttl, item;

ttl = params.ttl;
if (ttl && parseInt(ttl, 10) !== ttl) {
throw new Error('ttl must be a number');
}

item = {value: params.value};
if (ttl) {
item.expire = CrossStorageHub._now() + ttl;
}

window.localStorage.setItem(params.key, JSON.stringify(item));
window.localStorage.setItem(params.key, params.value);
};

/**
* Accepts an object with an array of keys for which to retrieve their values.
* Returns a single value if only one key was supplied, otherwise it returns
* an array. Any keys not set, or expired, result in a null element in the
* resulting array.
* an array. Any keys not set result in a null element in the resulting array.
*
* @param {object} params An object with an array of keys
* @returns {*|*[]} Either a single value, or an array
*/
CrossStorageHub._get = function(params) {
var storage, result, i, item, key;
var storage, result, i, value;

storage = window.localStorage;
result = [];

for (i = 0; i < params.keys.length; i++) {
key = params.keys[i];

try {
item = JSON.parse(storage.getItem(key));
value = storage.getItem(params.keys[i]);
} catch (e) {
item = null;
value = null;
}

if (item === null) {
result.push(null);
} else if (item.expire && item.expire < CrossStorageHub._now()) {
storage.removeItem(key);
result.push(null);
} else {
result.push(item.value);
}
result.push(value);
}

return (result.length > 1) ? result : result[0];
Expand Down
4 changes: 2 additions & 2 deletions dist/hub.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cross-storage",
"version": "0.8.2",
"version": "1.0.0",
"description": "Cross domain local storage",
"keywords": [
"local",
Expand Down

0 comments on commit d562ceb

Please sign in to comment.