debian-mirror-gitlab/app/assets/javascripts/analytics/shared/utils.js
2021-11-11 11:23:49 +05:30

9 lines
385 B
JavaScript

import dateFormat from 'dateformat';
import { dateFormats } from './constants';
export const filterBySearchTerm = (data = [], searchTerm = '', filterByKey = 'name') => {
if (!searchTerm?.length) return data;
return data.filter((item) => item[filterByKey].toLowerCase().includes(searchTerm.toLowerCase()));
};
export const toYmd = (date) => dateFormat(date, dateFormats.isoDate);