forked from Patatruc/word-definition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
42 lines (34 loc) · 1.04 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var wd = require("word-definition");
demo1();
function demo1() {
wd.getDef("thing", "en", null, function(result) {
print(result, "Definition of 'THING', english, no hyperlink");
demo2();
});
}
function demo2() {
wd.getDef("thing", "en", { hyperlinks: "html" }, function(result) {
print(result, "Definition of 'THING', english, HTML hyperlinks");
demo3();
});
}
function demo3() {
wd.getDef("fonctionnent", "fr", null, function(result) {
print(result, "Definition of 'FONCTIONNER' (verb) from the inflected form 'FONCTIONNENT', french, no hyperlink");
demo4();
});
}
function demo4() {
wd.getDef("garçon", "fr", { hyperlinks: "html", formatted: true }, function(result) {
print(result, "Definition of 'GARCON', french, with HTML hyperlinks and text formatting");
});
}
function print(definition, title) {
console.log();
console.log("******** " + title + " ********");
console.log();
console.log(definition);
console.log();
console.log("****************************************************************");
console.log("");
}