mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user