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
Show hidden characters
{ | |
"compilerOptions": { | |
"baseUrl": "..", | |
"paths": { | |
"@src/*": ["./src/*"] | |
} | |
} | |
} |
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
{"lastUpload":"2020-10-21T09:11:51.403Z","extensionVersion":"v3.4.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
export const amountToString = amount => ( | |
amount < 0 ? `(${-amount})` : `${amount}` | |
); |
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
[ ["Иван", "Иванов"], | |
[101101, "Московское ш., 101, кв. 101", "Ленинград"], | |
["812 123-1234", "916 123-4567"] ] |
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
{ "firstName": "Иван", "lastName": "Иванов", | |
"address": { "streetAddress": "Московское ш., 101, кв. 101", "city": "Ленинград", "postalCode": 101101 }, | |
"phoneNumbers": ["812 123-1234", "916 123-4567"] } |
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 authorsByIds = () => new DataLoader(async ids => { | |
const authors = await authorModel.findByIds(ids); | |
const authorById = new Map(); | |
authors.forEach(author => authorById.set(author.id, author)); | |
return ids.map(id => authorById.get(id)); | |
}); | |
const authorResolver = (source, { id }, context) => { | |
let dl = context.dataLoaders.get(authorsById); | |
if (!dl) { |
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
{"lastUpload":"2020-01-11T12:45:39.616Z","extensionVersion":"v3.4.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
const normalize = (k, v) => ( | |
k !== '' && Array.isArray(v) | |
? { name: v[0], age: v[1], flag: v[2] } | |
: v | |
); | |
const data = JSON.parse( | |
'[["name", 13, true], ["surname", 34, false]]', | |
normalize | |
); |
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
function MapValues<K extends string, S, D>( | |
source: { [k in K]: S }, | |
mapper: (value: S, key: K, src: { [k in K]: S }) => D | |
): { [k in K]: D } { | |
const dest = {} as { [k in K]: D }; | |
for (let key of Object.keys(source) as K[]) { | |
dest[key] = mapper(source[key], key, source) | |
} |
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 get = items => index => items[index]; | |
const push = items => item => { items.push(item); }; | |
const pop = items => () => items.pop(); | |
const arrayApi = items => Object.assign( | |
get(items), { | |
push: push(items), | |
pop: pop(items), | |
} | |
); |