A `daily-sentence` module for node.js. (data from http://xue.youdao.com/w?page=1&type=all&position=tinyEnglish)
MIT License
A daily-sentence
module for node.js. (data from http://xue.youdao.com/w?page=1&type=all&position=tinyEnglish)
It will offer you different an English sentence (translation included) and an image each day. Something like:
He who would search for pearl must dive deep.
You just input that code under terminal:
$ npm install daily-sentence --save
And you just need require this module in your code file:
var daily = require("daily-sentence");
You can get today's sentence via
daily.today(function(err, sentence) {
// DO SOMETHING...
});
You can get oneday's sentence via:
daily.get(ONE_DAY, function(err, sentence) {
// DO SOMETHING...
});
The ONE_DAY
above is a variable. It can be:
new Date()
)The callback function will offer you an object that like:
{
"date" : "yyyy-mm-dd",
"image" : "THE_IMAGE_URL",
"sen" : "THE_ENGLISH_SENTENCE",
"trans" : "THE_TRANSLATION"
}
The module will default enable local cache (to save the network traffic). It will create a .daily-sen-db
directory at your current work directory (process.cwd()
). And all the cache file will be put into it.
If you don't want to use the cache files, you can disable it before you get
.
daily.setUseCache(false);
And if you want to reopen it, just switch the false
to true
.
Maybe I will create some sync
functions. Just maybe.
Anyone can do contribution to this project. And I will glad to merge your commit.
Just contact me @:
MIT