本文整理汇总了TypeScript中@jonggrang/parsing.pure函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pure函数的具体用法?TypeScript pure怎么用?TypeScript pure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pure函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: optNH4cH4
}))).alt(PS.attempt(PS.co(function* () {
const a1: string = yield optNH4cH4(3);
yield PS.string('::');
const a2: string = yield h4c;
const a3: string = yield ls32;
return PS.pure(`${a1}::${a2}${a3}`);
}))).alt(PS.attempt(PS.co(function* () {
开发者ID:syaiful6,项目名称:jonggrang,代码行数:7,代码来源:parsing.ts
示例3: 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
示例4: countMinMax
function countMinMax<A>(m: number, n: number, p: PS.Parser<A>): PS.Parser<L.List<A>> {
if (m > 0) {
return p.chain(x => countMinMax(m - 1, n - 1, p).map(ar => L.cons(x, ar)));
} else if (n <= 0) {
return PS.pure(L.nil);
}
return PS.option(L.nil, p.chain(x => countMinMax(0, n - 1, p).map(ar => L.cons(x, ar))));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:parsing.ts
示例5: go
function go(idx: number, n: number): PS.Parser<B[]> {
switch (n) {
case 0: return PS.pure([]);
case 2: return f(xs[idx]).map(pair).ap(f(xs[idx + 1]));
default:
let m = Math.floor(n / 4) * 2;
return go(idx, m).map(concatArr).ap(go(idx + m, n - m));
}
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:parsing.ts
示例6: 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
示例7: 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
示例8: Date
const rfc1123Date: PS.Parser<HttpDate> = PS.co(function *() {
yield PS.optional(weekDay.chain(() => PS.string(', ')));
const [y, m, d]: [number, Month, Day] = yield date;
yield PS.optional(PS.whiteSpace);
const [h, n, s]: [number, number, number] = yield time;
yield PS.optional(PS.whiteSpace);
// RFC 2616 defines GMT only but there are actually ill-formed ones such
// as "+0000" and "UTC" in the wild.
yield PS.string('GMT').alt(PS.string('+0000')).alt(PS.string('UTC'));
return PS.pure(fromDate(new Date(Date.UTC(y, m, d, h, n, s))));
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:12,代码来源:date.ts
注:本文中的@jonggrang/parsing.pure函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论