Skip to content

Commit

Permalink
Add doccomments
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Nov 9, 2018
1 parent 74ad8b1 commit 7f0b59a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/typescript/cached-factorial/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { AdjadentNumberedCalculator } from 'cached-expression-shared-utils'

/**
* Utilize [cached-expression](https://www.npmjs.com/package/cached-expression)
* to calculate multiple factorial numbers
*
* **Definition:**
* * 0! = 1! = 1
* * ∀ n ≥ 2: n! = n * (n - 1)!
*
* @example
* import CachedFactorial from 'cached-factorial'
* const { calculate } = new CachedFactorial()
* const result = [0, 1, 2, 3, 4, 5].map(calculate) // expect: [1, 1, 2, 6, 24, 120]
*/
class CachedFactorial extends AdjadentNumberedCalculator<number> {
constructor () {
super(
Expand Down
14 changes: 14 additions & 0 deletions packages/typescript/cached-fibonacci/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { AdjadentNumberedCalculator } from 'cached-expression-shared-utils'

/**
* Utilize [cached-expression](https://www.npmjs.com/package/cached-expression)
* to calculate fibonacci numbers
*
* **Definition:**
* * fib(0) = 0
* * fib(1) = 1
* * ∀ n ≥ 2: fib(n) = fib(n - 2) + fib(n - 1)
*
* @example
* import CachedFibonacci from 'cached-fibonacci'
* const { calculate } = new CachedFibonacci()
* const result = [0, 1, 2, 3, 4, 5].map(calculate) // expect: [0, 1, 1, 2, 3, 5]
*/
class CachedFibonacci extends AdjadentNumberedCalculator<number> {
constructor () {
super(x => {
Expand Down

0 comments on commit 7f0b59a

Please sign in to comment.