Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Apr 28, 2015
1 parent d549d04 commit f8f5263
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
23 changes: 14 additions & 9 deletions dist/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
* @return {Boolean}
*/
this._checkSupport = function (driver) {
if (angular.isUndefined(this._supported)) {
if (! _defined(this._supported)) {
var l = 'l';
try {
this._resolveDriver(driver || 'local').setItem(l, l);
Expand Down Expand Up @@ -423,26 +423,31 @@
var items = {};
angular.forEach(this._driver, function (value, key) {
if (this._namespace) {
var prefixWithSeparator = this._namespace + this._separator;
if (key.indexOf(prefixWithSeparator) === 0) {
key = key.substring(prefixWithSeparator.length);
}
var prefix = this._namespace + this._separator;
if (key.indexOf(prefix) === 0) key = key.substring(prefix.length);
}
if (this.has(key)) items[key] = this.get(key);
}, this);

return items;
},

/**
* Get the storage keys as an array
*
* @return {Array}
*/
keys: function () {
return Object.keys(this.all());
},

/**
* Remove all items set within the current namespace/driver
*
* @return {self}
*/
clean: function () {
this.forget(Object.keys(this.all()));

return this;
return this.forget(this.keys());
},

/**
Expand All @@ -462,7 +467,7 @@
* @return {Integer}
*/
count: function () {
return Object.keys(this.all()).length;
return this.keys().length;
},

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-locker.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 dist/angular-locker.min.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var gulp = require('gulp'),
fizzy = require('fizzy'),
pkg = require('./package.json'),
config = require('./config'),
paths = config.paths;
fizzy = require('fizzy'),
pkg = require('./package.json'),
config = require('./config'),
paths = config.paths;

// Lint the JS
gulp.task('lint', fizzy.task('lint', { src: paths.scripts }));
Expand Down
23 changes: 14 additions & 9 deletions src/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
* @return {Boolean}
*/
this._checkSupport = function (driver) {
if (angular.isUndefined(this._supported)) {
if (! _defined(this._supported)) {
var l = 'l';
try {
this._resolveDriver(driver || 'local').setItem(l, l);
Expand Down Expand Up @@ -423,26 +423,31 @@
var items = {};
angular.forEach(this._driver, function (value, key) {
if (this._namespace) {
var prefixWithSeparator = this._namespace + this._separator;
if (key.indexOf(prefixWithSeparator) === 0) {
key = key.substring(prefixWithSeparator.length);
}
var prefix = this._namespace + this._separator;
if (key.indexOf(prefix) === 0) key = key.substring(prefix.length);
}
if (this.has(key)) items[key] = this.get(key);
}, this);

return items;
},

/**
* Get the storage keys as an array
*
* @return {Array}
*/
keys: function () {
return Object.keys(this.all());
},

/**
* Remove all items set within the current namespace/driver
*
* @return {self}
*/
clean: function () {
this.forget(Object.keys(this.all()));

return this;
return this.forget(this.keys());
},

/**
Expand All @@ -462,7 +467,7 @@
* @return {Integer}
*/
count: function () {
return Object.keys(this.all()).length;
return this.keys().length;
},

/**
Expand Down

0 comments on commit f8f5263

Please sign in to comment.