本文整理汇总了TypeScript中@jonggrang/prelude.isRight函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isRight函数的具体用法?TypeScript isRight怎么用?TypeScript isRight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isRight函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderDirectoryContentsTable
function renderDirectoryContentsTable(pieces: Piece[], folder: Folder): string {
let table = [
'<table>',
' <thead>',
' <th class="first"></th>', // todo image
' <th>Name</th>',
' <th>Modified</th>',
' <th>Size</th>',
' </thead>',
' <tbody>'
].join('\n');
const sorted = folder.sort(compareFolder);
let alt: boolean;
let item: Either<FolderName, File>;
let name: string;
let href: string;
for (let i = 0, len = sorted.length; i < len; i++) {
alt = (i % 2) === 0;
item = sorted[i];
name = isLeft(item) ? (item.value === '' ? '..' : item.value) : item.value.name;
href = addCurrentDir(pieces, name)
table += alt ? '<tr class="alt">' : '<tr>\n';
table += `<td class="first${isLeft(item) ? ' icon-dir' : ''}"></td>\n`;
table += `<td><a href="${href}">${name}</a></td>\n`;
table += `<td>${isRight(item) && isJust(item.value.getModified)
? formatCalender(item.value.getModified.value) : ''}</td>\n`;
table += `<td>${isRight(item) ? prettyShow(item.value.size) : ''}</td>\n`;
table += '</tr>\n';
}
table += ' </tbody>\n';
table += '</table>\n';
return table;
}
示例2: parseHTTPDate
export function parseHTTPDate(str: string): P.Maybe<HttpDate> {
const ret = PS.runParser(rfc1123Date, str);
if (P.isRight(ret)) {
return P.just(ret.value);
}
return P.nothing;
}
示例3: compareFolder
function compareFolder(fa: Either<FolderName, File>, fb: Either<FolderName, File>): 0 | 1 | -1 {
if (isLeft(fa) && isRight(fb)) {
return -1;
}
if (isRight(fa) && isLeft(fb)) {
return 1;
}
if (isLeft(fa) && isLeft(fb)) {
return fa.value < fb.value ? -1 : fa.value === fb.value ? 0 : 1;
}
if (isRight(fa) && isRight(fb)) {
let a = fa.value.name, b = fb.value.name;
return a < b ? -1 : a === b ? 0 : 1;
}
// should never reached here
return 0;
}
示例4: test
test('writing unblocks reads', function* () {
const chan: Q.Chan<number> = yield Q.newChan;
yield T.forkTask(T.apSecond(T.delay(20), Q.writeChan(chan, 1)));
const r: P.Either<void, number> = yield compete(T.delay(50), Q.readChan(chan));
assert.ok(P.isRight(r));
return T.pure(void 0);
});
示例5: attempt
return attempt(task).chain(r => {
if (isRight(r)) return pure(r);
const ret = pred(r.value);
return isJust(ret) ? pure(left(ret.value)) : raise(r.value);
});
示例6: fn
return fn(P.left, P.right, a).chain(res => {
if (P.isRight(res)) {
return Task.of(res.value);
}
return go(res.value);
});
示例7:
function isValidParse<A>(p: PS.Parser<A>, str: string): boolean {
const ret = PS.runParser(parseEof(p), str);
if (P.isRight(ret)) return true;
return false;
}
示例8: parseURIAny
function parseURIAny(p: PS.Parser<URI>, str: string): P.Maybe<URI> {
const ret = PS.runParser(parseEof(p), str);
if (P.isRight(ret)) return P.just(ret.value);
return P.nothing;
}