當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript prelude.isNothing函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。