Permalink
Browse files

check for undefined in syllables()

  • Loading branch information...
1 parent e270b4e commit e6f91b1b60c1ffc762769d8f701d06f415a545a9 @substack committed May 2, 2011
Showing with 5 additions and 4 deletions.
  1. +2 −2 index.js
  2. +1 −1 package.json
  3. +2 −1 test/syllables.js
View
@@ -13,8 +13,8 @@ module.exports = function (cb) {
};
self.syllables = function (word) {
- var pro = self.pronounce(word)[0];
- return pro.filter(function (ph) {
+ var prose = self.pronounce(word);
+ return prose && prose[0].filter(function (ph) {
return ph.match(/^[AEIOU]/);
}).length;
};
View
@@ -1,7 +1,7 @@
{
"name" : "rhyme",
"description" : "A rhyming dictionary",
- "version" : "0.0.2",
+ "version" : "0.0.3",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/node-rhyme.git"
View
@@ -1,7 +1,7 @@
var assert = require('assert');
var rhyme = require('rhyme');
-exports.rhyme = function () {
+exports.syllables = function () {
var to = setTimeout(function () {
assert.fail('never finished');
}, 15000);
@@ -19,6 +19,7 @@ exports.rhyme = function () {
assert.eql(r.syllables('aim'), 1);
assert.eql(r.syllables('pineapple'), 3);
assert.eql(r.syllables('electrocution'), 5);
+ assert.ok(r.syllables('zimfphaml') === undefined);
});
};

0 comments on commit e6f91b1

Please sign in to comment.