- CMS UI https://github.com/moneyadviceservice/cms / https://github.com/moneyadviceservice/cms/pulls?q=is%3Apr+is%3Aclosed+author%3Aourmaninamsterdam
- CMS UI https://github.com/moneyadviceservice/cms-editor
- Dough Component Library UI https://github.com/moneyadviceservice/dough/pulls?q=is%3Apr+is%3Aclosed+author%3Aourmaninamsterdam
- Main MAS website https://github.com/moneyadviceservice/frontend/pulls?q=is%3Apr+is%3Aclosed+author%3Aourmaninamsterdam
- A11y sandbox https://github.com/moneyadviceservice/frontend-sandbox/pulls?q=is%3Apr+is%3Aclosed+author%3Aourmaninamsterdam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import retryAsync from '~utils/retryAsync'; | |
describe('retryAsync', () => { | |
describe('with retry attempts left', () => { | |
describe('if the async function promise rejects', () => { | |
it('retries the given async function 3 times before eventually throwing', async () => { | |
const mockAsyncFn = jest.fn().mockRejectedValue('failed'); | |
await expect(retryAsync(3, () => mockAsyncFn())).rejects.toThrow(); | |
expect(mockAsyncFn).toHaveBeenCalledTimes(3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from https://howtodoinjava.com/typescript/function-overloading | |
class MiddleEarthResident { | |
name: string; | |
constructor(name: string) { | |
this.name = name; | |
} | |
} | |
class ShireResident extends MiddleEarthResident { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://stackoverflow.com/questions/44654291/is-it-good-practice-to-use-ordinal-of-enum | |
public enum Person { | |
GRANDPARENT(null), | |
PARENT(GRANDPARENT), | |
CHILD(PARENT); | |
private final Person parent; | |
private Person(Person parent) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import useAppState from 'react-native-appstate-hook'; | |
import RNFS from 'react-native-fs'; | |
async function copyDir(source: string, destination: string) { | |
const fileChangeLog: string[] = []; | |
await copyDirRecursive(source, destination, fileChangeLog); | |
return fileChangeLog; |
Natural -> (listof X) - build-list
(listof X) -> (listof X) - filter
(listof X) -> (listof Y) - map
(listof X) -> Boolean - andmap
(listof X) -> Boolean - ormap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (find name dir) | |
(local [(define (c1 n rdirs rimgs) | |
(or (string=? name n) | |
rdirs | |
rimgs)) | |
(define (c2 rdir rdirs) | |
(or rdir rdirs)) | |
(define (c3 img rimgs) | |
false)] | |
(fold-dir c1 c2 c3 false false dir))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = async (ms: number) => | |
new Promise((resolve) => { | |
setTimeout(() => resolve(), ms); | |
}); | |
await wait(10000); // wait for 10 seconds | |
// Continue... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NetInfo, { NetInfoState, NetInfoSubscription } from '@react-native-community/netinfo'; | |
import { useState, useRef, useEffect } from 'react'; | |
const useDeviceOnlineStatus = () => { | |
const [online, setOnline] = useState(false); | |
const unsubscribeRef = useRef<NetInfoSubscription | undefined>(); | |
useEffect(() => { | |
unsubscribeRef.current = NetInfo.addEventListener((state: NetInfoState) => { | |
setOnline(state.isConnected); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hyphenateText = (text, breakpoint) => { | |
if (text.length > breakpoint) { | |
const words = text.split(' '); | |
return words.map((word) => { | |
if (word.length > breakpoint) { | |
const head = word.substr(0, breakpoint); | |
const tail = word.substr(breakpoint); | |
return `${head} -${tail}`; | |
} | |
return word; |