1 function immutableAssign <A, B> (target: A, source: B) {
2 return Object.assign({}, target, source)
5 function removeElementFromArray <T> (arr: T[], elem: T) {
6 const index = arr.indexOf(elem)
7 if (index !== -1) arr.splice(index, 1)
10 function sortBy (obj: any[], key1: string, key2?: string) {
11 return obj.sort((a, b) => {
12 const elem1 = key2 ? a[key1][key2] : a[key1]
13 const elem2 = key2 ? b[key1][key2] : b[key1]
15 if (elem1 < elem2) return -1
16 if (elem1 === elem2) return 0
21 function intoArray (value: any) {
22 if (!value) return undefined
23 if (Array.isArray(value)) return value
25 if (typeof value === 'string') return value.split(',')
30 function toBoolean (value: any) {
31 if (!value) return undefined
33 if (typeof value === 'boolean') return value
35 if (value === 'true') return true
36 if (value === 'false') return false
44 removeElementFromArray,