25 lines
587 B
JavaScript
25 lines
587 B
JavaScript
var memoizedProperty = require('../util').memoizedProperty;
|
|
|
|
function memoize(name, value, factory, nameTr) {
|
|
memoizedProperty(this, nameTr(name), function() {
|
|
return factory(name, value);
|
|
});
|
|
}
|
|
|
|
function Collection(iterable, options, factory, nameTr, callback) {
|
|
nameTr = nameTr || String;
|
|
var self = this;
|
|
|
|
for (var id in iterable) {
|
|
if (Object.prototype.hasOwnProperty.call(iterable, id)) {
|
|
memoize.call(self, id, iterable[id], factory, nameTr);
|
|
if (callback) callback(id, iterable[id]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @api private
|
|
*/
|
|
module.exports = Collection;
|