Socket
Socket
Sign inDemoInstall

lifecycle

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

319

lifecycle.js

@@ -1,37 +0,50 @@

// Generated by CoffeeScript 1.3.3
/*
Lifecycle.js 1.0.2
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/json-serialize/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Note: some 'extend'-related code from Backbone.js is repeated in this file.
Please see the following for details on Backbone.js and its licensing:
https:github.com/documentcloud/backbone/blob/master/LICENSE
*/
(function() {
return (function(factory) {
// AMD
if (typeof define === 'function' && define.amd) {
return define('lifecycle', factory);
}
// CommonJS/NodeJS or No Loader
else {
return factory.call(this);
}
})(function() {// Generated by CoffeeScript 1.3.3
/*
Lifecycle.js 1.0.1
(c) 2011, 2012 Kevin Malakoff.
Lifecycle is freely distributable under the MIT license.
https:#github.com/kmalakoff/Lifecycle
Lifecycle.js 1.0.2
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/json-serialize/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Note: some code from Backbone.js is repeated in this file.
Note: some 'extend'-related code from Backbone.js is repeated in this file.
Please see the following for details on Backbone.js and its licensing:
https:github.com/documentcloud/backbone
https:github.com/documentcloud/backbone/blob/master/LICENSE
*/
var LC, copyProps, isArray;
(function() {
var LC, copyProps, isArray;
LC = this.LC = typeof exports !== 'undefined' ? exports : {};
LC = this.LC = typeof exports !== 'undefined' ? exports : {};
LC.VERSION = "1.0.2";
LC.VERSION = "1.0.1";
isArray = function(obj) {
return obj.constructor === Array;
};
isArray = function(obj) {
return obj.constructor === Array;
};
copyProps = function(dest, source) {
var key, value;
for (key in source) {
value = source[key];
dest[key] = value;
}
return dest;
};
copyProps = function(dest, source) {
var key, value;
for (key in source) {
value = source[key];
dest[key] = value;
}
return dest;
};
// Shared empty constructor function to aid in prototype-chain creation.

@@ -88,150 +101,150 @@ var ctor = function(){};

LC.own = function(obj, options) {
var clone, key, value, _i, _j, _len, _len1;
if (!obj || (typeof obj !== "object")) {
LC.own = function(obj, options) {
var clone, key, value, _i, _j, _len, _len1;
if (!obj || (typeof obj !== "object")) {
return obj;
}
options || (options = {});
if (isArray(obj)) {
if (options.share_collection) {
for (_i = 0, _len = obj.length; _i < _len; _i++) {
value = obj[_i];
LC.own(value, {
prefer_clone: options.prefer_clone
});
}
return obj;
} else {
clone = [];
for (_j = 0, _len1 = obj.length; _j < _len1; _j++) {
value = obj[_j];
clone.push(LC.own(value, {
prefer_clone: options.prefer_clone
}));
}
return clone;
}
options || (options = {});
if (isArray(obj)) {
if (options.share_collection) {
for (_i = 0, _len = obj.length; _i < _len; _i++) {
value = obj[_i];
LC.own(value, {
prefer_clone: options.prefer_clone
});
}
return obj;
} else {
clone = [];
for (_j = 0, _len1 = obj.length; _j < _len1; _j++) {
value = obj[_j];
clone.push(LC.own(value, {
prefer_clone: options.prefer_clone
}));
}
return clone;
} else if (options.properties) {
if (options.share_collection) {
for (key in obj) {
value = obj[key];
LC.own(value, {
prefer_clone: options.prefer_clone
});
}
} else if (options.properties) {
if (options.share_collection) {
for (key in obj) {
value = obj[key];
LC.own(value, {
prefer_clone: options.prefer_clone
});
}
return obj;
} else {
clone = {};
for (key in obj) {
value = obj[key];
clone[key] = LC.own(value, {
prefer_clone: options.prefer_clone
});
}
return clone;
return obj;
} else {
clone = {};
for (key in obj) {
value = obj[key];
clone[key] = LC.own(value, {
prefer_clone: options.prefer_clone
});
}
} else if (obj.retain) {
if (options.prefer_clone && obj.clone) {
return obj.clone();
} else {
return obj.retain();
}
} else if (obj.clone) {
return clone;
}
} else if (obj.retain) {
if (options.prefer_clone && obj.clone) {
return obj.clone();
} else {
return obj.retain();
}
} else if (obj.clone) {
return obj.clone();
}
return obj;
};
LC.disown = function(obj, options) {
var index, key, value, _i, _len;
if (options == null) {
options = {};
}
if (!obj || (typeof obj !== "object")) {
return obj;
};
LC.disown = function(obj, options) {
var index, key, value, _i, _len;
if (options == null) {
options = {};
}
if (isArray(obj)) {
if (options.clear_values) {
for (index in obj) {
value = obj[index];
LC.disown(value, {
clear_values: options.clear_values
});
obj[index] = null;
}
} else {
for (_i = 0, _len = obj.length; _i < _len; _i++) {
value = obj[_i];
LC.disown(value, {
remove_values: options.remove_values
});
}
if (options.remove_values) {
obj.length = 0;
}
}
if (!obj || (typeof obj !== "object")) {
return obj;
}
if (isArray(obj)) {
if (options.clear_values) {
for (index in obj) {
value = obj[index];
LC.disown(value, {
clear_values: options.clear_values
});
obj[index] = null;
}
} else {
for (_i = 0, _len = obj.length; _i < _len; _i++) {
value = obj[_i];
LC.disown(value, {
remove_values: options.remove_values
});
}
if (options.remove_values) {
obj.length = 0;
}
} else if (options.properties) {
if (options.clear_values) {
for (key in obj) {
value = obj[key];
LC.disown(value, {
clear_values: options.clear_values
});
obj[key] = null;
}
} else if (options.properties) {
if (options.clear_values) {
for (key in obj) {
value = obj[key];
LC.disown(value, {
clear_values: options.clear_values
});
obj[key] = null;
}
} else {
for (key in obj) {
value = obj[key];
LC.disown(value, {
remove_values: options.remove_values
});
delete obj[key];
}
} else {
for (key in obj) {
value = obj[key];
LC.disown(value, {
remove_values: options.remove_values
});
delete obj[key];
}
} else if (obj.release) {
obj.release();
} else if (obj.destroy) {
obj.destroy();
}
return obj;
};
} else if (obj.release) {
obj.release();
} else if (obj.destroy) {
obj.destroy();
}
return obj;
};
LC.RefCountable = (function() {
LC.RefCountable = (function() {
RefCountable.extend = extend;
RefCountable.extend = extend;
function RefCountable() {
this.__LC || (this.__LC = {});
this.__LC.ref_count = 1;
}
function RefCountable() {
this.__LC || (this.__LC = {});
this.__LC.ref_count = 1;
}
RefCountable.prototype.__destroy = function() {};
RefCountable.prototype.__destroy = function() {};
RefCountable.prototype.retain = function() {
if (this.__LC.ref_count <= 0) {
throw "RefCountable: ref_count is corrupt: " + this.__LC.ref_count;
}
this.__LC.ref_count++;
return this;
};
RefCountable.prototype.retain = function() {
if (this.__LC.ref_count <= 0) {
throw "RefCountable: ref_count is corrupt: " + this.__LC.ref_count;
}
this.__LC.ref_count++;
return this;
};
RefCountable.prototype.release = function() {
if (this.__LC.ref_count <= 0) {
throw "RefCountable: ref_count is corrupt: " + this.__LC.ref_count;
}
this.__LC.ref_count--;
if (!this.__LC.ref_count) {
this.__destroy();
}
return this;
};
RefCountable.prototype.release = function() {
if (this.__LC.ref_count <= 0) {
throw "RefCountable: ref_count is corrupt: " + this.__LC.ref_count;
}
this.__LC.ref_count--;
if (!this.__LC.ref_count) {
this.__destroy();
}
return this;
};
RefCountable.prototype.refCount = function() {
return this.__LC.ref_count;
};
RefCountable.prototype.refCount = function() {
return this.__LC.ref_count;
};
return RefCountable;
return RefCountable;
})();
}).call(this);
})();
; return LC;});
}).call(this);

@@ -1,12 +0,9 @@

// Generated by CoffeeScript 1.3.3
/*
Lifecycle.js 1.0.1
(c) 2011, 2012 Kevin Malakoff.
Lifecycle is freely distributable under the MIT license.
https:#github.com/kmalakoff/Lifecycle
Lifecycle.js 1.0.2
(c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/json-serialize/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Note: some code from Backbone.js is repeated in this file.
Note: some 'extend'-related code from Backbone.js is repeated in this file.
Please see the following for details on Backbone.js and its licensing:
https:github.com/documentcloud/backbone
https:github.com/documentcloud/backbone/blob/master/LICENSE
*/(function(){var e,t,n;e=this.LC=typeof exports!="undefined"?exports:{},e.VERSION="1.0.1",n=function(e){return e.constructor===Array},t=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e};var r=function(){},i=function(e,n,i){var s;return n&&n.hasOwnProperty("constructor")?s=n.constructor:s=function(){e.apply(this,arguments)},t(s,e),r.prototype=e.prototype,s.prototype=new r,n&&t(s.prototype,n),i&&t(s,i),s.prototype.constructor=s,s.__super__=e.prototype,s},s=function(e,t){var n=i(this,e,t);return n.extend=this.extend,n};e.own=function(t,r){var i,s,o,u,a,f,l;if(!t||typeof t!="object")return t;r||(r={});if(n(t)){if(r.share_collection){for(u=0,f=t.length;u<f;u++)o=t[u],e.own(o,{prefer_clone:r.prefer_clone});return t}i=[];for(a=0,l=t.length;a<l;a++)o=t[a],i.push(e.own(o,{prefer_clone:r.prefer_clone}));return i}if(r.properties){if(r.share_collection){for(s in t)o=t[s],e.own(o,{prefer_clone:r.prefer_clone});return t}i={};for(s in t)o=t[s],i[s]=e.own(o,{prefer_clone:r.prefer_clone});return i}return t.retain?r.prefer_clone&&t.clone?t.clone():t.retain():t.clone?t.clone():t},e.disown=function(t,r){var i,s,o,u,a;r==null&&(r={});if(!t||typeof t!="object")return t;if(n(t))if(r.clear_values)for(i in t)o=t[i],e.disown(o,{clear_values:r.clear_values}),t[i]=null;else{for(u=0,a=t.length;u<a;u++)o=t[u],e.disown(o,{remove_values:r.remove_values});r.remove_values&&(t.length=0)}else if(r.properties)if(r.clear_values)for(s in t)o=t[s],e.disown(o,{clear_values:r.clear_values}),t[s]=null;else for(s in t)o=t[s],e.disown(o,{remove_values:r.remove_values}),delete t[s];else t.release?t.release():t.destroy&&t.destroy();return t},e.RefCountable=function(){function e(){this.__LC||(this.__LC={}),this.__LC.ref_count=1}return e.extend=s,e.prototype.__destroy=function(){},e.prototype.retain=function(){if(this.__LC.ref_count<=0)throw"RefCountable: ref_count is corrupt: "+this.__LC.ref_count;return this.__LC.ref_count++,this},e.prototype.release=function(){if(this.__LC.ref_count<=0)throw"RefCountable: ref_count is corrupt: "+this.__LC.ref_count;return this.__LC.ref_count--,this.__LC.ref_count||this.__destroy(),this},e.prototype.refCount=function(){return this.__LC.ref_count},e}()}).call(this);
*/(function(){return function(e){return typeof define=="function"&&define.amd?define("lifecycle",e):e.call(this)}(function(){var e,t,n;e=this.LC=typeof exports!="undefined"?exports:{},e.VERSION="1.0.2",n=function(e){return e.constructor===Array},t=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e};var r=function(){},i=function(e,n,i){var s;return n&&n.hasOwnProperty("constructor")?s=n.constructor:s=function(){e.apply(this,arguments)},t(s,e),r.prototype=e.prototype,s.prototype=new r,n&&t(s.prototype,n),i&&t(s,i),s.prototype.constructor=s,s.__super__=e.prototype,s},s=function(e,t){var n=i(this,e,t);return n.extend=this.extend,n};return e.own=function(t,r){var i,s,o,u,a,f,l;if(!t||typeof t!="object")return t;r||(r={});if(n(t)){if(r.share_collection){for(u=0,f=t.length;u<f;u++)o=t[u],e.own(o,{prefer_clone:r.prefer_clone});return t}i=[];for(a=0,l=t.length;a<l;a++)o=t[a],i.push(e.own(o,{prefer_clone:r.prefer_clone}));return i}if(r.properties){if(r.share_collection){for(s in t)o=t[s],e.own(o,{prefer_clone:r.prefer_clone});return t}i={};for(s in t)o=t[s],i[s]=e.own(o,{prefer_clone:r.prefer_clone});return i}return t.retain?r.prefer_clone&&t.clone?t.clone():t.retain():t.clone?t.clone():t},e.disown=function(t,r){var i,s,o,u,a;r==null&&(r={});if(!t||typeof t!="object")return t;if(n(t))if(r.clear_values)for(i in t)o=t[i],e.disown(o,{clear_values:r.clear_values}),t[i]=null;else{for(u=0,a=t.length;u<a;u++)o=t[u],e.disown(o,{remove_values:r.remove_values});r.remove_values&&(t.length=0)}else if(r.properties)if(r.clear_values)for(s in t)o=t[s],e.disown(o,{clear_values:r.clear_values}),t[s]=null;else for(s in t)o=t[s],e.disown(o,{remove_values:r.remove_values}),delete t[s];else t.release?t.release():t.destroy&&t.destroy();return t},e.RefCountable=function(){function e(){this.__LC||(this.__LC={}),this.__LC.ref_count=1}return e.extend=s,e.prototype.__destroy=function(){},e.prototype.retain=function(){if(this.__LC.ref_count<=0)throw"RefCountable: ref_count is corrupt: "+this.__LC.ref_count;return this.__LC.ref_count++,this},e.prototype.release=function(){if(this.__LC.ref_count<=0)throw"RefCountable: ref_count is corrupt: "+this.__LC.ref_count;return this.__LC.ref_count--,this.__LC.ref_count||this.__destroy(),this},e.prototype.refCount=function(){return this.__LC.ref_count},e}(),e})}).call(this);

@@ -15,3 +15,3 @@ {

"main" : "lifecycle.js",
"version" : "1.0.1"
"version" : "1.0.2"
}
Lifecycle.js provides conventions and helpers to manage the life cycles of Javascript instances.
#Download Latest (1.1.2):
You can get the library here:
Please see the [release notes](https://github.com/kmalakoff/lifecycle/blob/master/RELEASE_NOTES.md) for upgrade pointers.
* [Development version][1]
* [Production version][2]
* [Development version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.js)
* [Production version](https://raw.github.com/kmalakoff/lifecycle/1.0.2/lifecycle.min.js)
###Module Loading
Lifecycle.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:
* 'lifecycle' - lifecycle.js.
Introduction

@@ -13,3 +20,3 @@ ------------

A good example of this is [Backbone.Articulation][3]. Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)
A good example of this is [Backbone.Articulation](https://github.com/kmalakoff/backbone-articulation). Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)

@@ -91,19 +98,2 @@ # LC.own and LC.disown

# Release Notes
###1.0.1
- converted back to CoffeeScript
- build using easy-bake
- added packaging tests
- added extend() functionality for JavaScript and CoffeeScript class usability
- changed convention from _destroy() to __destroy() given that some libraries (like KnockoutJS) use _destroy for other purposes
- removed Lifecycle alias
Building, Running and Testing the library

@@ -119,7 +109,2 @@ -----------------------

Look at: https://github.com/kmalakoff/easy-bake
[1]: https://raw.github.com/kmalakoff/lifecycle/1.0.1/lifecycle.js
[2]: https://raw.github.com/kmalakoff/lifecycle/1.0.1/lifecycle.min.js
[3]: https://github.com/kmalakoff/backbone-articulation
Look at: https://github.com/kmalakoff/easy-bake
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc