2 lines
8.1 KiB
Plaintext
2 lines
8.1 KiB
Plaintext
|
)]}'
|
||
|
{"version":3,"sources":["reactive-dict/reactive-dict.js","reactive-dict/migration.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yE;AACA,mE;AACA,kC;AACA,0B;AACA,uB;AACA,gC;AACA,E;AACA,mC;AACA,6D;AACA,qB;AACA,iC;AACA,E;;AAEA,mE;AACA,oC;AACA,4B;AACA,iB;AACA,uC;AACA,oD;AACA,uE;AACA,2D;AACA,iE;AACA,8C;AACA,6D;AACA,2B;AACA,Y;AACA,oE;AACA,K;AACA,U;AACA,oD;AACA,mB;AACA,G;;AAEA,yC;AACA,8C;AACA,E;;AAEA,kC;AACA,qE;AACA,8D;AACA,qC;;AAEA,sC;AACA,oB;;AAEA,qE;AACA,mC;AACA,a;AACA,K;AACA,qD;AACA,kD;AACA,0B;;AAEA,6B;;AAEA,yC;AACA,mE;AACA,qC;AACA,a;AACA,2B;;AAEA,gC;AACA,uB;AACA,M;;AAEA,+B;AACA,iC;AACA,0D;AACA,6C;AACA,K;AACA,I;;AAEA,qC;AACA,oB;AACA,iE;AACA,uF;AACA,yC;AACA,uC;AACA,2B;AACA,K;AACA,I;;AAEA,uB;AACA,oB;AACA,yB;AACA,+B;AACA,iC;AACA,I;;AAEA,iC;AACA,oB;;AAEA,+C;AACA,wB;AACA,uC;AACA,gC;AACA,K;;AAEA,wE;AACA,sE;AACA,4E;AACA,0E;AACA,+E;AACA,oD;AACA,M;AACA,2E;AACA,qB;AACA,oC;AACA,oC;AACA,qC;AACA,uC;AACA,mC;AACA,mD;AACA,uB;AACA,mE;AACA,2C;;AAEA,yB;AACA,2B;;AAEA,2D;AACA,yE;;AAEA,mE;AACA,kB;AACA,0C;AACA,2E;AACA,qD;AACA,wE;AACA,2D;AACA,W;AACA,O;AACA,K;;AAEA,6B;AACA,gE;AACA,yC;AACA,I;;AAEA,iC;AACA,oB;;AAEA,yC;AACA,2B;AACA,O;AACA,I;;AAEA,8B;AACA,oB;AACA,iC;AACA,iD;AACA,kC;AACA,K;AACA,I;;AAEA,8D;AACA,iE;AACA,kC;AACA,gD;AACA,qB;AACA,G;AACA,G;;;;;;;;;;;;;;;;;;;ACjKA,oD;AACA,0D;;AAEA,sD;AACA,sD;AACA,oD;;AAEA,c;AACA,E;;AAEA,kE;AACA,oD;AACA,gE;;AAEA,gD;AACA,E;;AAEA,wC;AACA,+D;AACA,gE;AACA,4E;AACA,2C;AACA,yD;;AAEA,sE;AACA,gB;AACA,iE;AACA,sD;AACA,2B;;AAEA,wC;AACA,6E;;AAEA,0C;AACA,K;AACA,C","file":"/packages/reactive-dict.js","sourcesContent":["// XXX come up with a serialization method which canonicalizes object key\n// order, which would allow us to use objects as values for equals.\nvar stringify = function (value) {\n if (value === undefined)\n return 'undefined';\n return EJSON.stringify(value);\n};\nvar parse = function (serialized) {\n if (serialized === undefined || serialized === 'undefined')\n return undefined;\n return EJSON.parse(serialized);\n};\n\n// XXX COMPAT WITH 0.9.1 : accept migrationData instead of dictName\nReactiveDict = function (dictName) {\n // this.keys: key -> value\n if (dictName) {\n if (typeof dictName === 'string') {\n // the normal case, argument is a string name.\n // _registerDictForMigrate will throw an error on duplicate name.\n ReactiveDict._registerDictForMigrate(dictName, this);\n this.keys = ReactiveDict._loadMigratedDict(dictName) || {};\n } else if (typeof dictName === 'object') {\n // back-compat case: dictName is actually migrationData\n this.keys = dictName;\n } else {\n throw new Error(\"Invalid ReactiveDict argument: \" + dictName);\n }\n } else {\n // no name given; no migration will be performed\n this.keys = {};\n }\n\n this.keyDeps = {}; // key -> Dependency\n this.keyValueDeps = {}; // key -> Dependency\n};\n\n_.extend(ReactiveDict.prototype, {\n // set() began as a key/value method, but we are now overloading it\n // to take an object of key/value pairs, similar to backbone\n // http://backbonejs.org/#Model-set\n\n set: function (keyOrObject, value) {\n var self = this;\n\n if ((typeof keyOrObject === 'object') && (value === undefined)) {\n self._setObject(keyOrObject);\n return;\n }\n // the input isn't an object, so it must be a key\n // and we resume with the rest of the function\n var key = keyOrObject;\n\n value = stringify(value);\n\n var oldSerializedValue = 'undefined';\n if (_.has(self.keys, key)) oldSerializedValue = self.keys[key];\n if (value === oldSerializedValue)\n return;\n self.keys[key] = value;\n\n var changed = function (v) {\n v && v.changed();\n };\n\n changed(self.keyDeps[key]);\n if (self.keyValueDeps[key]) {\n changed(self.keyValueDeps[key][oldSerializedValue]);\n changed(self.keyValueDeps[key][value]);\n }\n },\n\n setDefault: function (key, value) {\n var self = this;\n // for now, explicitly check for undefined, since there is no\n // ReactiveDict.clear(). Later we might have a ReactiveD
|