mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-18 13:43:27 +00:00
* Tgui: More common components in ts (#83098) ## About The Pull Request Converts more of common into typescript, with some tests ## Why It's Good For The Game Typescript,,,, * Tgui: More common components in ts --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
24 lines
651 B
TypeScript
24 lines
651 B
TypeScript
import { flow } from './fp';
|
|
|
|
describe('flow', () => {
|
|
it('composes multiple functions into one', () => {
|
|
const add2 = (x) => x + 2;
|
|
const multiplyBy3 = (x) => x * 3;
|
|
const subtract5 = (x) => x - 5;
|
|
|
|
const composedFunction = flow(add2, multiplyBy3, subtract5);
|
|
|
|
expect(composedFunction(4)).toBe(13); // ((4 + 2) * 3) - 5 = 13
|
|
});
|
|
|
|
it('handles arrays of functions', () => {
|
|
const add2 = (x) => x + 2;
|
|
const multiplyBy3 = (x) => x * 3;
|
|
const subtract5 = (x) => x - 5;
|
|
|
|
const composedFunction = flow([add2, multiplyBy3], subtract5);
|
|
|
|
expect(composedFunction(4)).toBe(13); // ((4 + 2) * 3) - 5 = 13
|
|
});
|
|
});
|