geo.what3words
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -32,28 +32,2 @@ var request = require('request'), | ||
/** | ||
* Checks if oneWord is available | ||
* @param {[object]} options Can contain the following properties: | ||
* * lang: alternative language, default will be usef if this is not declared. | ||
* * word: a string containing the oneWord | ||
* * full: Return the full response | ||
*/ | ||
What3Words.prototype.oneWordAvailable = function (options) { | ||
var language = options.lang || this.language; | ||
return new Promise(_.bind(function(resolve, reject) { | ||
this.execute('oneword-available', {word: options.word, lang: language}) | ||
.then(function(res) { | ||
if (options.full) { | ||
resolve(res); | ||
} else { | ||
resolve(res.available); | ||
} | ||
}) | ||
.catch(function(err) { | ||
reject(err); | ||
}); | ||
}, this)); | ||
}; | ||
/** | ||
* Convert GPS co-ordinates into 3 words. | ||
@@ -60,0 +34,0 @@ * @param {[object]} options Can contain the following properties: |
@@ -5,7 +5,7 @@ { | ||
"main": "index.js", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"private": false, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lokku/js-geo-what3words.git" | ||
"url": "https://github.com/OpenCageData/js-geo-what3words.git" | ||
}, | ||
@@ -37,4 +37,4 @@ "scripts": { | ||
"bugs": { | ||
"url": "https://github.com/lokku/js-geo-what3words/issues" | ||
"url": "https://github.com/OpenCageData/js-geo-what3words/issues" | ||
} | ||
} |
var should = require('should'), | ||
What3Words = require('../lib/geo.what3words'), | ||
API_KEY = 'YOUR_API_KEY'; | ||
API_KEY = 'YOUR_API_KEY'; | ||
@@ -49,2 +49,3 @@ describe('What3Words API Wrapper', function(){ | ||
res.should.be.a.Array; | ||
res.length.should.be.greaterThan(0); | ||
done(); | ||
@@ -72,13 +73,4 @@ }); | ||
it('should be able to check if a word is available', function(done) { | ||
w3w.oneWordAvailable({ | ||
word: 'nestoria' | ||
}).then(function(res) { | ||
res.should.eql('1').and.be.a.Number; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
11758
216