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