本文整理匯總了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;
}