Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Last active December 6, 2017 17:30
Show Gist options
  • Save VitorLuizC/62cd0bfefae11b016cbb24c1855a6dc5 to your computer and use it in GitHub Desktop.
Save VitorLuizC/62cd0bfefae11b016cbb24c1855a6dc5 to your computer and use it in GitHub Desktop.
import { cull } from 'cullender';
import { isActive, isLatest } from './validators'
// ...
const latest = cull(
[ ...users ],
isActive,
isLatest
);
import { isDate } from './validators';
export const DAY = 24 * 60 * 60 * 1000;
export const getTime = (date) => isDate(date) ? new Date(date).getTime() : Date.now();
import { DAY, getTime } from './time';
export const isDate = (value) => /^\d{4}-\d{2}-\d{2}$/.test(value);
export const isActive = ({ active }) => !!active;
export const isLatest = ({ created }) => getTime(created) > getTime() - 7 * DAY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment