From 0cbb6ea78ecc720ee6166b83e395ea9fbf17069c Mon Sep 17 00:00:00 2001 From: Ivan Bakaidov Date: Thu, 4 Feb 2016 22:45:29 +0300 Subject: [PATCH] Add prototype --- Readme.md | 12 +++++++++++- index.js | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4f078d4..dbb4016 100644 --- a/Readme.md +++ b/Readme.md @@ -18,10 +18,20 @@ var fs = require('fs'); var read = thunkify(fs.readFile); read('package.json', 'utf8')(function(err, str){ - + }); ``` +### Or +```js +var thunkify = require('thunkify'); +var fs = require('fs'); +thunkify.addProto(); + +read.thunkify('package.json', 'utf8')(function(err, str){ + +}); +``` # License MIT diff --git a/index.js b/index.js index b2b272c..6c39d21 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,18 @@ var assert = require('assert'); module.exports = thunkify; +/** +* export prototype method +*/ +thunkify.addProto = function () { + +Object.defineProperty(Function.prototype, "thunkify", { + get: function () { + return thunkify(this); + } +}); +}; + /** * Wrap a regular callback `fn` as a thunk. *