44 lines
		
	
	
		
			809 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			809 B
		
	
	
	
		
			JavaScript
		
	
	
	
/**
 | 
						|
 * @ typedef {Object} BirthData
 | 
						|
 * @ property {Date} birthDate
 | 
						|
 */
 | 
						|
/**
 | 
						|
 * @typedef {Object} BrainCell
 | 
						|
 * @property {string} type
 | 
						|
 * @property {Object} data
 | 
						|
 */
 | 
						|
/**
 | 
						|
 * @type {BrainCell[]}
 | 
						|
 */
 | 
						|
export let memory = [];
 | 
						|
 | 
						|
export function AddCell(name, data)
 | 
						|
{
 | 
						|
    memory.push({
 | 
						|
        type: name,
 | 
						|
        data
 | 
						|
    });
 | 
						|
};
 | 
						|
/**
 | 
						|
 * @param {string} type 
 | 
						|
 * @param {(BrainCell) => boolean} filterQuery 
 | 
						|
 */
 | 
						|
export function RemoveCell(type, filterQuery)
 | 
						|
{
 | 
						|
    memory = memory.filter(e => !(
 | 
						|
        e.type == type && filterQuery(e.data)
 | 
						|
    ));
 | 
						|
};
 | 
						|
 | 
						|
/**
 | 
						|
 * @param {string} type 
 | 
						|
 * @param {(BrainCell) => boolean} filterQuery 
 | 
						|
 */
 | 
						|
export function FilterCell(type, filterQuery)
 | 
						|
{
 | 
						|
    return memory.filter(e => 
 | 
						|
        e.type == type && filterQuery(e.data)
 | 
						|
    ).map(e => e.data);
 | 
						|
};
 | 
						|
 | 
						|
window.memoryDump = () => memory; |