本文整理匯總了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);
}