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


TypeScript parsing.char函數代碼示例

本文整理匯總了TypeScript中@jonggrang/parsing.char函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript char函數的具體用法?TypeScript char怎麽用?TypeScript char使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了char函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

export const uri: PS.Parser<URI> = PS.co(function* () {
  const us: string = yield PS.attempt(uscheme);
  const [ua, up]: [Maybe<URIAuth>, string] = yield hierPart;
  const uq: string = yield PS.option('', PS.char('?').chain(() => uquery));
  const uf: string = yield PS.option('', PS.char('#').chain(() => ufragment));
  return PS.pure(mkURI(us, ua, up, uq, uf));
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:7,代碼來源:parsing.ts

示例2: notMatching

export const relativeRef: PS.Parser<URI> = PS.co(function* () {
  yield notMatching(uscheme);
  const [ua, path]: [Maybe<URIAuth>, string] = yield relativePart;
  const uq: string = yield PS.option('', PS.char('?').chain(() => uquery));
  const uf: string = yield PS.option('', PS.char('#').chain(() => ufragment));
  return PS.pure(mkURI('', ua, path, uq, uf));
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:7,代碼來源:parsing.ts

示例3: notFollowedBy

const ipv4address: PS.Parser<string> = PS.co(function* () {
  const a1: string = yield decOctet;
  yield PS.char('.');
  const a2: string = yield decOctet;
  yield PS.char('.');
  const a3: string = yield decOctet;
  yield PS.char('.');
  const a4: string = yield decOctet;
  yield notFollowedBy(nameChar);
  return PS.pure(`${a1}.${a2}.${a3}.${a4}`);
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:11,代碼來源:parsing.ts

示例4: digits

const time: PS.Parser<[number, number, number]> = PS.co(function* () {
  let h = yield digits(2, 2);
  yield PS.char(':');
  let m = yield digits(2, 2);
  // the seconds fields is optional
  let s = yield PS.option(0, PS.attempt(PS.char(':').chain(() => digits(2, 2))));

  if (h > 23 || m > 59 || s > 59) {
    return PS.fail('hour, minute and seconds must be in valid range');
  }
  return PS.pure([h, m, s]);
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:12,代碼來源:date.ts

示例5: oneThenMany

const uscheme: PS.Parser<string> = PS.co(function* () {
  const s: string = yield oneThenMany(PS.anyLetter, PS.satisfy(isSchemeChar)).map(joinStr);
  yield PS.char(':');
  return PS.pure(s + ':');
});
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:5,代碼來源:parsing.ts


注:本文中的@jonggrang/parsing.char函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。