const push = (function() {
const container = [];
const alreadyInContainerIndex = {};
const checkItem = function(item) {
return item === null || !alreadyInContainerIndex[item.id];
};
return function(data) {
if (!checkItem(data))
return;
const index = container.push(data) - 1;
if (data)
alreadyInContainerIndex[data.id] = index;
}
})();