- 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 hidden or 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; |
This file contains hidden or 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 asEnumeration = dictionary => Object.freeze({ | |
from(value) { | |
if (dictionary[value]) { | |
return dictionary[value]; | |
} | |
throw Error(`Invalid enumeration value ${value}`); | |
} | |
}); | |
const getEvenNumbers = limit => includeIfConditionIsMet(limit, number => number % 2 === 0); |
This file contains hidden or 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 generateIncrementedNumbersList = (min, max, increment, includeMin) => { | |
const items = []; | |
let incrementor = Math.max(min, increment); | |
if (includeMin) { | |
items.push(min); | |
} | |
while (incrementor <= max) { | |
items.push(incrementor); |
This file contains hidden or 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 add = (a, b) => a + b; | |
const add10 = num => add(num, 10); | |
const add200 = num => add(num, 200); | |
const addNew = a => b => a + b; | |
console.log(add(10, 20)) // 30 | |
console.log(add10(10)) // 20 | |
console.log(addNew(10)(20)) // 30 | |
console.log(add200(10)) // 210 |
This file contains hidden or 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 rxRangeSlider = ({ rangeNode, handlesContainerNode, handleStartNode, handleEndNode, start: [stepStart, stepEnd], stepSize, bounds: [rangeStart, rangeEnd] }) => { | |
const KEY_LEFT = 37; | |
const KEY_RIGHT = 39; | |
const VALID_KEYS = [KEY_LEFT, KEY_RIGHT]; | |
const INCREMENT_LOWER = 'INCREMENT_LOWER'; | |
const DECREMENT_LOWER = 'DECREMENT_LOWER'; | |
const INCREMENT_UPPER = 'INCREMENT_UPPER'; | |
const DECREMENT_UPPER = 'DECREMENT_UPPER'; | |
const restrictToRange = (min, max, num) => Math.min(Math.max(min, num), max); |
This file contains hidden or 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 omit = (object, key) => { | |
const objectCopy = Object.assign({}, object); | |
Object.keys(objectCopy).forEach(itemKey => { | |
if(key === itemKey) { | |
delete objectCopy[itemKey]; | |
} | |
}) | |
return objectCopy; | |
}; |
This file contains hidden or 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
Rx.Observable.range(1, 10) | |
.toArray() | |
.mergeMap(items => Rx.Observable.from(items)) | |
.map(a => a + a) | |
.subscribe({ | |
next(items) { | |
console.log(items); | |
} |
This file contains hidden or 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 mapKeys = (collection, rootKey) => { | |
const obj = {}; | |
collection.forEach(item => { | |
obj[item[rootKey]] = item; | |
}); | |
return obj; | |
}; | |
const justins = [{id: 1, name: 'Justin Bieber'},{id: 2, name: 'Justin Timberlake'},{id: 3, name: 'Justin Time'}]; |
This file contains hidden or 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
"1,40-44" | |
.split(',') | |
.map(item => item.trim().split('-') | |
.map(item => parseInt(item.trim()))) // [[1], [40,44]] | |
"2-3,10,12,45,46-59" | |
.split(',') | |
.map(item => item.trim().split('-') | |
.map(item => parseInt(item.trim()))) // [[2,3], [10,12,45], [46,59]] |