10
__coverage__['build/recordset-base/recordset-base.js'] = {"path":"build/recordset-base/recordset-base.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":45}}},"2":{"name":"(anonymous_2)","line":9,"loc":{"start":{"line":9,"column":12},"end":{"line":9,"column":23}}},"3":{"name":"(anonymous_3)","line":13,"loc":{"start":{"line":13,"column":17},"end":{"line":13,"column":28}}},"4":{"name":"(anonymous_4)","line":16,"loc":{"start":{"line":16,"column":16},"end":{"line":16,"column":27}}},"5":{"name":"(anonymous_5)","line":26,"loc":{"start":{"line":26,"column":14},"end":{"line":26,"column":30}}},"6":{"name":"(anonymous_6)","line":94,"loc":{"start":{"line":94,"column":17},"end":{"line":94,"column":28}}},"7":{"name":"(anonymous_7)","line":191,"loc":{"start":{"line":191,"column":15},"end":{"line":191,"column":27}}},"8":{"name":"(anonymous_8)","line":210,"loc":{"start":{"line":210,"column":22},"end":{"line":210,"column":34}}},"9":{"name":"(anonymous_9)","line":222,"loc":{"start":{"line":222,"column":23},"end":{"line":222,"column":46}}},"10":{"name":"(anonymous_10)","line":240,"loc":{"start":{"line":240,"column":15},"end":{"line":240,"column":26}}},"11":{"name":"(anonymous_11)","line":254,"loc":{"start":{"line":254,"column":20},"end":{"line":254,"column":34}}},"12":{"name":"(anonymous_12)","line":273,"loc":{"start":{"line":273,"column":9},"end":{"line":273,"column":32}}},"13":{"name":"(anonymous_13)","line":307,"loc":{"start":{"line":307,"column":12},"end":{"line":307,"column":35}}},"14":{"name":"(anonymous_14)","line":331,"loc":{"start":{"line":331,"column":11},"end":{"line":331,"column":22}}},"15":{"name":"(anonymous_15)","line":346,"loc":{"start":{"line":346,"column":12},"end":{"line":346,"column":34}}},"16":{"name":"(anonymous_16)","line":377,"loc":{"start":{"line":377,"column":15},"end":{"line":377,"column":27}}},"17":{"name":"(anonymous_17)","line":390,"loc":{"start":{"line":390,"column":18},"end":{"line":390,"column":30}}},"18":{"name":"(anonymous_18)","line":402,"loc":{"start":{"line":402,"column":18},"end":{"line":402,"column":30}}},"19":{"name":"(anonymous_19)","line":416,"loc":{"start":{"line":416,"column":17},"end":{"line":416,"column":29}}},"20":{"name":"(anonymous_20)","line":427,"loc":{"start":{"line":427,"column":17},"end":{"line":427,"column":30}}},"21":{"name":"(anonymous_21)","line":456,"loc":{"start":{"line":456,"column":24},"end":{"line":456,"column":48}}},"22":{"name":"(anonymous_22)","line":468,"loc":{"start":{"line":468,"column":21},"end":{"line":468,"column":36}}},"23":{"name":"(anonymous_23)","line":485,"loc":{"start":{"line":485,"column":14},"end":{"line":485,"column":37}}},"24":{"name":"(anonymous_24)","line":508,"loc":{"start":{"line":508,"column":17},"end":{"line":508,"column":40}}},"25":{"name":"(anonymous_25)","line":530,"loc":{"start":{"line":530,"column":17},"end":{"line":530,"column":41}}},"26":{"name":"(anonymous_26)","line":550,"loc":{"start":{"line":550,"column":16},"end":{"line":550,"column":27}}},"27":{"name":"(anonymous_27)","line":560,"loc":{"start":{"line":560,"column":20},"end":{"line":560,"column":31}}},"28":{"name":"(anonymous_28)","line":572,"loc":{"start":{"line":572,"column":21},"end":{"line":572,"column":35}}},"29":{"name":"(anonymous_29)","line":585,"loc":{"start":{"line":585,"column":17},"end":{"line":585,"column":34}}},"30":{"name":"(anonymous_30)","line":614,"loc":{"start":{"line":614,"column":20},"end":{"line":614,"column":31}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":650,"column":50}},"2":{"start":{"line":8,"column":0},"end":{"line":57,"column":3}},"3":{"start":{"line":10,"column":8},"end":{"line":10,"column":24}},"4":{"start":{"line":27,"column":8},"end":{"line":32,"column":9}},"5":{"start":{"line":28,"column":12},"end":{"line":28,"column":36}},"6":{"start":{"line":31,"column":12},"end":{"line":31,"column":43}},"7":{"start":{"line":33,"column":8},"end":{"line":33,"column":20}},"8":{"start":{"line":59,"column":0},"end":{"line":59,"column":18}},"9":{"start":{"line":69,"column":0},"end":{"line":644,"column":3}},"10":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"11":{"start":{"line":99,"column":12},"end":{"line":99,"column":29}},"12":{"start":{"line":103,"column":8},"end":{"line":172,"column":11}},"13":{"start":{"line":174,"column":8},"end":{"line":174,"column":46}},"14":{"start":{"line":176,"column":8},"end":{"line":181,"column":40}},"15":{"start":{"line":193,"column":8},"end":{"line":198,"column":9}},"16":{"start":{"line":194,"column":12},"end":{"line":194,"column":40}},"17":{"start":{"line":196,"column":13},"end":{"line":198,"column":9}},"18":{"start":{"line":197,"column":12},"end":{"line":197,"column":34}},"19":{"start":{"line":199,"column":8},"end":{"line":199,"column":20}},"20":{"start":{"line":211,"column":8},"end":{"line":211,"column":30}},"21":{"start":{"line":223,"column":8},"end":{"line":224,"column":29}},"22":{"start":{"line":226,"column":8},"end":{"line":226,"column":65}},"23":{"start":{"line":228,"column":8},"end":{"line":230,"column":9}},"24":{"start":{"line":229,"column":12},"end":{"line":229,"column":57}},"25":{"start":{"line":231,"column":8},"end":{"line":231,"column":31}},"26":{"start":{"line":241,"column":8},"end":{"line":241,"column":27}},"27":{"start":{"line":255,"column":8},"end":{"line":257,"column":21}},"28":{"start":{"line":258,"column":8},"end":{"line":260,"column":9}},"29":{"start":{"line":259,"column":12},"end":{"line":259,"column":55}},"30":{"start":{"line":261,"column":8},"end":{"line":261,"column":23}},"31":{"start":{"line":275,"column":8},"end":{"line":277,"column":14}},"32":{"start":{"line":279,"column":8},"end":{"line":279,"column":81}},"33":{"start":{"line":282,"column":8},"end":{"line":288,"column":9}},"34":{"start":{"line":283,"column":12},"end":{"line":285,"column":13}},"35":{"start":{"line":284,"column":16},"end":{"line":284,"column":63}},"36":{"start":{"line":286,"column":15},"end":{"line":288,"column":9}},"37":{"start":{"line":287,"column":12},"end":{"line":287,"column":56}},"38":{"start":{"line":290,"column":8},"end":{"line":293,"column":11}},"39":{"start":{"line":294,"column":8},"end":{"line":294,"column":20}},"40":{"start":{"line":308,"column":8},"end":{"line":308,"column":28}},"41":{"start":{"line":311,"column":8},"end":{"line":311,"column":63}},"42":{"start":{"line":312,"column":8},"end":{"line":312,"column":39}},"43":{"start":{"line":314,"column":8},"end":{"line":314,"column":63}},"44":{"start":{"line":315,"column":8},"end":{"line":319,"column":11}},"45":{"start":{"line":322,"column":8},"end":{"line":322,"column":20}},"46":{"start":{"line":332,"column":8},"end":{"line":332,"column":31}},"47":{"start":{"line":333,"column":8},"end":{"line":333,"column":20}},"48":{"start":{"line":347,"column":8},"end":{"line":349,"column":18}},"49":{"start":{"line":353,"column":8},"end":{"line":353,"column":54}},"50":{"start":{"line":354,"column":8},"end":{"line":354,"column":59}},"51":{"start":{"line":356,"column":8},"end":{"line":358,"column":9}},"52":{"start":{"line":357,"column":12},"end":{"line":357,"column":50}},"53":{"start":{"line":360,"column":8},"end":{"line":364,"column":11}},"54":{"start":{"line":366,"column":8},"end":{"line":366,"column":20}},"55":{"start":{"line":378,"column":8},"end":{"line":378,"column":76}},"56":{"start":{"line":391,"column":8},"end":{"line":391,"column":50}},"57":{"start":{"line":403,"column":8},"end":{"line":405,"column":9}},"58":{"start":{"line":404,"column":12},"end":{"line":404,"column":74}},"59":{"start":{"line":417,"column":8},"end":{"line":417,"column":25}},"60":{"start":{"line":428,"column":8},"end":{"line":430,"column":20}},"61":{"start":{"line":434,"column":8},"end":{"line":434,"column":64}},"62":{"start":{"line":436,"column":8},"end":{"line":437,"column":73}},"63":{"start":{"line":439,"column":8},"end":{"line":441,"column":9}},"64":{"start":{"line":440,"column":12},"end":{"line":440,"column":39}},"65":{"start":{"line":457,"column":8},"end":{"line":457,"column":41}},"66":{"start":{"line":469,"column":8},"end":{"line":469,"column":62}},"67":{"start":{"line":486,"column":8},"end":{"line":487,"column":19}},"68":{"start":{"line":489,"column":8},"end":{"line":491,"column":9}},"69":{"start":{"line":490,"column":12},"end":{"line":490,"column":47}},"70":{"start":{"line":493,"column":8},"end":{"line":493,"column":20}},"71":{"start":{"line":509,"column":8},"end":{"line":511,"column":9}},"72":{"start":{"line":510,"column":12},"end":{"line":510,"column":47}},"73":{"start":{"line":513,"column":8},"end":{"line":513,"column":20}},"74":{"start":{"line":531,"column":8},"end":{"line":533,"column":9}},"75":{"start":{"line":532,"column":12},"end":{"line":532,"column":75}},"76":{"start":{"line":535,"column":8},"end":{"line":535,"column":62}},"77":{"start":{"line":551,"column":8},"end":{"line":551,"column":18}},"78":{"start":{"line":561,"column":8},"end":{"line":561,"column":80}},"79":{"start":{"line":573,"column":8},"end":{"line":573,"column":77}},"80":{"start":{"line":586,"column":8},"end":{"line":588,"column":9}},"81":{"start":{"line":587,"column":12},"end":{"line":587,"column":45}},"82":{"start":{"line":590,"column":8},"end":{"line":591,"column":19}},"83":{"start":{"line":594,"column":8},"end":{"line":596,"column":9}},"84":{"start":{"line":595,"column":12},"end":{"line":595,"column":56}},"85":{"start":{"line":598,"column":8},"end":{"line":598,"column":39}},"86":{"start":{"line":616,"column":16},"end":{"line":616,"column":44}},"87":{"start":{"line":645,"column":0},"end":{"line":645,"column":32}},"88":{"start":{"line":646,"column":0},"end":{"line":646,"column":24}}},"branchMap":{"1":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":8},"end":{"line":27,"column":8}},{"start":{"line":27,"column":8},"end":{"line":27,"column":8}}]},"2":{"line":98,"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":98,"column":8}},{"start":{"line":98,"column":8},"end":{"line":98,"column":8}}]},"3":{"line":193,"type":"if","locations":[{"start":{"line":193,"column":8},"end":{"line":193,"column":8}},{"start":{"line":193,"column":8},"end":{"line":193,"column":8}}]},"4":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":13},"end":{"line":196,"column":13}},{"start":{"line":196,"column":13},"end":{"line":196,"column":13}}]},"5":{"line":226,"type":"cond-expr","locations":[{"start":{"line":226,"column":56},"end":{"line":226,"column":61}},{"start":{"line":226,"column":63},"end":{"line":226,"column":64}}]},"6":{"line":226,"type":"binary-expr","locations":[{"start":{"line":226,"column":17},"end":{"line":226,"column":37}},{"start":{"line":226,"column":42},"end":{"line":226,"column":51}}]},"7":{"line":279,"type":"cond-expr","locations":[{"start":{"line":279,"column":55},"end":{"line":279,"column":60}},{"start":{"line":279,"column":62},"end":{"line":279,"column":80}}]},"8":{"line":279,"type":"binary-expr","locations":[{"start":{"line":279,"column":15},"end":{"line":279,"column":35}},{"start":{"line":279,"column":40},"end":{"line":279,"column":50}}]},"9":{"line":282,"type":"if","locations":[{"start":{"line":282,"column":8},"end":{"line":282,"column":8}},{"start":{"line":282,"column":8},"end":{"line":282,"column":8}}]},"10":{"line":286,"type":"if","locations":[{"start":{"line":286,"column":15},"end":{"line":286,"column":15}},{"start":{"line":286,"column":15},"end":{"line":286,"column":15}}]},"11":{"line":311,"type":"cond-expr","locations":[{"start":{"line":311,"column":31},"end":{"line":311,"column":36}},{"start":{"line":311,"column":39},"end":{"line":311,"column":61}}]},"12":{"line":312,"type":"cond-expr","locations":[{"start":{"line":312,"column":30},"end":{"line":312,"column":35}},{"start":{"line":312,"column":37},"end":{"line":312,"column":38}}]},"13":{"line":353,"type":"cond-expr","locations":[{"start":{"line":353,"column":40},"end":{"line":353,"column":46}},{"start":{"line":353,"column":49},"end":{"line":353,"column":53}}]},"14":{"line":391,"type":"binary-expr","locations":[{"start":{"line":391,"column":36},"end":{"line":391,"column":43}},{"start":{"line":391,"column":47},"end":{"line":391,"column":48}}]},"15":{"line":436,"type":"binary-expr","locations":[{"start":{"line":436,"column":18},"end":{"line":436,"column":31}},{"start":{"line":437,"column":20},"end":{"line":437,"column":72}}]},"16":{"line":439,"type":"if","locations":[{"start":{"line":439,"column":8},"end":{"line":439,"column":8}},{"start":{"line":439,"column":8},"end":{"line":439,"column":8}}]},"17":{"line":531,"type":"if","locations":[{"start":{"line":531,"column":8},"end":{"line":531,"column":8}},{"start":{"line":531,"column":8},"end":{"line":531,"column":8}}]},"18":{"line":531,"type":"binary-expr","locations":[{"start":{"line":531,"column":12},"end":{"line":531,"column":25}},{"start":{"line":531,"column":29},"end":{"line":531,"column":49}}]},"19":{"line":561,"type":"binary-expr","locations":[{"start":{"line":561,"column":59},"end":{"line":561,"column":70}},{"start":{"line":561,"column":74},"end":{"line":561,"column":76}}]},"20":{"line":573,"type":"cond-expr","locations":[{"start":{"line":573,"column":43},"end":{"line":573,"column":46}},{"start":{"line":573,"column":49},"end":{"line":573,"column":76}}]},"21":{"line":586,"type":"if","locations":[{"start":{"line":586,"column":8},"end":{"line":586,"column":8}},{"start":{"line":586,"column":8},"end":{"line":586,"column":8}}]}},"code":["(function () { YUI.add('recordset-base', function (Y, NAME) {","","/**"," * Provides a wrapper around a standard javascript object. Can be inserted into a Recordset instance."," *"," * @class Record"," */","var Record = Y.Base.create('record', Y.Base, [], {"," _setId: function() {"," return Y.guid();"," },",""," initializer: function() {"," },",""," destructor: function() {"," },",""," /**"," * Retrieve a particular (or all) values from the object"," *"," * @param field {string} (optional) The key to retrieve the value from. If not supplied, the entire object is returned."," * @method getValue"," * @public"," */"," getValue: function(field) {"," if (field === undefined) {"," return this.get(\"data\");"," }"," else {"," return this.get(\"data\")[field];"," }"," return null;"," }","},","{"," ATTRS: {",""," /**"," * @description Unique ID of the record instance"," * @attribute id"," * @type string"," */"," id: {"," valueFn: \"_setId\""," },",""," /**"," * @description The object stored within the record instance"," * @attribute data"," * @type object"," */"," data: {"," value: null"," }"," }","});","","Y.Record = Record;","/**","The Recordset utility provides a standard way for dealing with","a collection of similar objects.","@module recordset","@main recordset","@submodule recordset-base","**/","","","var ArrayList = Y.ArrayList,","Lang = Y.Lang,","","/**","The Recordset utility provides a standard way for dealing with","a collection of similar objects.","","Provides the base Recordset implementation, which can be extended to add","additional functionality, such as custom indexing. sorting, and filtering.","","@class Recordset","@extends Base","@uses ArrayList","@param config {Object} Configuration object with initial attribute values","@constructor","**/","Recordset = Y.Base.create('recordset', Y.Base, [], {","",""," /**"," * Publish default functions for events. Create the initial hash table."," *"," * @method initializer"," * @protected"," */"," initializer: function() {"," // The reason the conditional is needed is because of two scenarios:"," // 1. Instantiating new Y.Recordset() will not go into the setter of \"records\", and so it is necessary to create this._items in the initializer."," // 2. Instantiating new Y.Recordset({records: [{...}]}) will call the setter of \"records\" and create this._items. In this case, we don't want that to be overwritten by []."," if (!this._items) {"," this._items = [];"," }",""," //set up event listener to fire events when recordset is modified in anyway"," this.publish({"," /**"," * <p>At least one record is being added. Additional properties of"," * the event are:</p>"," * <dl>"," * <dt>added</dt>"," * <dd>Array of new records to be added</dd>"," * <dt>index</dt>"," * <dd>The insertion index in the Recordset's internal"," * array</dd>"," * </dl>"," *"," * <p>Preventing this event will cause the new records NOT to be"," * added to the Recordset's internal collection.</p>"," *"," * @event add"," * @preventable _defAddFn"," */"," add: { defaultFn: this._defAddFn },",""," /**"," * <p>At least one record is being removed. Additional properties of"," * the event are:</p>"," * <dl>"," * <dt>removed</dt>"," * <dd>Array of records to be removed</dd>"," * <dt>range</dt>"," * <dd>Number of records to be removed</dd>"," * <dt>index</dt>"," * <dd>The starting index in the Recordset's internal"," * array from which to remove records</dd>"," * </dl>"," *"," * <p>Preventing this event will cause the records NOT to be"," * removed from the Recordset's internal collection.</p>"," *"," * @event remove"," * @preventable _defRemoveFn"," */"," remove: { defaultFn: this._defRemoveFn },",""," /**"," * The Recordset is being flushed of all records."," *"," * @event empty"," * @preventable _defEmptyFn"," */"," empty: { defaultFn: this._defEmptyFn },",""," /**"," * <p>At least one record is being updated. Additional properties of"," * the event are:</p>"," * <dl>"," * <dt>updated</dt>"," * <dd>Array of records with updated values</dd>"," * <dt>overwritten</dt>"," * <dd>Array of current records that will be replaced</dd>"," * <dt>index</dt>"," * <dd>The starting index in the Recordset's internal"," * array from which to update will apply</dd>"," * </dl>"," *"," * <p>Preventing this event will cause the records NOT to be"," * updated in the Recordset's internal collection.</p>"," *"," * @event update"," * @preventable _defUpdateFn"," */"," update: { defaultFn: this._defUpdateFn }"," });",""," this._buildHashTable(this.get('key'));",""," this.after(["," 'recordsChange',"," 'add',"," 'remove',"," 'update',"," 'empty'], this._updateHash);"," },",""," /**"," * Returns the record with particular ID or index"," *"," * @method getRecord"," * @param i {String, Number} The ID of the record if a string, or the index if a number."," * @return {Record} A Y.Record instance"," */"," getRecord: function(i) {",""," if (Lang.isString(i)) {"," return this.get('table')[i];"," }"," else if (Lang.isNumber(i)) {"," return this._items[i];"," }"," return null;"," },","",""," /**"," * Returns the record at a particular index"," *"," * @method getRecordByIndex"," * @param i {Number} Index at which the required record resides"," * @return {Record} A Y.Record instance"," */"," getRecordByIndex: function(i) {"," return this._items[i];"," },",""," /**"," * Returns a range of records beginning at particular index"," *"," * @method getRecordsByIndex"," * @param index {Number} Index at which the required record resides"," * @param range {Number} (Optional) Number of records to retrieve. The default is 1"," * @return {Array} An array of Y.Record instances"," */"," getRecordsByIndex: function(index, range) {"," var i = 0,"," returnedRecords = [];"," //Range cannot take on negative values"," range = (Lang.isNumber(range) && (range > 0)) ? range: 1;",""," for (; i < range; i++) {"," returnedRecords.push(this._items[index + i]);"," }"," return returnedRecords;"," },",""," /**"," * Returns the length of the recordset"," *"," * @method getLength"," * @return {Number} Number of records in the recordset"," */"," getLength: function() {"," return this.size();"," },",""," /**"," Gets an array of values for a data _key_ in the set's records. If no _key_"," is supplied, the returned array will contain the full data object for each"," record.",""," @method getValuesByKey"," @param {String} [key] Data property to get from all records"," @return {Array} An array of values for the given _key_ if supplied."," Otherwise, an array of each record's data hash."," **/"," getValuesByKey: function(key) {"," var i = 0,"," len = this._items.length,"," retVals = [];"," for (; i < len; i++) {"," retVals.push(this._items[i].getValue(key));"," }"," return retVals;"," },","",""," /**"," * Adds one or more Records to the RecordSet at the given index. If index is null, then adds the Records to the end of the RecordSet."," *"," * @method add"," * @param {Record|Object|Array} oData A Y.Record instance, An object literal of data or an array of object literals"," * @param [index] {Number} [index] Index at which to add the record(s)"," * @return {Recordset} The updated recordset instance"," */"," add: function(oData, index) {",""," var newRecords = [],"," idx,"," i = 0;",""," idx = (Lang.isNumber(index) && (index > -1)) ? index: this._items.length;",""," //Passing in array of object literals for oData"," if (Lang.isArray(oData)) {"," for (; i < oData.length; i++) {"," newRecords[i] = this._changeToRecord(oData[i]);"," }"," } else if (Lang.isObject(oData)) {"," newRecords[0] = this._changeToRecord(oData);"," }",""," this.fire('add', {"," added: newRecords,"," index: idx"," });"," return this;"," },",""," /**"," Removes one or more Records to the RecordSet at the given index. If index"," is null, then removes a single Record from the end of the RecordSet.",""," @method remove"," @param {Number} [index] Index at which to remove the record(s) from"," @param {Number} [range] Number of records to remove (including the one"," at the index)"," @return {Recordset} The updated recordset instance"," **/"," remove: function(index, range) {"," var remRecords = [];",""," //Default is to only remove the last record - the length is always 1 greater than the last index"," index = (index > -1) ? index: (this._items.length - 1);"," range = (range > 0) ? range: 1;",""," remRecords = this._items.slice(index, (index + range));"," this.fire('remove', {"," removed: remRecords,"," range: range,"," index: index"," });"," //this._recordRemoved(remRecords, index);"," //return ({data: remRecords, index:index});"," return this;"," },",""," /**"," * Empties the recordset"," *"," * @method empty"," * @return {Recordset} The updated recordset instance"," */"," empty: function() {"," this.fire('empty', {});"," return this;"," },",""," /**"," Updates the recordset with the new records passed in. Overwrites existing"," records when updating the index with the new records.",""," @method update"," @param {Record|Object|Array} data A Y.Record instance, An object literal of"," data or an array of object literals"," @param {Number} [index] The index to start updating from."," @return {Recordset} The updated recordset instance"," **/"," update: function(data, index) {"," var rec,"," arr,"," i = 0;",""," // Whatever is passed in, we are changing it to an array so that it can"," // be easily iterated in the _defUpdateFn method"," arr = (!(Lang.isArray(data))) ? [data] : data;"," rec = this._items.slice(index, index + arr.length);",""," for (; i < arr.length; i++) {"," arr[i] = this._changeToRecord(arr[i]);"," }",""," this.fire('update', {"," updated: arr,"," overwritten: rec,"," index: index"," });",""," return this;"," },",""," /**"," * Default behavior for the \"add\" event. Adds Record instances starting from"," * the index specified in `e.index`."," *"," * @method _defAddFn"," * @param {EventFacade} e The add event"," * @private"," */"," _defAddFn: function(e) {"," this._items.splice.apply(this._items, [e.index, 0].concat(e.added));"," },",""," /**"," * Default behavior for the \"remove\" event. Removes Records from the"," * internal array starting from `e.index`. By default, it will remove one"," * Record. But if `e.range` is set, it will remove that many Records."," *"," * @method _defRemoveFn"," * @param {EventFacade} e The remove event"," * @private"," */"," _defRemoveFn: function(e) {"," this._items.splice(e.index, e.range || 1);"," },",""," /**"," * Default behavior for the \"update\" event. Sets Record instances for each"," * item in `e.updated` at indexes starting from `e.index`."," *"," * @method _defUpdateFn"," * @param {EventFacade} e The update event"," * @private"," */"," _defUpdateFn: function(e) {"," for (var i = 0; i < e.updated.length; i++) {"," this._items[e.index + i] = this._changeToRecord(e.updated[i]);"," }"," },",""," /**"," * Default behavior for the \"empty\" event. Clears the internal array of"," * Records."," *"," * @method _defEmptyFn"," * @param {EventFacade} e The empty event"," * @private"," */"," _defEmptyFn: function(e) {"," this._items = [];"," },",""," /**"," Updates the internal hash table.",""," @method _defUpdateHash"," @param {EventFacade} e Event triggering the hash table update"," @private"," **/"," _updateHash: function (e) {"," var handler = \"_hash\","," type = e.type.replace(/.*:/,''),"," newHash;",""," // _hashAdd, _hashRemove, _hashEmpty, etc"," // Not a switch or else if setup to allow for external expansion."," handler += type.charAt(0).toUpperCase() + type.slice(1);",""," newHash = this[handler] &&"," this[handler](this.get('table'), this.get('key'), e);",""," if (newHash) {"," this.set('table', newHash);"," }"," },",""," /**"," Regenerates the hash table from the current internal array of Records.",""," @method _hashRecordsChange"," @param {Object} hash The hash map before replacement"," @param {String} key The key by which to add items to the hash"," @param {Object} e The event or object containing the items to be added."," Items are expected to be stored in an array assigned to"," the `added` property."," @return {Object} The updated hash map"," @private"," **/"," _hashRecordsChange: function (hash, key, e) {"," return this._buildHashTable(key);"," },",""," /**"," Builds a hash table from the current internal array of Records.",""," @method _buildHashTable"," @param {String} key The Record key to hash the items by"," @return {Object} A new hash map of Records keyed by each Records' key"," @private"," **/"," _buildHashTable: function (key) {"," return this._hashAdd({}, key, { added: this._items });"," },",""," /**"," Adds items to the hash table. Items are the values, and the keys are the"," values of the item's attribute named in the `key` parameter.",""," @method _hashAdd"," @param {Object} hash The hash map before adding items"," @param {String} key The key by which to add the items to the hash"," @param {Object} e The event or object containing the items to be added."," Items are expected to be stored in an array assigned to"," the `added` property."," @return {Object} The updated hash map"," @private"," **/"," _hashAdd: function(hash, key, e) {"," var items = e.added,"," i, len;",""," for (i = 0, len = e.added.length; i < len; ++i) {"," hash[items[i].get(key)] = items[i];"," }",""," return hash;"," },",""," /**"," Removes items from the hash table.",""," @method _hashRemove"," @param {Object} hash The hash map before removing items"," @param {String} key The key by which to remove the items from the hash"," @param {Object} e The event or object containing the items to be removed."," Items are expected to be stored in an array assigned to"," the `removed` property."," @return {Object} The updated hash map"," @private"," **/"," _hashRemove: function(hash, key, e) {"," for (var i = e.removed.length - 1; i >= 0; --i) {"," delete hash[e.removed[i].get(key)];"," }",""," return hash;"," },",""," /**"," Updates items in the hash table.",""," @method _hashUpdate"," @param {Object} hash The hash map before updating items"," @param {String} key The key by which to update the items to the hash"," @param {Object} e The event or object containing the items to be updated."," Items are expected to be stored in an array assigned to"," the `updated` property. Optionally, items can be"," identified for being overwritten by including them in an"," array assigned to the `overwritten` property."," @return {Object} The updated hash map"," @private"," **/"," _hashUpdate: function (hash, key, e) {"," if (e.overwritten && e.overwritten.length) {"," hash = this._hashRemove(hash, key, { removed: e.overwritten });"," }",""," return this._hashAdd(hash, key, { added: e.updated });"," },",""," /**"," Clears the hash table.",""," @method _hashEmpty"," @param {Object} hash The hash map before adding items"," @param {String} key The key by which to remove the items from the hash"," @param {Object} e The event or object containing the items to be removed."," Items are expected to be stored in an array assigned to"," the `removed` property."," @return {Object} An empty hash"," @private"," **/"," _hashEmpty: function() {"," return {};"," },",""," /**"," * Sets up the hashtable with all the records currently in the recordset"," *"," * @method _initHashTable"," * @private"," */"," _initHashTable: function() {"," return this._hashAdd({}, this.get('key'), { added: this._items || [] });"," },",""," /**"," * Helper method - it takes an object bag and converts it to a Y.Record"," *"," * @method _changeToRecord"," * @param obj {Object|Record} Any objet literal or Y.Record instance"," * @return {Record} A Record instance."," * @private"," */"," _changeToRecord: function(obj) {"," return (obj instanceof Y.Record) ? obj : new Y.Record({ data: obj });"," },",""," /**"," Ensures the value being set is an array of Record instances. If array items"," are raw object data, they are turned into Records.",""," @method _setRecords"," @param {Record[]|Object[]} items The Records or data Objects to store as"," Records."," @return {Record[]}"," **/"," _setRecords: function (items) {"," if (!Y.Lang.isArray(items)) {"," return Y.Attribute.INVALID_VALUE;"," }",""," var records = [],"," i, len;",""," // FIXME: This should use the flyweight pattern if possible"," for (i = 0, len = items.length; i < len; ++i) {"," records[i] = this._changeToRecord(items[i]);"," }",""," return (this._items = records);"," }","}, {"," ATTRS: {",""," /**"," * An array of Records that the Recordset is storing. Passing an array"," * of raw record data is also accepted. The data for each item will be"," * wrapped in a Record instance."," *"," * @attribute records"," * @type {Record[]}"," */"," records: {"," // TODO: necessary? valueFn?"," lazyAdd: false,"," getter: function() {"," // give them a copy, not the internal object"," return Y.Array(this._items);"," },"," setter: \"_setRecords\""," },",""," /**"," A hash table where the ID of the record is the key, and the record"," instance is the value.",""," @attribute table"," @type object"," **/"," table: {"," valueFn: '_initHashTable'"," },",""," /**"," The ID to use as the key in the hash table.",""," @attribute key"," @type string"," **/"," key: {"," value: 'id',"," readOnly: true"," }",""," }","});","Y.augment(Recordset, ArrayList);","Y.Recordset = Recordset;","","","","}, '3.13.0', {\"requires\": [\"base\", \"arraylist\"]});","","}());"]};