本文整理汇总了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;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:10,代码来源:index.ts
示例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);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:index.ts
示例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]));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:fd-cache.ts
示例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);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:11,代码来源:send-stream.ts
示例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]);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:13,代码来源:parser.ts
示例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;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:14,代码来源:parser.ts
示例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);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:14,代码来源:file.ts
示例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'))));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:20,代码来源:static.ts
示例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));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:3,代码来源:auto-update.ts
示例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)));
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:4,代码来源:container.test.ts
注:本文中的@jonggrang/prelude.isNothing函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论