Skip to content

Commit

Permalink
feat : compose functions
Browse files Browse the repository at this point in the history
  • Loading branch information
t007rushi committed Apr 7, 2022
1 parent 4c14851 commit 792e054
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/utils/composeFun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const composeFilterFunctions =
(state, ...functions) =>
(notes) =>
functions.reduce((acc, curr) => {
return curr(state, acc);
}, notes);

//Filter by priority
// export const filterbyPriority = (state, notes) => {
// if (state.priorities.length !== 0) {
// return notes.filter((item) =>
// state.priorities.includes(item.Note.priority)
// );
// }
// return notes;
// };
//Filter by labels
// export const filterbyLabels = (state, notes) => {
// if (state.tags.length !== 0) {
// return notes.filter(
// (item) =>
// item.Note.labels.filter((tag) => state.tags.includes(tag)).length > 0
// );
// }
// return notes;
// };
//sort by date
// export const sortbydate = (state, notes) => {
// if (state.sortby === "old") {
// return [...notes].sort(
// (a, b) => Date.parse(a.Note.createdAt) - Date.parse(b.Note.createdAt)
// );
// } else if (state.sortby === "new") {
// return [...notes].sort(
// (a, b) => Date.parse(b.Note.createdAt) - Date.parse(a.Note.createdAt)
// );
// }
// return notes;
// };

0 comments on commit 792e054

Please sign in to comment.