A NodeJS and browser wrapper for fetching etymology information in various languages from Douglas Harper's wonderful Online Etymology Dictionary (https://www.etymonline.com)
Please refer to Online Etymology Dictionary's Terms of Service to make sure you are not infringing intellectual property rights with your use case, and please be kind to their servers.
Consider donating directly to Douglas Harper for maintaining an excellent word resource.
Add etymo-js
to your Node project
npm install etymo-js
import { Etymo } from "etymo-js";
// initialize
const etymo = new Etymo();
async function run() {
const results = await etymo.search("remember");
console.log(results);
}
run();
Returns an array of search results, with the first item being most relevant:
[
{
"term": "remember (v.)",
"def": "mid-14c., remembren, \"keep or bear (something or someone) in mind, retain in the memory, preserve unforgotten,\" from Old French remembrer [...]",
"path": "/word/disremember#etymonline_v_11486",
"id": "11486"
},
{
"term": "*(s)mer- (1)",
"def": "Proto-Indo-European root meaning \"to remember.\" \n' +
'It forms all or part of: commemorate; commemoration; mourn; memo; memoir; memorable; memorandum; memorial [...]"
"path": "/word/*%28s%29mer-#etymonline_v_53458",
"id": "53458"
},
{
"term": "remembrance (n.)",
"def": "c. 1300, remembraunce, \"a memory, recollection,\" from Old French remembrance (11c.), from remembrer (see remember). From late 14c. as \"consideration, reflection; present consciousness [...]",
"path": "/word/remembrance#etymonline_v_37059",
"id": "37059"
} ...
]
Note - requires internet connection to retrieve data.
Basic search
Returns array of search result obejcts ({ term, def, path, id}
), ordered by relevance to search term
const res = await etymo.search("remember");
[
{
"term": "remember (v.)",
"def": "mid-14c., remembren, \"keep or bear (something or someone) in mind, retain in the memory, preserve unforgotten,\" from Old French remembrer [...]",
"path": "/word/disremember#etymonline_v_11486",
"id": "11486"
}, ...
]
Multi-word search
It's fine to use spaces in the search term
const res = await etymo.search("back seat");
[
{
"term": "back seat (n.)",
"def": "also back-seat, 1832, originally of coaches, from back (adj.) + seat (n.). Used figuratively for \"less or least prominent position\" by 1868. Back-seat driver \"passenger who gives the driver unwanted advice\" is [...]",
"path": "/word/back%20seat#etymonline_v_42318",
"id": "42318"
}, ...
]
Gets an entry by its path. You can also specifify the language of the definition returned.
Returns a single entry ({ term, def, path, id}
)
get English definition
const res = await etymo.get("/word/remember#etymonline_v_10402");
{
"term": "remember (v.)",
"def": "mid-14c., remembren, \"keep or bear (something or someone) in mind, retain in the memory, preserve unforgotten,\" from Old French remembrer \"remember, recall, bring to mind\" (11c.)[...]",
"path": "/word/remember#etymonline_v_10402",
"id": "10402"
}
get definition in another language
You can specify an option lang
parameter . See avaialable languages below. Note that the lang
parameter will override any language pre-pended in the provided path
.
// get definition in Japanese
const res = await etymo.get("/word/remember#etymonline_v_10402", {
lang: "jp",
});
{
"term": "remember (v.)",
"def": "14世紀中頃、remembren は、「(何かや誰かを)心に留める、記憶に保つ、忘れないようにする」という意味で使われました。これは、古フランス語の remembrer「思い出す、思い起こす」(11世紀)から来ており、ラテン語の rememorari「思い出す、記憶する」から派生したものです。これは、re-「再び」(re- を参照) [...]",
"path": "/jp/word/remember#etymonline_v_10402",
"id": "10402"
}
Supported languages
Language | Two-Letter Code |
---|---|
English | en |
Spanish | es |
French | fr |
German | de |
Italian | it |
Portuguese | pt |
Japanese | ja |
Chinese | zh |
Korean | ko |
Returns a list of terms currently trending on etymonline.com
const res = await etymo.trending();
// => ['nepotism','nickelodeon','hero','island','ego','fast','spell','gospel','father','confidence']
Package created with @el3um4s/typescript-npm-package-starter
Ignore the TS errors in the test file 🤷 Jest doesn't seem to care.
Run
npm run build
You can test the code with Jest
npm test
You can find the test coverage in coverage/lcov-report/index.html
.
You can check and upgrade dependencies to the latest versions, ignoring specified versions. with npm-check-updates:
npm run check-updates
You can also use npm run check-updates:minor
to update only patch and minor.
Instead npm run check-updates:patch
only updates patch.
First commit the changes to GitHub. Then login to your NPM account (If you don’t have an account you can do so on https://www.npmjs.com/signup)
npm login
Then run publish:
npm publish
If you're using a scoped name use:
npm publish --access public
To update the package use:
npm version patch
and then
npm publish