Repository: pbiswas101/Mathball (js)

Issue:
Kaprekar Number
### Do the checklist before filing the issue:

- [ ] Is this something you can **debug and fix**?
- [x] Do you have Node.js and all the relevant dev-dependencies installed?
- [ ] Is this a **feature request** that you can add?

###### NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it.

- *Give your answer below:*

------------

[Function: **M.isKaprekar()**] needs to be added!
For more info:

https://www.geeksforgeeks.org/kaprekar-number/

*M.isKaprekar()* needs to accept a positive integer and all other arguments passed should throw a type error which needs to be handled gracefully! For error handling, you should refer to how other features like M.isArmstrong() is implemented.

Pull request description:
added M.check('prime')()
### Do the checklist before submitting the PR:

- [X] Have you read the guidelines mentioned in **CONTRIBUTING.md**?
- [ ] Have you squashed your commits?

**Q**: What version of *Node.js* you've used in the project? (`e.g. Node v10.11.0`)
**A**: v11.10.0

**Q**: Mention the *Issue Number*! (`e.g. Fixed #8`)
**A**: #111 

- *Give additional information regarding the PR below:*

------------


Patch:
diff --git a/README.md b/README.md
index 18f1f2d..b3e3aa9 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ $ npm install mathball --save
 
 ## Features
 
-- **Number Checkers** - [isArmstrong][3] - [isAutomorphic][4] - [isCarmichael][43] - [isDeficient][42] - [isFrugal][47] - [isHarshad][45] - [isKaprekar][23] - [isLucky][24] - [isNeon][5] - [isPalindrome][6] - [isPerfect][27] - [isPrime][7] - [isSmith][26] - [isStormer][52] -[isHoax][54]
+- **Number Checkers** - [isArmstrong][3] - [isAutomorphic][4] - [isCarmichael][43] - [isDeficient][42] - [isFrugal][47] - [isHarshad][45] - [isKaprekar][23] - [isLucky][24] - [isNeon][5] - [isPalindrome][6] - [isPerfect][27] - [M.check('prime')(Number)][7] - [isSmith][26] - [isStormer][52] -[isHoax][54]
 
 - **Find nth Number** - [bell][32] - [catalan][22] - [fibonacci][8] - [find][21] - [magic][9] - [nCr][48] - [fibonacci][8] - [magic][9] - [padovan][41] - [smart][25] - [triangular][93] - [ugly][56]
 
diff --git a/src/carmichael/index.js b/src/carmichael/index.js
index 130ee8e..e2c9490 100644
--- a/src/carmichael/index.js
+++ b/src/carmichael/index.js
@@ -3,7 +3,7 @@
 */
 
 const validate = require('../validation/positive-integer');
-const prime = require('../prime');
+const prime = require('../prime').check;
 
 function squarefree(i){
 	for(let k = 2; (k <= Math.sqrt(i) && i % k !== 0 && i/k % k !== 0); k++){
@@ -15,7 +15,7 @@ function isCarmichael(n){
 	let c = 0;
 	for(let i = 1; i <= n; i++){
 		if(n % i == 0){
-			if(prime.isPrime(i) && ((n-1) % (i-1) == 0)){
+			if(prime(i) && ((n-1) % (i-1) == 0)){
 				c++;
 				if(c >= 3 && i % 2 != 0 && squarefree(i)){
 					return true;
diff --git a/src/check/index.js b/src/check/index.js
new file mode 100644
index 0000000..6f4eb42
--- /dev/null
+++ b/src/check/index.js
@@ -0,0 +1,3 @@
+module.exports = arg => {
+  return require(`../${arg}`).check;
+};
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 07c4175..adf0a5a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -13,7 +13,8 @@ const armstrong = require('./armstrong'),
 	isFrugal = require('./isFrugal'),
 	isStormer = require('./isStormer'),
 	carmichael = require('./carmichael'),
-	{ isHoax } = require('./isHoax');
+	{ isHoax } = require('./isHoax'),
+	check = require('./check');
 
 /* Find nth Number */
 const bell = require('./bell'),
@@ -98,7 +99,6 @@ module.exports = {
 	pipe,
 	pow,
 	phi: totient.phi,
-	isPrime: prime.isPrime,
 	isStormer: isStormer.isStormer,
 	rangePrime: prime.rangePrime,
 	smart: smart.smart,
@@ -120,5 +120,6 @@ module.exports = {
 	Complex,
 	isHoax,
 	ugly,
-	triangular: triangular.triangular
+	triangular: triangular.triangular,
+	check
 };
diff --git a/src/prime/index.js b/src/prime/index.js
index 5521331..176fd64 100644
--- a/src/prime/index.js
+++ b/src/prime/index.js
@@ -4,7 +4,7 @@
 
 const validate = require('../validation/positive-integer');
 
-exports.isPrime = num => {
+exports.check = num => {
 	validate(num, 'isPrime');
   if (num === 2 || num === 3) { return true; }
   if (num < 2 || num % 2 === 0) { return false; }


Test patch:
diff --git a/test/check-spec.js b/test/check-spec.js
new file mode 100644
index 0000000..04b6b62
--- /dev/null
+++ b/test/check-spec.js
@@ -0,0 +1,12 @@
+const assert = require("assert"),
+	check = require("../src/check");
+
+describe("[Function: check]", () => {
+	it("should be a function", () => {
+		assert.strictEqual(typeof check, "function");
+  });
+
+	it("should return `true` when called `prime` with 2 as an argument", () => {
+		assert.strictEqual(check('prime')(2), true);
+  });
+});
diff --git a/test/prime-spec.js b/test/prime-spec.js
index 88957d0..dfb44d5 100644
--- a/test/prime-spec.js
+++ b/test/prime-spec.js
@@ -1,6 +1,6 @@
 const assert = require('assert'),
 	prime = require('../src/prime'),
-	isPrime = prime.isPrime,
+	isPrime = prime.check,
 	rangePrime = prime.rangePrime;
 
 describe('[Function: isPrime]', () => {