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

Commit

Permalink
optimising new instances
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Apr 10, 2015
1 parent 9e11880 commit 31e6240
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ http://www.jsdelivr.com/#!angular.locker

Simply download the zip file [HERE](https://github.com/tymondesigns/angular-locker/archive/master.zip) and include `dist/angular-locker.min.js` in your project.

1.63 kB Minified & gzipped.
1.65 kB Minified & gzipped.

<h2 id="usage">Usage</h2>

Expand Down
12 changes: 11 additions & 1 deletion dist/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* If value is a function then execute, otherwise return
*
* @param {Mixed} value
* @param {Mixed} parameter
* @param {Mixed} param
* @return {Mixed}
*/
var _value = function (value, param) {
Expand Down Expand Up @@ -138,11 +138,15 @@
this._namespace = options.namespace;

/**
* Separates the namespace from the keys
*
* @type {String}
*/
this._separator = options.separator;

/**
* Store the watchers here so we can un-register them later
*
* @type {Object}
*/
this._watchers = {};
Expand Down Expand Up @@ -507,6 +511,9 @@
* @return {self}
*/
driver: function (driver) {
// no need to create a new instance if the driver is the same
if (this._resolveDriver(driver) === this._driver) return this;

return this.instance(angular.extend(this._options, { driver: driver }));
},

Expand All @@ -526,6 +533,9 @@
* @return {self}
*/
namespace: function (namespace) {
// no need to create a new instance if the namespace is the same
if (namespace === this._namespace) return this;

return this.instance(angular.extend(this._options, { namespace: namespace }));
},

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.

12 changes: 11 additions & 1 deletion src/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* If value is a function then execute, otherwise return
*
* @param {Mixed} value
* @param {Mixed} parameter
* @param {Mixed} param
* @return {Mixed}
*/
var _value = function (value, param) {
Expand Down Expand Up @@ -138,11 +138,15 @@
this._namespace = options.namespace;

/**
* Separates the namespace from the keys
*
* @type {String}
*/
this._separator = options.separator;

/**
* Store the watchers here so we can un-register them later
*
* @type {Object}
*/
this._watchers = {};
Expand Down Expand Up @@ -507,6 +511,9 @@
* @return {self}
*/
driver: function (driver) {
// no need to create a new instance if the driver is the same
if (this._resolveDriver(driver) === this._driver) return this;

return this.instance(angular.extend(this._options, { driver: driver }));
},

Expand All @@ -526,6 +533,9 @@
* @return {self}
*/
namespace: function (namespace) {
// no need to create a new instance if the namespace is the same
if (namespace === this._namespace) return this;

return this.instance(angular.extend(this._options, { namespace: namespace }));
},

Expand Down

0 comments on commit 31e6240

Please sign in to comment.