Last active
December 6, 2017 17:30
-
-
Save VitorLuizC/62cd0bfefae11b016cbb24c1855a6dc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cull } from 'cullender'; | |
import { isActive, isLatest } from './validators' | |
// ... | |
const latest = cull( | |
[ ...users ], | |
isActive, | |
isLatest | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { isDate } from './validators'; | |
export const DAY = 24 * 60 * 60 * 1000; | |
export const getTime = (date) => isDate(date) ? new Date(date).getTime() : Date.now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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