merge: Remove duplicate helper functions in cache tests. (#933)

* refactor: added one implementation of fibonacciCahce

* chore: move union function

* chore: renamed the cacheTest file
This commit is contained in:
Fahim Faisaal
2022-03-20 13:36:13 +06:00
committed by GitHub
parent bb2338216e
commit 9f7ed56290
4 changed files with 44 additions and 49 deletions

View File

@@ -1,20 +1,10 @@
import { memoize } from '../Memoize'
import { union } from './cacheTest'
import { fibonacci } from '../../Dynamic-Programming/FibonacciNumber'
import { factorial } from '../../Recursive/Factorial'
const multipleFactorials = (arr) => arr.map(factorial)
/**
* @title implementation of union function
* @param {Set} sets
* @return {new Set}
*/
function union (...sets) {
return new Set(
sets.reduce((flatArray, set) => [...flatArray, ...set], [])
)
}
describe('Testing Memoize', () => {
it('expects the fibonacci function to use the cache on the second call', () => {
const memoFibonacci = memoize(fibonacci)