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

Commit

Permalink
2.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Jun 10, 2015
1 parent e502aa2 commit bf8b9e4
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 15 deletions.
44 changes: 39 additions & 5 deletions .gitdown/_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ Configure via `lockerProvider` (*optional*)

```js
.config(['lockerProvider', function config(lockerProvider) {
lockerProvider.setDefaultDriver('session')
.setDefaultNamespace('myAppName')
.setSeparator('.')
.setEventsEnabled(false);
lockerProvider.defaults({
driver: 'session',
namespace: 'myApp',
separator: '.',
eventsEnabled: true,
extend: {}
});
}]);
```

*Note*: You can also pass `false` into `setDefaultNamespace()` if you prefer to not have a namespace in your keys.
*Note*: You can also pass `false` to `namespace` if you prefer to not have a namespace in your keys.

inject `locker` into your controller/service/directive etc

Expand All @@ -29,6 +32,28 @@ inject `locker` into your controller/service/directive etc
}]);
```

#### Extending Locker

You can pass in an implementation of the [Storage Interface](https://developer.mozilla.org/en-US/docs/Web/API/Storage) to the `lockerProvider` as described above. e.g.

```js
lockerProvider.defaults({
extend: {
myCustomStore: function () {
// getItem
// setItem
// removeItem
// etc
}
}
});

// then use as normal
locker.driver('myCustomStore').put('foo', 'bar');
```

See my [storageMock](https://github.com/tymondesigns/angular-locker/blob/master/test/mock/storageMock.js) for an example on how to define a custom implementation.

----------------------------

### Switching storage drivers
Expand Down Expand Up @@ -96,6 +121,15 @@ locker.put('someKey', function(current) {
locker.get('someKey') // = ['foo', 'bar', 'baz']
```

If the current value is not already set then you can pass a third parameter as a default that will be returned instead. e.g.

```js
// given locker.get('foo') is not defined
locker.put('foo', function (current) {
// current will equal 'bar'
}, 'bar');
```

#### adding multiple items at once by passing a single object

This will add each key/value pair as a **separate** item in storage
Expand Down
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ Configure via `lockerProvider` (*optional*)

```js
.config(['lockerProvider', function config(lockerProvider) {
lockerProvider.setDefaultDriver('session')
.setDefaultNamespace('myAppName')
.setSeparator('.')
.setEventsEnabled(false);
lockerProvider.defaults({
driver: 'session',
namespace: 'myApp',
separator: '.',
eventsEnabled: true,
extend: {}
});
}]);
```

*Note*: You can also pass `false` into `setDefaultNamespace()` if you prefer to not have a namespace in your keys.
*Note*: You can also pass `false` to `namespace` if you prefer to not have a namespace in your keys.

inject `locker` into your controller/service/directive etc

Expand All @@ -82,6 +85,28 @@ inject `locker` into your controller/service/directive etc
}]);
```

<h4 id="usage-adding-to-your-project-extending-locker">Extending Locker</h4>

You can pass in an implementation of the [Storage Interface](https://developer.mozilla.org/en-US/docs/Web/API/Storage) to the `lockerProvider` as described above. e.g.

```js
lockerProvider.defaults({
extend: {
myCustomStore: function () {
// getItem
// setItem
// removeItem
// etc
}
}
});

// then use as normal
locker.driver('myCustomStore').put('foo', 'bar');
```

See my [storageMock](https://github.com/tymondesigns/angular-locker/blob/master/test/mock/storageMock.js) for an example on how to define a custom implementation.

----------------------------

<h3 id="usage-switching-storage-drivers">Switching storage drivers</h3>
Expand Down Expand Up @@ -149,6 +174,15 @@ locker.put('someKey', function(current) {
locker.get('someKey') // = ['foo', 'bar', 'baz']
```

If the current value is not already set then you can pass a third parameter as a default that will be returned instead. e.g.

```js
// given locker.get('foo') is not defined
locker.put('foo', function (current) {
// current will equal 'bar'
}, 'bar');
```

<h4 id="usage-adding-items-to-locker-adding-multiple-items-at-once-by-passing-a-single-object">adding multiple items at once by passing a single object</h4>

This will add each key/value pair as a **separate** item in storage
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-locker",
"version": "1.2.1",
"version": "2.0.0",
"homepage": "https://github.com/tymondesigns/angular-locker",
"authors": [
"Sean Tymon <[email protected]>"
Expand Down
9 changes: 8 additions & 1 deletion changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ lockerProvider.defaults({

##### General

- Reduced size of minified file by removing *now* unnecessary functions.
- Added ability to extend locker at the config stage
- Added `keys()` method to return an array of keys that exist within the current driver/namespace
- Reduced size of minified file by removing *now* unnecessary functions
- Adding third default parameter to `put()` method
- Hugely refactored and simplified Gulp build process
- Added [jscs](http://jscs.info/) to enforce coding style
- Namespaces can now contain the separator without any issues
- Lots of micro optimisations
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-locker",
"version": "1.2.1",
"version": "2.0.0",
"description": "A simple & configurable abstraction for local/session storage in angular projects",
"author": "@tymondesigns",
"license": "MIT",
Expand Down

0 comments on commit bf8b9e4

Please sign in to comment.