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