All files czip.ts

100% Statements 9/9
100% Branches 2/2
100% Functions 3/3
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  1x                                
/**
 * Generates a collection from multiple arrays
 * 
 * @export
 * @param {{[key: string]: any[]}} input Object with arrays
 * @param {string} [primary] Key of primary array (result will have the same length)
 * @returns {{[key: string]: any}} Collection
 */
export default function(input: {[key: string]: any[]}, primary?: string) : {[key: string]: any} {
	let keys : string[] = Object.keys(input),
		primaryValues : any = input[primary || keys[0]];
 
	return primaryValues.map((val, i) => {
		let res = {};
		keys.forEach(k => res[k] = input[k][i]);
		return res;
	});
};