本文整理汇总了TypeScript中@jonggrang/prelude.isNothing函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNothing函数的具体用法?TypeScript isNothing怎么用?TypeScript isNothing使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNothing函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: uriAuthEquals
function uriAuthEquals(s: P.Maybe<URIAuth>, d: P.Maybe<URIAuth>): boolean {
if (P.isNothing(s) && P.isNothing(d)) return true;
if (P.isJust(s) && P.isJust(d)) {
const sa = s.value;
const da = d.value;
const uriAuth: (keyof URIAuth)[] = ['userInfo', 'port', 'regName'];
return uriAuth.every(x => sa[x] === da[x]);
}
return false;
}
示例2: normalizePathSegments
export function normalizePathSegments(uriStr: string): string {
let juri = parseURI(uriStr);
if (P.isNothing(juri)) return uriStr;
const uriV = juri.value;
let normUri = mkURI(uriV.scheme, uriV.auth, removeDotSegments(uriV.path), uriV.query,
uriV.fragment);
return uriToString(ident, normUri);
}
示例3: maybeGetFd
function maybeGetFd(mfd: MutableFdCache, path: string, hash: number, mentry: P.Maybe<FdEntry>): T.Task<[P.Maybe<number>, Refresh]> {
if (P.isNothing(mentry)) {
return newFdEntry(path)
.chain(entry => mfd.add([hash, entry])
.then(T.pure([P.just(entry.fd), refresh(entry.status)] as [P.Maybe<number>, Refresh])));
}
let fdEntry = mentry.value;
return refresh(fdEntry.status).then(T.pure([P.just(fdEntry.fd), refresh(fdEntry.status)] as [P.Maybe<number>, Refresh]));
}
示例4: sendFile
export function sendFile(
ws: ServerResponse,
fid: FileId,
start: number,
len: number,
hook: T.Task<void>
) {
return len <= 0 ? hook
: P.isNothing(fid.fd) ? sendFilePath(ws, fid.path, partFile(start, len), hook)
: sendFileFd(ws, fid.fd.value, partFile(start, len), hook);
}
示例5: parseRequestBody
export function parseRequestBody(ctx: HttpContext, opts?: MutterOptions): T.Task<[Params, Files]> {
if (!requestHasBody(ctx.request)) return T.pure([{}, {}] as [Params, Files]);
const mctype = getRequestBodyType(ctx.request);
if (isNothing(mctype)) return T.pure([{}, {}] as [Params, Files]);
const { value: ctype } = mctype;
return ctype.tag === 'urlencoded' ? parseUrlEncodedBody(ctx, opts)
: ctype.tag === 'multipart' ? parseMultipartBody(ctx, opts)
: /* istanbul ignore next */ T.pure([{}, {}] as [Params, Files]);
}
示例6: getRequestBodyType
export function getRequestBodyType(req: Request): Maybe<RequestBodyType> {
const parsed = safeParseContentType(req);
if (isNothing(parsed)) return nothing;
const { type, parameters } = parsed.value;
if (type && type.indexOf('multipart') === 0)
return just({ tag: 'multipart', boundary: parameters.boundary || '' } as RequestBodyType);
if (type === 'application/x-www-form-urlencoded')
return just({ tag: 'urlencoded', charset: parameters.charset } as RequestBodyType);
return nothing;
}
示例7: parseRange
function parseRange(rng: string, size: number): RspFileInfo {
const parsed = H.parseByteRanges(rng);
if (P.isNothing(parsed))
return rspFileInfo(RspFileInfoType.WITHOUTBODY, 416);
const rngs = parsed.value;
if (rngs.length === 0)
return rspFileInfo(RspFileInfoType.WITHOUTBODY, 416);
const [beg, end] = checkRange(rngs[0], size);
const len = end - beg + 1;
const st = beg == 0 && end == size - 1 ? 200 : 206;
return rspFileInfo(RspFileInfoType.WITHBODY, st, {}, beg, len);
}
示例8: serveFolder
export function serveFolder(
settings: StaticSettings, pieces: Piece[],
req: IncomingMessage, folder: Folder
): T.Task<StaticResponse> {
if (P.isNothing(settings.listing)) {
return T.pure(waiStaticResponse(W.responseBuffer(403, {
'Content-Type': 'text/plain'
}, Buffer.from('Directory listings disabled'))));
}
if (settings.addTrailingSlash) {
const path = addTrailingSlash(req);
if (path != null) return T.pure({ tag: StaticResponseType.RAWREDIRECT, path: path } as StaticResponse);
}
const listing = settings.listing.value;
return T.pure(waiStaticResponse(W.responseBuffer(200, {
'Content-Type': 'text/html; charset=utf-8'
}, Buffer.from(listing(pieces, folder), 'utf8'))));
}
示例9: isNothing
function applyMaybe<A, B>(ma: Maybe<(_: A) => B>, mb: Maybe<A>): Maybe<B> {
return isNothing(ma) ? nothing : isNothing(mb) ? nothing : just(ma.value(mb.value));
}
示例10: it
it('#searchWith return Nothing if the key is not present', function () {
const mmap = MM.singleton(10, 'ten');
assert.ok(P.isNothing(MM.searchWith(9, P.identity, mmap)));
});