本文整理汇总了TypeScript中@jonggrang/task.raise函数的典型用法代码示例。如果您正苦于以下问题:TypeScript raise函数的具体用法?TypeScript raise怎么用?TypeScript raise使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了raise函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Error
export function eachObjLim<A, B>(
n: number,
ms: Record<string, A>,
fn: (a: A, i: string) => T.Task<B>
): T.Task<Record<string, B>> {
return n <= 0 ? T.raise(new Error('1 arguments to eachObjLim must be greater than zero'))
: newQSem(n).chain(qsem => eachObjPar(ms, (v, i) => withQSem(qsem, fn(v, i))));
}
示例2: FileInfo
.chain(stat => {
if (stat.isFile()) {
let time = H.fromDate(stat.mtime);
let date = H.formatHttpDate(time);
return T.pure(new FileInfo(path, stat.size, time, date));
}
return T.raise(new Error(`getInfo: ${path} isn't a file`));
});
示例3: Error
return fcache.read.chain(cache => {
const there = HM.lookup(hash, path, cache);
if (isJust(there)) {
const entry = there.value;
return entry.tag === EntryType.NEGATIVE ? T.raise(new Error('FileInfoCache:getAndRegisterInfo'))
: T.pure(entry.finfo);
}
return T.rescue(positive(fcache, hash, path), () => negative(fcache, hash, path));
});
示例4: getSessionImpl
return getSessionImpl(storage, sess.id).chain(oldSess => {
if (oldSess) return T.raise(new SessionAlreadyExists(oldSess, sess));
const sk = storage.sessionKey(sess.id);
let commands: string[][] = [['hmset', sk].concat(printSession(sess))];
// ttl
let ttl = expireSession(sess, storage);
if (ttl !== null) commands.push(ttl);
// auth
if (sess.authId)
commands.push(['sadd', storage.authKey(sess.authId), sk]);
return transaction(commands, storage.redis).map(absurd);
});
示例5: destroy
destroy(sessId: string) {
return T.raise(new TNTExplosion('destroy', { sessId }));
}
示例6: get
get(sessId: string) {
return T.raise(new TNTExplosion('get', { sessId }));
}
示例7: onlyTiny0
function onlyTiny0(ctx: any, file: FileUpload): T.Task<boolean> {
return file.fieldname === 'tiny0' ? T.pure(true) : T.raise(new Error('only tiny0 allowed'));
}
示例8: send
return send(W.responseStream(200, headers, () => T.raise(new Error('should not evaluated'))));
示例9: replace
replace(session: SS.Session) {
return T.raise(new TNTExplosion('replace', session));
}