本文整理汇总了TypeScript中ramda.join函数的典型用法代码示例。如果您正苦于以下问题:TypeScript join函数的具体用法?TypeScript join怎么用?TypeScript join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了join函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: migrations
export default function migrations(config: Config) {
let command = config.commands.migrations;
return listMigrations(config.files.directory)
.then(migrations =>
command.id
? R.filter(m => m.id === command.id, migrations)
: migrations
)
.map(command.long ? formatMigrationLong : formatMigration)
.then(R.join(''));
}
示例2: journal
export default function journal(config: Config) {
let client = config.client;
let command = config.commands.journal;
return readJournal(client.name, client.config, client.journalTable)
.then(entries =>
command.id
? R.filter(e => e.migrationID === command.id, entries)
: entries
)
.map(formatJournalEntry)
.then(R.join(''));
}
示例3: status
export default function status(config: Config) {
let client = config.client;
let command = config.commands.status;
let list = listMigrations(config.files.directory);
let read = readJournal(client.name, client.config, client.journalTable);
return Promise.join(list, read, getMigrationStates)
.then(states =>
command.id
? R.filter(s => s.migrationID === command.id, states)
: states
)
.map(formatMigrationState)
.then(R.join(''));
}
示例4: apply
export default function apply(config: Config) {
let client = config.client;
let command = config.commands.apply;
let migrations = listMigrations(config.files.directory);
let journal = readJournal(client.name, client.config, client.journalTable);
let states = Promise.join(migrations, journal, getMigrationStates)
let applicableIDs = states
.then(R.filter(isApplicable))
.then(ss => R.map(s => s.migrationID, ss));
let toApplyIDs: Promise<string[]>;
if (command.pending) {
toApplyIDs = applicableIDs;
} else if (command.id) {
toApplyIDs = applicableIDs.then(R.filter(id => id === command.id));
} else if (command.to) {
toApplyIDs = applicableIDs.then(R.filter(id => id <= command.to));
} else if (command.number) {
toApplyIDs = applicableIDs.then(R.take(command.number));
} else {
toApplyIDs = Promise.resolve([]);
}
let toApply = Promise.join(migrations, toApplyIDs, (ms, ids) =>
R.filter(m => R.contains(m.id, ids), ms)
);
let apply = toApply.then(ms =>
applyFunction(command.method)(
client.name, client.config, client.journalTable, ms
)
);
let previousEntry = journal.then(es => R.last(es));
let newEntries = Promise.join(previousEntry, apply, (prev, es) =>
prev ? R.filter(e => e.timestamp > prev.timestamp, es) : apply
);
return newEntries
.then(R.map(formatJournalEntry))
.then(R.join(''));
}
示例5: revert
export default function revert(config: Config) {
let client = config.client;
let command = config.commands.revert;
let migrations = listMigrations(config.files.directory);
let journal = readJournal(client.name, client.config, client.journalTable);
let states = Promise.join(migrations, journal, getMigrationStates);
let revertableIDs = states
.then(R.filter(isRevertable))
.then(ss => R.map(s => s.migrationID, ss));
let toRevertIDs: Promise<string[]>;
if (command.id) {
toRevertIDs = revertableIDs.then(R.filter(id => id === command.id));
} else if (command.to) {
toRevertIDs = revertableIDs.then(R.filter(id => id > command.to));
} else if (command.number) {
toRevertIDs = revertableIDs.then(R.reverse).then(R.take(command.number));
} else {
toRevertIDs = Promise.resolve([]);
}
let toRevert = Promise.join(migrations, toRevertIDs, (ms, ids) =>
R.filter(m => R.contains(m.id, ids), R.reverse(ms))
);
let revert = toRevert.then(ms =>
revertFunction(command.method)(
client.name, client.config, client.journalTable, ms
)
);
let previousEntry = journal.then(es => R.last(es));
let newEntries = Promise.join(previousEntry, revert, (prev, es) =>
R.filter(e => e.timestamp > prev.timestamp, es)
);
return newEntries
.then(R.map(formatJournalEntry))
.then(R.join(''));
}
示例6: saveBase64Image
static async saveBase64Image(base64: string): Promise<string> {
const imageURLData = base64.replace(/^data:image\/\w+;base64,/, '');
const hash = md5(imageURLData + Date.now()).substring(0, 20);
const filename = R.compose(
R.join('-'),
R.splitEvery(5)
)(hash);
const storagePath: string = configure.get('TASK_COVER_STORAGE_PATH');
await new Promise((resolve, reject) => {
fs.writeFile(path.join(storagePath, filename), imageURLData, 'base64', error => {
if (error) {
return reject(error);
}
return resolve();
});
});
return filename;
}
示例7: it
import * as R from 'ramda'
import makeCard from './makeCard'
const example = 'example'
const situation = 'situation'
const geography = 'geography'
const form = 'form'
const pronunciation = 'pronunciation'
const definition = 'definition'
const synonym = 'synonym'
const antonym = 'antonym'
const headword = "doesn't matter"
const frequency = "doesn't matter"
const join = R.join('')
describe('makeCard', () => {
it('make correct card if example passed (minimum card parts)', () => {
expect(
makeCard({
example,
definition,
form,
situation: '',
geography: '',
synonym: '',
antonym: '',
pronunciation: '',
headword,
frequency
})
示例8: compose
compose,
map
} from 'pointfree-fantasy';
import listen from 'utils/listen';
import getDom from 'utils/get-dom';
import logEventValue from 'utils/log-event-value';
import setHtml from 'utils/set-html';
import getJson from 'utils/get-json';
import log from 'utils/log';
const apiEndpoint: string = 'http://jsonplaceholder.typicode.com/posts';
// templatePost :: String -> String
const templatePost = (title: string) => `<li>${title}</li>`;
// getPostHtml :: Post -> String
const getPostHtml = compose(templatePost, _.prop('title'));
// getPostsHtml :: [Post] -> String
const getPostsHtml = compose(_.join(''), map(getPostHtml));
const displayPosts = compose(setHtml('.posts'), getPostsHtml);
getJson(apiEndpoint)
.fork(log, displayPosts);
getDom('input')
.map(listen('keyup'))
.runIO()
.subscribe(logEventValue, log);
示例9: RegExp
replacement =>
syllable.replace(
new RegExp(`(${join('|', replacementSet)})`, 'g'),
replacement
),