Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-local-storage-ci-dev

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-local-storage-ci-dev - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

.editorconfig

82

dist/angular-local-storage.js

@@ -11,3 +11,3 @@ var isDefined = angular.isDefined,

var type = Object.prototype.toString.call(sth).toLowerCase();
return '[object string],[object undefined],[object null],[object number],[object boolean]'.split(',').some(function (typeStr) {
return '[object string],[object undefined],[object null],[object number],[object boolean]'.split(',').some(function(typeStr) {
return typeStr == type;

@@ -57,10 +57,6 @@ });

this.setOptions = function(options) {
};
// Setter for expiry
this.setExpiry = function(exp, prefix) {
this.setExpiry = function(exp, alwaysExpire) {
this.expiry.value = exp; // millisecond
prefix && (this.expiry.prefix = prefix);
this.expiry.alwaysExpire = !!alwaysExpire;
};

@@ -81,18 +77,7 @@

// Setter for cookie config
this.setStorageCookie = function(exp, path) {
if (exp) {
console.warn('Set expiry for cookie is deprecated, use setExpiry instead.');
// this.cookie.expiry = exp;
this.expiry.value = exp * ONE_DAY_MILLISECONDS; // trans days to millisecond
}
this.cookie.path = path;
this.setStorageCookie = function(cookieOptions) {
angular.extend(this.cookie, cookieOptions);
return this;
};
// Setter for cookie domain
this.setStorageCookieDomain = function(domain) {
this.cookie.domain = domain;
return this;
};
// Setter for notification config

@@ -132,3 +117,3 @@ // itemSet & itemRemove should be booleans

// Checks the browser to see if local storage is supported
var browserSupportsLocalStorage = (function () {
var browserSupportsLocalStorage = (function() {
try {

@@ -171,3 +156,3 @@ var supported = (storageType in $window && $window[storageType] !== null);

*/
var addToLocalStorage = function (key, value, expiry, expireTimeStamp) {
var addToLocalStorage = function(key, value, expiry, expireTimeStamp) {
var daysToExpire = 0;

@@ -210,3 +195,7 @@ var wrappedData = {};

if (notify.setItem) {
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'cookie'});
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {
key: key,
newvalue: value,
storageType: 'cookie'
});
}

@@ -221,3 +210,7 @@ return addToCookies(key, value, daysToExpire);

if (notify.setItem) {
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: self.storageType});
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {
key: key,
newvalue: value,
storageType: self.storageType
});
}

@@ -244,3 +237,3 @@ } catch (e) {

*/
var getFromLocalStorage = function (key, forceNeedExpire) {
var getFromLocalStorage = function(key, forceNeedExpire) {

@@ -318,5 +311,5 @@ if (!browserSupportsLocalStorage || self.storageType === 'cookie') {

// Example use: localStorageService.remove('library'); // removes the key/value pair of library='angular'
var removeFromLocalStorage = function () {
var removeFromLocalStorage = function() {
var i, key;
for (i=0; i<arguments.length; i++) {
for (i = 0; i < arguments.length; i++) {
key = arguments[i];

@@ -329,3 +322,6 @@ if (!browserSupportsLocalStorage || self.storageType === 'cookie') {

if (notify.removeItem) {
$rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: 'cookie'});
$rootScope.$broadcast('LocalStorageModule.notification.removeitem', {
key: key,
storageType: 'cookie'
});
}

@@ -353,3 +349,3 @@ removeFromCookies(key);

// Example use: var keys = localStorageService.keys()
var getKeysForLocalStorage = function () {
var getKeysForLocalStorage = function() {

@@ -381,3 +377,3 @@ if (!browserSupportsLocalStorage) {

// Should be used mostly for development purposes
var clearAllFromLocalStorage = function (regularExpression) {
var clearAllFromLocalStorage = function(regularExpression) {

@@ -427,7 +423,7 @@ // Setting both regular expressions independently

// Example use: localStorageService.cookie.add('library','angular');
var addToCookies = function (key, value, daysToExpiry) {
var addToCookies = function(key, value, daysToExpiry) {
if (isUndefined(value)) {
return false;
} else if(isArray(value) || isObject(value)) {
} else if (isArray(value) || isObject(value)) {
value = toJson(value);

@@ -460,3 +456,3 @@ }

var cookiePath = "; path=" + cookie.path;
if(cookie.domain){
if (cookie.domain) {
cookieDomain = "; domain=" + cookie.domain;

@@ -475,3 +471,3 @@ }

// Example use: localStorageService.cookie.get('library'); // returns 'angular'
var getFromCookies = function (key) {
var getFromCookies = function(key) {
if (!browserSupportsCookies) {

@@ -483,6 +479,6 @@ $rootScope.$broadcast('LocalStorageModule.notification.error', 'COOKIES_NOT_SUPPORTED');

var cookies = $document.cookie && $document.cookie.split(';') || [];
for(var i=0; i < cookies.length; i++) {
for (var i = 0; i < cookies.length; i++) {
var thisCookie = cookies[i];
while (thisCookie.charAt(0) === ' ') {
thisCookie = thisCookie.substring(1,thisCookie.length);
thisCookie = thisCookie.substring(1, thisCookie.length);
}

@@ -493,3 +489,3 @@ if (thisCookie.indexOf(deriveQualifiedKey(key) + '=') === 0) {

return JSON.parse(storedValues);
} catch(e) {
} catch (e) {
return storedValues;

@@ -502,11 +498,11 @@ }

var removeFromCookies = function (key) {
addToCookies(key,null);
var removeFromCookies = function(key) {
addToCookies(key, null);
};
var clearAllFromCookies = function () {
var clearAllFromCookies = function() {
var thisCookie = null, thisKey = null;
var prefixLength = prefix.length;
var cookies = $document.cookie.split(';');
for(var i = 0; i < cookies.length; i++) {
for (var i = 0; i < cookies.length; i++) {
thisCookie = cookies[i];

@@ -551,4 +547,4 @@

var storage = $window[storageType];
for(var i = 0; i < storage.length; i++) {
if(storage.key(i).indexOf(prefix) === 0 ) {
for (var i = 0; i < storage.length; i++) {
if (storage.key(i).indexOf(prefix) === 0) {
count++;

@@ -555,0 +551,0 @@ }

{
"name": "angular-local-storage-ci-dev",
"version": "0.3.1",
"version": "0.3.2",
"description": "An Angular module that gives you access to the browsers local storage",
"main": "./dist/angular-local-storage.js",
"homepage": "https://github.com/TencentWSRD/angular-local-storage",
"main": "index.js",
"scripts": {
"test": "grunt test"
},
"repository": {
"type": "git",
"url": "https://github.com/TencentWSRD/angular-local-storage.git"
},
"keywords": [

@@ -11,27 +19,26 @@ "AngularJS",

],
"author": {
"name": "grevory",
"email": "greg@gregpike.ca"
},
"author": "grevory <greg@gregpike.ca>",
"contributors": [
{
"name": "Ariel Mashraki",
"email": "ariel@mashraki.co.il"
}
"Ariel Mashraki <ariel@mashraki.co.il>",
"Xiao Yuze <xiaoyuze88@gmail.com>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/TencentWSRD/angular-local-storage/issues"
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-cli": "~0.1.9",
"grunt-contrib-concat": "*",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-jshint": "~0.12.0",
"grunt-contrib-uglify": "*",
"grunt-karma": "latest",
"karma": "~0.12.16",
"karma-jasmine": "~0.1.5",
"karma-coverage": "^0.2.6",
"karma-phantomjs-launcher": "~0.1.4",
"load-grunt-tasks": "~0.3.0",
"time-grunt": "~0.2.9"
"jasmine-core": "^2.4.1",
"karma": "~0.13.19",
"karma-coverage": "^0.5.3",
"karma-jasmine": "~0.3.7",
"karma-phantomjs-launcher": "~1.0.0",
"load-grunt-tasks": "~3.4.0",
"phantomjs-prebuilt": "^2.1.4",
"time-grunt": "~1.3.0"
}
}

@@ -1,78 +0,18 @@

angular-local-storage
angular-local-storage-ci-dev
=====================
An Angular module that gives you access to the browsers local storage, **v0.2.1**
An Angular module that gives you access to the browsers local storage
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
A forked version for our project CI, add new features such as expiry support for localStorage and so on to meet our demand.
##Table of contents:
- [![Gitter][gitter-image]][gitter-url]
- [Get Started](#get-started)
- [Video Tutorial](https://www.youtube.com/watch?v=I4iB0kOSmx8)
- [Development](#development)
- [Configuration](#configuration)
- [setPrefix](#setprefix)
- [setStorageType](#setstoragetype)
- [setStorageCookie](#setstoragecookie)
- [setStorageCookieDomain](#setstoragecookiedomain)
- [setNotify](#setnotify)
- [Example](#configuration-example)
- [API Documentation](#api-documentation)
- [isSupported](#issupported)
- [getStorageType](#getstoragetype)
- [set](#set)
- [get](#get)
- [keys](#keys)
- [remove](#remove)
- [clearAll](#clearall)
- [bind](#bind)
- [deriveKey](#derivekey)
- [length](#length)
- [cookie](#cookie)
- [isSupported](#cookieissupported)
- [set](#cookieset)
- [get](#cookieget)
- [remove](#cookieremove)
- [clearAll](#cookieclearall)
##Get Started
**(1)** You can install angular-local-storage using 2 different ways:<br/>
**Git:**
clone & build [this](https://github.com/grevory/angular-local-storage.git) repository<br/>
**Bower:**
## Install
```bash
$ bower install angular-local-storage --save
$ npm install angular-local-storage-ci-dev
```
**npm:**
```bash
$ npm install angular-local-storage
```
**(2)** Include `angular-local-storage.js` (or `angular-local-storage.min.js`) from the [dist](https://github.com/grevory/angular-local-storage/tree/master/dist) directory in your `index.html`, after including Angular itself.
**(3)** Add `'LocalStorageModule'` to your main module's list of dependencies.
```javascript
var angularLocalStorage = require('angular-local-storage-ci-dev');
When you're done, your setup should look similar to the following:
```html
<!doctype html>
<html ng-app="myApp">
<head>
</head>
<body>
...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src="bower_components/js/angular-local-storage.min.js"></script>
...
<script>
var myApp = angular.module('myApp', ['LocalStorageModule']);
</script>
...
</body>
</html>
angular.module('app', [
angularLocalStorage
]);
```

@@ -100,4 +40,4 @@ ##Configuration

Set cookie options (usually in case of fallback)<br/>
**expiry:** number of days before cookies expire (0 = does not expire). **default:** `30`<br/>
**path:** the web path the cookie represents. **default:** `'/'`
**cookieOptions:** options
**cookieOptions.path** the web path the cookie represents. **default:** `'/'`
```js

@@ -109,18 +49,8 @@ myApp.config(function (localStorageServiceProvider) {

```
###setStorageCookieDomain
Set the cookie domain, since this runs inside a the `config()` block, only providers and constants can be injected. As a result, `$location` service can't be used here, use a hardcoded string or `window.location`.<br/>
**No default value**
```js
myApp.config(function (localStorageServiceProvider) {
localStorageServiceProvider
.setStorageCookieDomain('<domain>');
});
```
For local testing (when you are testing on localhost) set the domain to an empty string ''. Setting the domain to 'localhost' will not work on all browsers (eg. Chrome) since some browsers only allow you to set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs **or intranet hostnames** like localhost. </br>
###setNotify
###setNotify
Send signals for each of the following actions:<br/>
**setItem** , default: `true`<br/>
**removeItem** , default: `false`
Configure whether events should be broadcasted on $rootScope for each of the following actions:<br/>
**setItem** , default: `true`, event "LocalStorageModule.notification.setitem"<br/>
**removeItem** , default: `false`, event "LocalStorageModule.notification.removeitem"
```js

@@ -137,3 +67,3 @@ myApp.config(function (localStorageServiceProvider) {

localStorageServiceProvider
.setPrefix('myApp')
.setPrefix('newci')
.setStorageType('sessionStorage')

@@ -173,3 +103,5 @@ .setNotify(true, true)

function submit(key, val) {
return localStorageService.set(key, val);
// expiry: milliseconds, this value will be expired in `expiry` milliseconds, if not set, and `localStorageService.expiry.alwaysExpire` is true, it will expire in the default expiry time.
// expireTimeStamp: TimeStamp, this value will be expired after this absolute time.
return localStorageService.set(key, val, expiry, expireTimeStamp);
}

@@ -187,3 +119,4 @@ //...

function getItem(key) {
return localStorageService.get(key);
// expiry: Number, if this value hasn't been wrapped by us, we will wrap them by using this expiry time.
return localStorageService.get(key, expiry);
}

@@ -246,3 +179,3 @@ //...

$scope.unbind = localStorageService.bind($scope, 'property');
//Test Changes

@@ -356,40 +289,1 @@ $scope.update = function(val) {

```
Check out the full demo at http://gregpike.net/demos/angular-local-storage/demo.html
##Development:
* Don't forget about tests.
* If you planning add some feature please create issue before.
Clone the project:
```sh
$ git clone https://github.com/<your-repo>/angular-local-storage.git
$ npm install
$ bower install
```
Run the tests:
```sh
$ grunt test
```
**Deploy:**<br/>
Run the build task, update version before(bower,package)
```sh
$ grunt dist
$ git tag 0.*.*
$ git push origin master --tags
```
[npm-image]: https://img.shields.io/npm/v/angular-local-storage.svg?style=flat-square
[npm-url]: https://npmjs.org/package/angular-local-storage
[travis-image]: https://img.shields.io/travis/grevory/angular-local-storage.svg?style=flat-square
[travis-url]: https://travis-ci.org/grevory/angular-local-storage
[coveralls-image]: https://img.shields.io/coveralls/grevory/angular-local-storage.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/grevory/angular-local-storage
[david-image]: http://img.shields.io/david/grevory/angular-local-storage.svg?style=flat-square
[david-url]: https://david-dm.org/grevory/angular-local-storage
[license-image]: http://img.shields.io/npm/l/angular-local-storage.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/angular-local-storage.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/angular-local-storage
[gitter-image]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/grevory/angular-local-storage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc