aboutsummaryrefslogtreecommitdiffstats
path: root/src/memory.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.js')
-rw-r--r--src/memory.js43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/memory.js b/src/memory.js
index 1a30faa..57dfa02 100644
--- a/src/memory.js
+++ b/src/memory.js
@@ -1,36 +1,37 @@
+
SVG.extend(SVG.Element, {
// Remember arbitrary data
- remember: function(k, v) {
- // remember every item in an object individually
- if (typeof arguments[0] == 'object')
- for (var v in k)
- this.remember(v, k[v])
-
- // retrieve memory
- else if (arguments.length == 1)
+ remember: function (k, v) {
+ // remember every item in an object individually
+ if (typeof arguments[0] === 'object') {
+ for (var key in k) {
+ this.remember(key, k[key])
+ }
+ } else if (arguments.length === 1) {
+ // retrieve memory
return this.memory()[k]
-
- // store memory
- else
+ } else {
+ // store memory
this.memory()[k] = v
+ }
return this
- }
+ },
// Erase a given memory
-, forget: function() {
- if (arguments.length == 0)
+ forget: function () {
+ if (arguments.length === 0) {
this._memory = {}
- else
- for (var i = arguments.length - 1; i >= 0; i--)
+ } else {
+ for (var i = arguments.length - 1; i >= 0; i--) {
delete this.memory()[arguments[i]]
-
+ }
+ }
return this
- }
+ },
// Initialize or return local memory object
-, memory: function() {
+ memory: function () {
return this._memory || (this._memory = {})
}
-
-}) \ No newline at end of file
+})