refactor: migrate to nuxt
This commit is contained in:
17
utils/index.ts
Normal file
17
utils/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { meat, staple, vegetable } from '~/data/food'
|
||||
|
||||
const foodItems = [...vegetable, ...meat, ...staple]
|
||||
const foodEmojiMap = new Map()
|
||||
foodItems.forEach((item) => {
|
||||
foodEmojiMap.set(item.name, item.emoji)
|
||||
})
|
||||
|
||||
/**
|
||||
* get emojis from stuff name array
|
||||
* @param stuff
|
||||
* @returns
|
||||
*/
|
||||
export function getEmojisFromStuff(stuff: string[]) {
|
||||
const emojis: string[] = stuff.map(name => foodEmojiMap.get(name)).filter(item => !!item)
|
||||
return emojis
|
||||
}
|
||||
Reference in New Issue
Block a user