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Q,GAEjB,EAAK,KAAK,OAEX,CAEH,IAAK,KADL,EAAa,EAAQ,aAEjB,EAAK,KAAK,GAGd,IAAK,KADL,EAAa,EAAQ,gBAES,GAAtB,EAAK,QAAQ,IAAY,EAAK,KAAK,EAE/C,CAEA,OAAO,CACX,EA6BI,OAAQ,EACR,SAvBsB,SAAU,GAChC,IACI,EAEJ,QAH2C,IAAhB,EAKvB,IAAK,KADL,EAAa,EAAQ,GACG,EAAkB,EAAK,OAC5C,CAEH,IAAK,KADL,EAAa,EAAQ,eACG,EAAkB,EAAK,kBAE/C,IAAK,KADL,EAAa,EAAQ,aACG,EAAkB,EAAK,eACnD,CACA,OAAO,CACX,EAWJ,EACJ","file":"/npm/angular-webstorage@0.1.2/src/angular-webstorage.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/angular-webstorage@0.1.2/src/angular-webstorage.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*jslint node: true */\n/*global angular, document*/\n\n'use strict';\n\nvar angularWebStorage = angular.module('WebStorageModule', []);\n\nangularWebStorage.provider('webStorageService', function () {\n\n    this.$get = ['$window', '$document', function ($window, $document) {\n        var webStorage;\n\n        // If angular $document is not available\n        $document = !$document ? document : ($document[0] ? $document[0] : $document);\n\n\n        /*\n         * Check if browser support web storage\n         */\n        var isBrowserSupport = function () {\n            var supported = ($window.hasOwnProperty('localStorage') && $window.localStorage !== null);\n            return supported;\n        };\n\n\n        /*\n         * Add value to storage\n         * - key: key to retrieve data\n         * - value: value of data\n         * - keep: *optional* boolean to keep value indefinitly (localStorage) or temporarily (sessionStorage)\n         */\n        var addToStorage = function (key, value, keep) {\n\n            // Get storage type\n            keep = (typeof keep === 'undefined' || typeof keep !== 'boolean') ? false : keep;\n            var storageType = keep ? 'localStorage' : 'sessionStorage';\n\n            // Convert undefined values to null\n            if (angular.isUndefined(value)) {\n                value = null;\n            } else if (angular.isObject(value) || angular.isArray(value)) {\n                value = angular.toJson(value);\n            }\n\n            // Set web storage\n            webStorage = $window[storageType];\n\n            // Add data to storage\n            webStorage.setItem(key, value);\n\n            return true;\n        };\n\n\n        /*\n         * Return a value from storage\n         * - key\n         * - storageType: *optional* localStorage or sessionStorage\n         */\n        var getFromStorage = function (key, storageType) {\n\n            // Get storage type\n            var isStorageType = typeof storageType === 'undefined' ? false : true,\n                item;\n\n            // Set web storage\n            if (isStorageType) {\n                webStorage = $window[storageType];\n                item = webStorage ? webStorage.getItem(key) : null;\n            } else {\n                webStorage = $window.sessionStorage;\n                item = webStorage ? webStorage.getItem(key) : null;\n                if (!item || item === 'null') {\n                    webStorage = $window.localStorage;\n                    item = webStorage ? webStorage.getItem(key) : null;\n                }\n            }\n\n            if (!item || item === 'null') {\n                return null;\n            }\n\n            if (item.charAt(0) === \"{\" || item.charAt(0) === \"[\") {\n                return angular.fromJson(item);\n            }\n\n            return item;\n        };\n\n\n        /*\n         * Remove an item from local storage\n         * - key: key to retrieve data\n         * - storageType: *optional* localStorage or sessionStorage\n         */\n        var removeFromStorage = function (key, storageType) {\n\n            var isStorageType = typeof storageType === 'undefined' ? false : true;\n\n            if (isStorageType) {\n                webStorage = $window[storageType];\n                webStorage.removeItem(key);\n            } else {\n                webStorage = $window.sessionStorage;\n                webStorage.removeItem(key);\n                webStorage = $window.localStorage;\n                webStorage.removeItem(key);\n            }\n\n            return true;\n        };\n\n\n        /*\n         * Return array of keys from storage\n         * - storageType: *optional* localStorage or sessionStorage\n         */\n        var getKeysFromStorage = function (storageType) {\n\n            var isStorageType = typeof storageType === 'undefined' ? false : true;\n\n            var key,\n                keys = [];\n\n            if (isStorageType) {\n                webStorage = $window[storageType];\n                for (key in webStorage) {\n                    keys.push(key);\n                }\n            } else {\n                webStorage = $window.localStorage;\n                for (key in webStorage) {\n                    keys.push(key);\n                }\n                webStorage = $window.sessionStorage;\n                for (key in webStorage) {\n                    if (keys.indexOf(key) == -1) keys.push(key);\n                }\n            }\n\n            return keys;\n        };\n\n\n        /*\n         * Remove all datas from storage\n         * - storageType: localStorage or sessionStorage\n         */\n        var clearAllFromStorage = function (storageType) {\n            var isStorageType = typeof storageType === 'undefined' ? false : true,\n                key;\n\n            if (isStorageType) {\n                webStorage = $window[storageType];\n                for (key in webStorage) removeFromStorage(key, storageType);\n            } else {\n                webStorage = $window.sessionStorage;\n                for (key in webStorage) removeFromStorage(key, 'sessionStorage');\n                webStorage = $window.localStorage;\n                for (key in webStorage) removeFromStorage(key, 'localStorage');\n            }\n            return true;\n        };\n\n\n        return {\n            isSupported: isBrowserSupport,\n            set: addToStorage,\n            get: getFromStorage,\n            keys: getKeysFromStorage,\n            remove: removeFromStorage,\n            clearAll: clearAllFromStorage\n        };\n    }];\n});\n"]}