Skip to content

Commit df3f9bd

Browse files
author
Mathieu Ghaleb
committed
- tag version 0.3.2
1 parent 37c23c9 commit df3f9bd

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "basil.js",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"homepage": "https://github.com/Wisembly/basil.js",
55
"authors": [
66
"Mathieu Ghaleb <mathieu@wisembly.com>"

build/basil.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
(function () {
22

3-
// Utils
4-
Object.extend = function () {
5-
var destination = typeof arguments[0] === 'object' ? arguments[0] : {};
6-
for (var i = 1; i < arguments.length; i++) {
7-
if (arguments[i] && typeof arguments[i] === 'object')
8-
for (var property in arguments[i])
9-
destination[property] = arguments[i][property];
10-
}
11-
return destination;
12-
};
13-
143
// Basil
154
var Basil = function (options) {
165
return new Basil.Storage().init(options);
176
};
187

19-
Basil.version = '0.3.1';
8+
// Version
9+
Basil.version = '0.3.2';
10+
11+
// Utils
12+
Basil.utils = {
13+
extend: function () {
14+
var destination = typeof arguments[0] === 'object' ? arguments[0] : {};
15+
for (var i = 1; i < arguments.length; i++) {
16+
if (arguments[i] && typeof arguments[i] === 'object')
17+
for (var property in arguments[i])
18+
destination[property] = arguments[i][property];
19+
}
20+
return destination;
21+
}
22+
};
2023

21-
Basil.options = Object.extend({
24+
// Options
25+
Basil.options = Basil.utils.extend({
2226
namespace: 'b45i1',
2327
storage: null,
2428
storages: ['local', 'cookie', 'session', 'memory'],
2529
expireDays: 365
2630
}, window.Basil ? window.Basil.options : {});
2731

32+
// Storage
2833
Basil.Storage = function () {
2934
var _salt = 'b45i1' + (Math.random() + 1)
3035
.toString(36)
@@ -77,17 +82,19 @@
7782
remove: function (name) {
7883
this.engine.removeItem(name);
7984
},
80-
reset: function () {
85+
reset: function (namespace) {
8186
for (var key, i = 0; i < this.engine.length; i++) {
8287
key = this.engine.key(i);
83-
if (key.indexOf(this.options.namespace) === 0)
88+
if (key.indexOf(namespace) === 0) {
8489
this.remove(key);
90+
i--;
91+
}
8592
}
8693
}
8794
};
8895

8996
// session storage
90-
_storages['session'] = Object.extend({}, _storages['local'], {
97+
_storages['session'] = Basil.utils.extend({}, _storages['local'], {
9198
engine: window.sessionStorage
9299
});
93100

@@ -108,9 +115,9 @@
108115
remove: function (name) {
109116
delete this._hash[name];
110117
},
111-
reset: function () {
118+
reset: function (namespace) {
112119
for (var key in this._hash) {
113-
if (key.indexOf(this.options.namespace) === 0)
120+
if (key.indexOf(namespace) === 0)
114121
this.remove(key);
115122
}
116123
}
@@ -157,21 +164,21 @@
157164
this.set(name, '', { expireDays: -1, domain: '.' + domainParts.slice(- i).join('.') });
158165
}
159166
},
160-
reset: function () {
167+
reset: function (namespace) {
161168
var cookies = document.cookie.split(';');
162169

163170
for (var i = 0; i < cookies.length; i++) {
164171
var cookie = cookies[i].replace(/^\s*/, ''),
165172
key = cookie.substr(0, cookie.indexOf('='));
166-
if (key.indexOf(this.options.namespace) === 0)
173+
if (key.indexOf(namespace) === 0)
167174
this.remove(key);
168175
}
169176
}
170177
};
171178

172179
return {
173180
init: function (options) {
174-
this.options = Object.extend({}, Basil.options, options);
181+
this.options = Basil.utils.extend({}, Basil.options, options);
175182

176183
this.supportedStorages = {};
177184
for (var i = 0, storage; i < this.options.storages.length; i++) {
@@ -200,7 +207,7 @@
200207
if (!(name = _toStoredKey(this.options.namespace, name)))
201208
return;
202209
value = _toStoredValue(value);
203-
options = Object.extend({
210+
options = Basil.utils.extend({
204211
expireDays: this.options.expireDays
205212
}, options);
206213

@@ -245,7 +252,7 @@
245252
for (var i = 0; i < storages.length; i++) {
246253
if (!this.check(storages[i]))
247254
continue;
248-
_storages[storages[i]].reset();
255+
_storages[storages[i]].reset(this.options.namespace);
249256
}
250257
},
251258
// Access to native storages, without namespace or basil value decoration

build/basil.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "basil.js",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"scripts": {
55
"test": "./node_modules/karma/bin/karma start test/karma.config.js",
66
"build": "./node_modules/gulp/bin/gulp.js"

src/basil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
};
77

88
// Version
9-
Basil.version = '0.3.1';
9+
Basil.version = '0.3.2';
1010

1111
// Utils
1212
Basil.utils = {

0 commit comments

Comments
 (0)