ramda#flatten JavaScript Examples
The following examples show how to use
ramda#flatten.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From cross-chain-realitio-proxy with MIT License | 6 votes |
export function createEnhancedClient() {
const params = process.env.IS_LOCAL
? {
region: "localhost",
endpoint: "http://localhost:8000",
}
: {};
const client = new DynamoDB.DocumentClient(params);
const writeSingleBatch = curry(function _writeSingleBatch(tableName, batch) {
return client
.batchWrite({
RequestItems: {
[tableName]: batch,
},
})
.promise();
});
const writeAllBatches = function _writeAllBatches(tableName, items) {
return compose(map(writeSingleBatch(tableName)), splitBatches)(items);
};
const batchWrite = curry(async function _batchWrite(tableName, items) {
return flatten(await P.all(writeAllBatches(tableName, items)));
});
return {
client,
batchWrite,
};
}
Example #2
Source File: index.js From discovery-mobile-ui with MIT License | 6 votes |
extractNextUrls = (() => {
const hasNextLink = pathEq(['relation'], 'next');
const extractNextUrlFromLink = (link) => link?.find(hasNextLink)?.url;
return ({ link, entry }, depth = 0) => {
let urls = [extractNextUrlFromLink(link)];
if (entry) {
if (depth < 2) {
urls = urls.concat(entry.map(({ resource }) => extractNextUrls(resource, depth + 1)));
} else {
console.error('extractReferences depth: ', depth, entry); // eslint-disable-line no-console
}
}
return flatten(urls).filter((url) => !!url);
};
})()
Example #3
Source File: index.js From discovery-mobile-ui with MIT License | 6 votes |
lastNRecordIdsGroupedByDay = (records, count) => {
const lastNSorted = Object.entries(groupRecordsByDay(records))
.sort(([k1], [k2]) => ((k1 > k2) ? -1 : 1))
.slice(0, count)
.map(([, recordsOnDay]) => recordsOnDay)
.map((recordsOnDay) => recordsOnDay);
return flatten(lastNSorted).map((recordsOnDay) => recordsOnDay.id);
}