本文整理汇总了TypeScript中@jonggrang/object.insert函数的典型用法代码示例。如果您正苦于以下问题:TypeScript insert函数的具体用法?TypeScript insert怎么用?TypeScript insert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
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 }
]));
});
示例2:
return RV.modifyRef_(this.sessions, oldMap => {
if (sess.id in oldMap) return [oldMap, T.raise(new SS.SessionAlreadyExists(oldMap[sess.id], sess))];
return [SO.insert(sess.id, sess, oldMap), T.pure(void 0)];
})
示例3: recomposeSession
/**
* Recompose a decomposed session again
*/
function recomposeSession(authKey: string, authId: string | null, sess: SessionData): SessionData {
return authId == null ? sess : insert(authKey, authId, sess);
}