1/** 2 * ---------------------------------------------- 3 * CATEGORYã®keyããæå®ããããããã£ãåå¾ãã 4 * -- 5 * @param {Array} categories - ã«ãã´ãªé åã¾ãã¯äºæ¬¡å é å 6 * @param {string} seg - æ¤ç´¢ãããã¼ 7 * @param {Object} options - ãªãã·ã§ã³ 8 * @param {string} [options.prop='value'] - åå¾ããããããã£åï¼'value' ã 'seg_name' çï¼ 9 * @param {boolean} [options.unique=false] - éè¤ãé¤å¤ããã 10 * @return {Array} 11 * ---------------------------------------------- 12 */ 13export function getValuesByKey(categories, seg, { prop = 'value', unique = false } = {}) { 14 const flat = typeof categories.flat === 'function' ? categories.flat() : categories.reduce((a, b) => a.concat(b), []); 15 const values = flat 16 .filter(item => item && item.seg_name === seg && Object.prototype.hasOwnProperty.call(item, prop)) 17 .map(item => item[prop]); 18 return unique ? Array.from(new Set(values)) : values; 19}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.