Skip to content
This repository was archived by the owner on Jul 3, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ Client.prototype.query = function(input, cb) {
if(!this.appKey) {
return cb("Application key not set", null)
}
var options;
var search;
if(typeof(input) === 'object') {
// If an ojbect is passed, look for search string and options
search = input.search;
options = input.options;
} else {
// If it's not an object, assume it's the search string
search = input;
options = "";
}

var uri = 'http://api.wolframalpha.com/v2/query?input=' + encodeURIComponent(input) + '&primary=true&appid=' + this.appKey
var uri = 'http://api.wolframalpha.com/v2/query?input=' + encodeURIComponent(search) + '&primary=true&appid=' + this.appKey + options;

request(uri, function(error, response, body) {
if(!error && response.statusCode == 200) {
Expand Down
23 changes: 23 additions & 0 deletions test/option-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node

console.log(process.env.WOLFRAM_APPID);

var wolfram = require('./node-wolfram').createClient(process.env.WOLFRAM_APPID)

wolfram.query({search: "words containing msdoep",
options:
"&podstate=WordsMadeWithOnlyLetters__Show+all" +
"&podstate=WordsMadeWithOnlyLetters__Disallow+repetition" +
"&includepodid=WordsMadeWithOnlyLetters"},
function(err, result) {
if(err) throw err
console.log("Size: %d", result.length);
console.log("Result: %j", result[0].subpods[0].value);
})

wolfram.query("words containing abcdefg",
function(err, result) {
if(err) throw err
console.log("Size: %d", result.length);
console.log("Result: %j", result);
})