本文整理汇总了TypeScript中@jonggrang/prelude.list类的典型用法代码示例。如果您正苦于以下问题:TypeScript list类的具体用法?TypeScript list怎么用?TypeScript list使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了list类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
function listForInPar_<A, B>(xs: P.list.List<A>, fn: (_: A) => T.Task<B>): T.Task<void> {
return P.list.foldr((a, b) => T.apSecond(fn(a).parallel(), b), T.Parallel.of(void 0), xs).sequential();
}
示例2: getMockOperation
it('saveSession can replace old session with new one', async function () {
const storage = await T.toPromise(emptyMockStorage);
const state = SS.createServerSessionState(storage);
const m1 = { a: 'b' };
const sess1 = await T.toPromise(SS.saveSession(state, { sess: null, now: fakenow }, m1));
const m2 = SO.insert(state.authKey, 'John', m1);
const sess2 = await T.toPromise(SS.saveSession(state, { sess: sess1, now: fakenow }, m2));
const m3 = SO.insert(SS.forceInvalidateKey, SS.ForceInvalidate.ALL_SESSION_IDS_OF_LOGGED_USER, m2 as any);
const sess3 = await T.toPromise(SS.saveSession(state, { sess: sess2, now: fakenow }, m3));
await getMockOperation(storage);
const m4 = SO.insert('x', 'y', m2);
const sess4 = await T.toPromise(SS.saveSession(state, { sess: sess3, now: fakenow }, m4));
assert.deepEqual(sess4, SO.assign({}, sess3, { data: SO.remove(state.authKey, m4) }));
const op = await getMockOperation(storage);
assert.deepEqual(op, L.fromArray([
{ tag: 'replace', session: sess4 }
]));
});
示例3: go
function go(xs: L.List<[number, L.List<A>]>, acc: L.List<[number, L.List<A>]>): T.Task<L.List<[number, L.List<A>]>> {
if (L.isEmpty(xs)) return T.pure(acc);
const [k, s] = xs.head;
return prune(s, f).chain(mt =>
isNothing(mt) ? go(xs.tail, acc)
/* otherwise */ : go(xs.tail, L.cons([k, mt.value] as [number, L.List<A>], acc)));
}
示例4: it
it('saveSession can create new session', async function () {
const storage = await T.toPromise(emptyMockStorage);
const state = SS.createServerSessionState(storage);
const m1 = { a: 'b' };
const session = await T.toPromise(SS.saveSession(state, { sess: null, now: fakenow }, m1));
assert.ok(session != null);
assert.equal((session as any).authId, null);
assert.deepEqual((session as any).data, m1);
const op = await getMockOperation(storage);
assert.deepEqual(op, L.singleton({ session, tag: 'insert' }));
});
示例5:
return L.concat(I.foldrWithKey((_, v, xs) => L.cons(v, xs), L.nil, m));
示例6: sepEndBy
return p.chain(a =>
sep.chain(() => sepEndBy(p, sep).map(as => L.cons(a, as)))
.alt(Parser.of(L.singleton(a)))
示例7: many
return p.chain(head => many(p).map(xs => L.cons(head, xs)));
示例8: just
function nel<A>(xs: L.List<A>): Maybe<L.List<A>> {
return L.isEmpty(xs) ? nothing : just(xs);
}