PageSourceSearch

https://lhkef.or.kr/js/components/organisms/news-box/internal/news-box.data-filter.js

js lhkef.or.kr collected 2026-10-03 01:25:45 UTC 1,800 bytes, 65 lines download raw bytes

1// @ts-check
2
3/** I. 기본 정보
4 * ==========================================
5 * <News Box Data Filter>
6 *
7 * Author: Innobaebae Co.
8 * Created: 2025-01-31
9 * Version: 1.0.0
10 *
11 * ==========================================
12 *
13 * 1. 목적:
14 *    탭 선택에 따른 데이터 필터링 로직
15 *
16 * 2. 특징:
17 *    - 순수 함수 (사이드 이펙트 없음)
18 *    - 카테고리 기반 필터링
19 */
20
21/**
22 * 탭 필터에 따라 데이터 필터링
23 * @param {Array} data - 전체 데이터 배열
24 * @param {string|null} filter - 필터 문자열 (null이면 전체)
25 * @returns {Array} - 필터링된 데이터
26 */
27export function filterDataByTab(data, filter) {
28  // filter가 null이면 전체 데이터 반환
29  if (!filter) {
30    return data;
31  }
32
33  // 카테고리가 필터 문자열을 포함하는 항목만 반환
34  return data.filter(item => {
35    const category = item.cate || '';
36    return category.includes(filter);
37  });
38}
39
40/**
41 * 데이터 검증 및 정규화
42 * @param {any} data - 검증할 데이터
43 * @returns {Array} - 정규화된 배열 데이터
44 */
45export function validateData(data) {
46  // 배열이 아니면 빈 배열 반환
47  if (!Array.isArray(data)) {
48    console.warn('[news-box] 데이터가 배열이 아닙니다:', data);
49    return [];
50  }
51
52  // 필수 필드 검증
53  return data.filter(item => {
54    const hasSeq = item.seq !== undefined && item.seq !== null;
55    const hasTitle = typeof item.title === 'string' && item.title.trim() !== '';
56    const hasDate = typeof item.regdate === 'string' && item.regdate.trim() !== '';
57
58    if (!hasSeq || !hasTitle || !hasDate) {
59      console.warn('[news-box] 필수 필드 누락:', item);
60      return false;
61    }
62
63    return true;
64  });
65}

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.