Skip to content

Commit e86b9c9

Browse files
committed
upated jsdoc for primes
1 parent 8fd4d16 commit e86b9c9

4 files changed

Lines changed: 42 additions & 34 deletions

File tree

doc-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"./src/graphs/others/",
99
"./src/graphs/shortest-path/",
1010
"./src/graphs/spanning-trees/",
11-
"./src/data-structures/"
11+
"./src/data-structures/",
12+
"./src/primes/"
1213
],
1314
"includePattern": ".+\\.js(doc)?$",
1415
"excludePattern": "docs"

src/primes/is-prime.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
/**
2-
* Advanced (optimised) method for checking if provided number is prime
3-
*
4-
* For example for number 104743 it should return true, for 104744 - false
5-
*/
61
(function (exports) {
72
'use strict';
83

94
/**
10-
* Method will return true if provided number is prime
5+
* Advanced (optimised) method for checking if provided number is prime.
6+
* For example for number 104743 it should return true, for 104744 - false.
117
*
12-
* @module primes
13-
* @param {Number} number - number that we check on prime
14-
* @returns {Boolean}
8+
* @module primes/is-prime
9+
* @param {Number} number - Number that we check on prime
10+
* @returns {Boolean} Will return true if provided number is prime
11+
*
12+
* @example
13+
* var isPrime = require('path/to/primes/is-prime').isPrime;
14+
*
15+
* console.log(isPrime(7)); // true
16+
* console.log(isPrime(18)); // false
1517
*/
1618
exports.isPrime = function (number) {
1719
if (number === 1) {

src/primes/prime-factor-tree.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
/**
2-
* Method that will return list of all primes for provided number
3-
*
4-
* For example for number 18 it should return following list of primes [2, 3, 3]
5-
*/
61
(function (exports) {
72
'use strict';
83

94
/**
10-
* Method will list of all primes for provided number
5+
* Method will return list of all primes for provided number.
6+
* For example for number 18 it should return following list of primes
7+
* [2, 3, 3].
118
*
12-
* @module primes
13-
* @param {Number} number
14-
* @returns {Array}
9+
* @module primes/prime-factor-tree
10+
* @param {Number} number - Number for which method will find all primes
11+
* @returns {Array} List of available primes for provided number
12+
*
13+
* @example
14+
* var primeFactorTree = require('path/to/primes/prime-factor-tree')
15+
* .primeFactorTree;
16+
*
17+
* console.log(primeFactorTree(18)); // [2, 3, 3]
18+
* console.log(primeFactorTree(600851475143)); // [71, 839, 1471, 6857]
1519
*/
1620
exports.primeFactorTree = function (number) {
1721
var div = 2,

src/primes/sieve-of-eratosthenes.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
/**
2-
* Sieve of Eratosthenes
3-
*
4-
* Simple, ancient algorithm for finding all prime numbers up to any given limit
5-
*
6-
* For example for limit 12 it should return following list of primes:
7-
* [2, 3, 5, 7, 11]
8-
*/
91
(function (exports) {
102
'use strict';
113

124
/**
13-
* Returns Sieve of Eratosthenes for specified number
5+
* Sieve of Eratosthenes.
146
*
15-
* Simple, ancient algorithm for finding all prime numbers up to any given
7+
* Simple, ancient algorithm for finding all prime numbers up to given limit.
8+
*
9+
* Returns list of primes up to specified limit.
10+
*
11+
* For example, for limit 10 it should return following list of primes:
12+
* [2, 3, 5, 7]
13+
*
14+
* @module primes/sieve-of-eratosthenes
15+
* @param {Number} limit - Algorithm will returns list of primes up to
16+
* specified limit
17+
* @returns {Array} Will return list with all prime numbers up to provided
1618
* limit
1719
*
18-
* @module primes
19-
* @param {Number} limit - algorithm will return list with prime numbers up
20-
* to given limit
20+
* @example
21+
* var sieveOfEratosthenes = require('path/to/primes/sieve-of-eratosthenes')
22+
* .sieveOfEratosthenes;
2123
*
22-
* @returns {Array} - will return array with all prime numbers up to
23-
* provided limit
24+
* console.log(sieveOfEratosthenes(12)); // [2, 3, 5, 7, 11]
2425
*/
2526
exports.sieveOfEratosthenes = function (limit) {
2627
var sieve = [],

0 commit comments

Comments
 (0)