From 1edac1a264845b47839d2fdda55b1fa728fcec7e Mon Sep 17 00:00:00 2001 From: Shahar Or Date: Tue, 28 Apr 2015 16:02:10 +0300 Subject: [PATCH 1/2] Document with Verb --- .verb.md | 11 +++++++++++ README.md | 32 ++++++-------------------------- index.js | 10 ++++++++++ package.js | 3 ++- 4 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 .verb.md diff --git a/.verb.md b/.verb.md new file mode 100644 index 0000000..6606c1d --- /dev/null +++ b/.verb.md @@ -0,0 +1,11 @@ +{%= badge("npm") %} {%= badge("standard") %} + +# {%= name %} {%= badge("travis") %} + +## API + +{%= apidocs("index.js") %} + +## License + +{%= copyright() %} diff --git a/README.md b/README.md index 66793aa..d7054d3 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,10 @@ -# call-n-times +[![NPM](https://nodei.co/npm/call-n-times.png)](https://nodei.co/npm/call-n-times/) + [![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard) -Calls a provided function a specified number of times, synchronously, and returns an array of the return values. +# call-n-times [![Build Status](https://travis-ci.org/PolicyStat/call-n-times.svg)](https://travis-ci.org/PolicyStat/call-n-times) -Should work in IE7+. Perhaps even older. +## API -Tests included. +## License -``` js -var call = require("call-n-times"); - -var logAndReturnFoo = function(){ - console.log("foo"); - return "foo"; -}; - -var returns = call(logAndReturnFoo, 3); -// 'Foo' -// 'Foo' -// 'Foo' - -returns.length === 3; -// true -returns[0] === "foo" -// true -returns[1] === "foo" -// true -returns[2] === "foo" -// true -``` +Copyright © 2015 PolicyStat LLC \ No newline at end of file diff --git a/index.js b/index.js index ca7e271..cbeef88 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,16 @@ var isInteger = require('validate.io-integer') +/** + * Synchronously calls `func` `n` number of times + * + * @name `call-n-times` + * @param {Function} `func` The function to call multiple times + * @param {Number} `n` Number of times `func` will be called + * @returns {Array} The return values of all the `func` calls + * @api public + */ + module.exports = function (func, n, cb) { if (arguments.length < 2) { throw new Error('Expected exactly 2 arguments') diff --git a/package.js b/package.js index 00da8a2..39b0c88 100644 --- a/package.js +++ b/package.js @@ -22,7 +22,7 @@ pkg.scripts = { 'npm run unit' ].join(' && ') } -pkg.githubRepo('policystat/call-n-times') +pkg.githubRepo('PolicyStat/call-n-times') pkg.keywords = [ 'call', 'repeat', @@ -31,6 +31,7 @@ pkg.keywords = [ pkg.author = mightyiam.authorString pkg.license = ps.openSource.license.spdx pkg.devDependencies = { + 'verb-cli': '^0.6.2', mocha: '^2.2.4', chai: '^2.3.0', sinon: '^1.14.1', From d87f452a0843533c0d115339dfde734622699d84 Mon Sep 17 00:00:00 2001 From: Shahar Or Date: Tue, 28 Apr 2015 18:53:33 +0300 Subject: [PATCH 2/2] API doc fix --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index a29600c..3d774fd 100644 --- a/index.js +++ b/index.js @@ -8,9 +8,9 @@ var isInteger = require('validate.io-integer') * Synchronously calls `func` `n` number of times * * @name `call-n-times` - * @param {Function} `func` The function to call multiple times - * @param {Number} `n` Number of times `func` will be called - * @returns {Array} The return values of all the `func` calls + * @param {Function} `func` Called `n` times with the index as argument + * @param {Number} `n` Times `func` will be called + * @returns {Array} Return values of all the `func` calls * @api public */