2015-10-08 00:08:19 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
let rpc = require('./rpc');
|
|
|
|
let util = require('./util');
|
|
|
|
|
2015-10-08 08:52:37 +00:00
|
|
|
let idKey = util.idKey;
|
|
|
|
let realmKey = util.realmKey;
|
|
|
|
let resizeListKey = util.resizeListKey;
|
2015-10-08 00:08:19 +00:00
|
|
|
|
|
|
|
exports.create = create;
|
|
|
|
|
|
|
|
function create(realmId, info) {
|
2015-10-08 04:20:14 +00:00
|
|
|
let results = util.createList(null, getterForLength, getterForIndex);
|
2015-10-08 00:08:19 +00:00
|
|
|
let size = info.size;
|
|
|
|
|
|
|
|
results[realmKey] = realmId;
|
2015-10-08 22:31:29 +00:00
|
|
|
results[idKey] = info.id;
|
2015-10-08 00:08:19 +00:00
|
|
|
|
2015-10-08 08:52:37 +00:00
|
|
|
results[resizeListKey](size);
|
2015-10-08 00:08:19 +00:00
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getterForLength() {
|
|
|
|
return rpc.getResultsSize(this[realmKey], this[idKey]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getterForIndex(index) {
|
|
|
|
return function() {
|
|
|
|
let realmId = this[realmKey];
|
|
|
|
return rpc.getResultsItem(realmId, this[idKey], index);
|
|
|
|
};
|
|
|
|
}
|