Skip to content

Commit

Permalink
added blocking interface
Browse files Browse the repository at this point in the history
  • Loading branch information
yetzt committed Sep 27, 2013
1 parent bffae14 commit 0c74986
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "typojs",
"description": "Generates typical typing errors for any given string",
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "git://github.com/yetzt/node-typojs.git"
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Expand Up @@ -30,19 +30,25 @@ var typo = require("typojs");
### typo(string, extended, callback(typos))

* `string` is a String you want to get typos for
* `extended` generates more, less common typos
* `callback` is a callback method with all generated typos as first argument
* `extended` generates more, less common typos (optional)
* `callback` is a callback method with all generated typos as first argument (optional)

_If no callback method is specified, the generated typos will be returned instead._

## Example

```` javascript

var typo = require("typojs");

/* with callback */
typo("Whatever", true, function(typos){
console.log(typos);
});

/* without callback */
console.log(typo("Whatever", true));

````

## Dedication
Expand Down
3 changes: 3 additions & 0 deletions typo.js
Expand Up @@ -136,6 +136,9 @@ var typo = function(word, extended, callback) {
if (typos.indexOf(t) < 0) typos.push(t);
});

/* act blocking if no callback is given */
if (typeof callback !== "function") return typos;

/* call back */
callback(typos);

Expand Down

0 comments on commit 0c74986

Please sign in to comment.