-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Scott Trinh
authored and
Scott Trinh
committed
Apr 28, 2017
1 parent
126a72f
commit 2cf14cd
Showing
5 changed files
with
36 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "angular-localforage", | ||
"main": "dist/angular-localForage.js", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"homepage": "https://github.com/ocombe/angular-localForage", | ||
"authors": [ | ||
"Olivier Combe <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* angular-localforage - Angular service & directive for https://github.com/mozilla/localForage (Offline storage, improved.) | ||
* @version v1.3.5 | ||
* @version v1.3.6 | ||
* @link https://github.com/ocombe/angular-localForage | ||
* @license MIT | ||
* @author Olivier Combe <[email protected]> | ||
|
@@ -126,13 +126,7 @@ | |
} else { | ||
var deferred = $q.defer(), | ||
args = arguments, | ||
localCopy = value; | ||
|
||
//avoid $promises attributes from value objects, if present. | ||
if(angular.isObject(localCopy) && angular.isDefined(localCopy.$promise)) { | ||
localCopy = angular.extend({}, value); | ||
delete localCopy.$promise; | ||
} | ||
localCopy = stripMeta(value); | ||
|
||
self._localforage.setItem(self.prefix() + key, localCopy) | ||
.then(function success() { | ||
|
@@ -151,6 +145,26 @@ | |
|
||
return deferred.promise; | ||
} | ||
|
||
function stripMeta(value) { | ||
var copy; | ||
if (angular.isArray(value)) { | ||
return value.map(stripMeta); | ||
} else if (angular.isObject(value) && !(value instanceof Blob)) { | ||
copy = angular.extend({}, value); | ||
|
||
angular.isDefined(copy.$promise) && delete copy.$promise; | ||
angular.isDefined(copy.$$hashKey) && delete copy.$$hashKey; | ||
|
||
return Object | ||
.keys(copy) | ||
.reduce(function stripEntries(acc, key) { | ||
acc[key] = stripMeta(copy[key]); | ||
return acc; | ||
}, {}); | ||
} | ||
return value; | ||
} | ||
}; | ||
|
||
// Directly get a value from storage | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters