forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃敟 Refactoring of the code to take out meta util
- Loading branch information
Showing
13 changed files
with
92 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
|
||
import { plays } from './play-meta'; | ||
|
||
const getAllPlays = () => { | ||
return plays; | ||
}; | ||
|
||
const getPlayById = id => { | ||
return plays.find(play => play.id === id); | ||
}; | ||
|
||
const getPlaysOnSearch = searchTerm => { | ||
return plays.filter(play => { | ||
return (play.name.toLowerCase().includes(searchTerm.toLowerCase()) | ||
|| play.description.toLowerCase().includes(searchTerm.toLowerCase())); | ||
}); | ||
} | ||
|
||
const getPlaysByTags = tags => { | ||
return plays.filter(play => { | ||
return play.tags.includes(tags); | ||
}); | ||
} | ||
|
||
const getPlaysByLevel = level => { | ||
return plays.filter(play => { | ||
return play.level === level; | ||
}); | ||
} | ||
|
||
const getPlaysByCreator = creator => { | ||
return plays.filter(play => { | ||
return play.github === creator; | ||
}); | ||
} | ||
|
||
const getAllTags = () => { | ||
const tags = plays.reduce((acc, play) => { | ||
return acc.concat(play.tags.split(',')); | ||
}, []); | ||
|
||
return Array.from(new Set([...tags])); | ||
} | ||
|
||
const getAllCreators = () => { | ||
const creators = plays.reduce((acc, play) => { | ||
play.github && acc.push(play.github); | ||
return acc; | ||
}, []); | ||
|
||
return Array.from(new Set([...creators])); | ||
} | ||
|
||
const getAllLevels = () => { | ||
const levels = plays.reduce((acc, play) => { | ||
return acc.concat(play.level); | ||
}, []); | ||
|
||
return Array.from(new Set([...levels])); | ||
} | ||
|
||
const getFeaturedPlays = () => { | ||
const featuredPlays = plays.filter(play => { | ||
return play.featured; | ||
}); | ||
return featuredPlays; | ||
} | ||
|
||
export { | ||
getAllPlays, | ||
getPlayById, | ||
getPlaysOnSearch, | ||
getPlaysByLevel, | ||
getPlaysByTags, | ||
getPlaysByCreator, | ||
getAllTags, | ||
getAllCreators, | ||
getAllLevels, | ||
getFeaturedPlays | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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