本文整理汇总了TypeScript中ramda.split函数的典型用法代码示例。如果您正苦于以下问题:TypeScript split函数的具体用法?TypeScript split怎么用?TypeScript split使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: exec
exec('git branch --no-color -a', options, (error, stdout, stderr) => {
if (stderr || error) return reject(stderr || error);
const getCurrentBranch = R.compose(
R.trim,
R.replace('*', ''),
R.find(line => line.startsWith('*')),
R.split('\n')
);
const processBranches = R.compose(
R.filter(br => stdout.match(new RegExp(`remotes\/.*\/${br}`))),
R.uniq
);
const currentBranch = getCurrentBranch(stdout);
const branches = processBranches([currentBranch, defaultBranch]);
return excludeCurrentRevision
? resolve(branches)
: getCurrentRevision(exec, projectPath)
.then((currentRevision) => {
return resolve(branches.concat(currentRevision));
});
});
示例2: validateCards
module.exports = (
message: string,
callback: (error: Error, result: string) => void
) => {
const cards = validateCards(split('\n', message))
callback(null, cards.join('\n') + '\n')
}
示例3: getAllRemotes
export function getAllRemotes(exec, projectPath: string) : Promise<string[]> {
const process = R.compose(
R.uniq,
R.map(R.head),
R.map(R.split(' ')),
R.reject(R.isEmpty),
R.map(R.last),
R.map(R.split(/\t/)),
R.split('\n')
);
return new Promise((resolve, reject) => {
exec('git remote -v', { cwd: projectPath }, (error, stdout, stderr) => {
if (stderr || error) return reject(stderr || error);
resolve(process(stdout));
});
});
}
示例4:
export const searchKeywordMatcher = (searchKeyword: string, title: string) => {
const lowerCaseTitle = title.toLowerCase()
return R.compose(
R.all((x: string) => lowerCaseTitle.includes(x)),
R.filter(Boolean),
R.split(' '),
R.toLower
)(searchKeyword)
}
示例5: compose
getIdOrNullFor = type => compose(
ifElse(isNil, always(null), compose(
ifElse(
contains(type),
compose<string, string[], string, number, Record<string, number>>(
objOf(`${type}_id`), Number, last, split('-'),
),
always(null),
),
)),
);
示例6: readDownSQL
export function readDownSQL(migration: Migration): Promise<string> {
if (migration.split) {
return fs.readFileAsync(migration.downPath, {encoding: 'utf8'})
.then(R.trim);
}
return fs.readFileAsync(migration.path, {encoding: 'utf8'})
.then(R.split(MIGRATION_SQL_SPLIT_REGEXP))
.tap(R.partial(assertSQLSections, migration))
.then(R.nth(1))
.then(R.trim);
}
示例7: split
const createTypeRecord = (value?: string): null | DiskRecord | VolumeRecord => {
if (isNil(value) || value === 'none') {
return null;
}
// Given: volume-123
const [type, id] = split('-', value); // -> [volume, 123]
const key = `${type}_id`; // -> `volume_id`
const idAsNumber = Number(id); // -> 123
return objOf(key, idAsNumber); // -> { volume_id: 123 }
};
示例8: head
export const pinNumbers = (observed: string): Array<String> => {
const lookUp = ['08', '124', '1235', '236', '1457', '24568', '3569', '478', '57890', '689'];
let obsHead: string = head(observed);
const heads = lookUp[obsHead];
if (observed.length <= 1)
return split('', heads);
const result = [];
for (const h of heads) {
for (const t of pinNumbers(drop(1, observed))) {
result.push(h + t)
}
}
return result
};
示例9: split
const cookieKey = (cookie: string) => compose<string, string[], string>(head, split('='))(cookie)
示例10: countBy
const countChars = (w: string) => countBy(split('') as any, w as any);