UNPKG

my-own-words

Version:

A small tool that I have created to keep safe all those words/expressions that I come across when I'm learning a new language

20 lines (14 loc) 501 B
const { getAndParseWords, sortAndSaveWords } = require('./fs-helpers'); const { newList } = require('./new'); function addWord(listName, word, definition) { newList(listName); const listOfWords = getAndParseWords(listName); if (!Object.keys(listOfWords).includes(word)) listOfWords[word] = [definition]; if (word && !listOfWords[word].includes(definition)) { listOfWords[word].push(definition); } return sortAndSaveWords(listName, listOfWords); } module.exports = { addWord, };