I have this JavaScript method that filters entries in an array that are one day apart:
one_day_deltas = availableDates.filter((date, index, arr) => {
return Math.abs(moment(date).diff(moment(arr[index - 1]), 'days')) == 1 || Math.abs(moment(date).diff(moment(arr[index + 1]), 'days')) == 1
})
I know there exists a Python function: filter() but I can't figure out how to mimic the build in args that JavaScript filter has built in callback argument.