本文整理汇总了TypeScript中@jonggrang/object.assign函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assign函数的具体用法?TypeScript assign怎么用?TypeScript assign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assign函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 }
]));
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:25,代码来源:server-session.ts
示例2: pipeStream
return pipeStream(outStream, source as any).map(() =>
assign(file, {
filename,
size: outStream.bytesWritten,
path: finalPath,
move: handleMove
})
开发者ID:syaiful6,项目名称:jonggrang,代码行数:7,代码来源:disk.ts
示例3: addContentHeaders
function addContentHeaders(hs: H.ResponseHeaders, off: number, len: number, size: number): H.ResponseHeaders {
const hs2 = SM.assign({}, hs, {
'Content-Length': len,
'Accept-Ranges': 'bytes'
});
if (len === size) return hs2;
hs2['Content-Ranges'] = contentRangeHeader(off, off + len - 1, size);
return hs2;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:file.ts
示例4: switch
.chain(srespond => {
switch (srespond.tag) {
case StaticResponseType.FILERESPONSE:
const { file } = srespond;
return ss.getMimeType(file)
.chain(mime => {
const headers = S.assign({}, srespond.headers, {
'Content-Type': mime
});
return sendResponse(file.toResponse(200, headers));
});
case StaticResponseType.NOTMODIFIED:
return sendResponse(W.responseBuffer(304, {}, Buffer.from('')));
case StaticResponseType.SENDCONTENT:
return sendResponse(W.responseReadable(200, {
'Content-Type': srespond.mimeType
}, srespond.readable));
case StaticResponseType.REDIRECT:
const reqQs = url.parse(req.url as string, true).query;
const loc = ss.mkRedirect(srespond.pieces, srespond.pieces.map(encodeURIComponent).join('/'));
const qString =
P.isJust(srespond.hash)
? S.assign({}, reqQs, { etag: srespond.hash.value })
: S.remove('etag', reqQs as any);
const qs = H.renderQuery(qString as any);
return sendResponse(W.responseBuffer(301, {
'Content-Type': 'text/plain',
Location: loc + (qs !== '' ? `?${qs}` : '')
}, Buffer.from('')));
case StaticResponseType.RAWREDIRECT:
return sendResponse(W.responseBuffer(301, {
'Content-Type': 'text/plain',
Location: srespond.path
}, Buffer.from('Redirect')));
case StaticResponseType.NOTFOUND:
if (P.isJust(ss.notFoundHandler)) {
return ss.notFoundHandler.value(ctx, sendResponse);
}
return sendResponse(W.responseBuffer(404, {
'Content-Type': 'text/plain'
}, Buffer.from('File not found')));
case StaticResponseType.WAIRESPONSE:
return sendResponse(srespond.response);
}
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:51,代码来源:static.ts
示例5: rspFileInfo
.chain(efinfo => {
if (isLeft(efinfo)) {
assert.equal(true, false);
return T.pure(false);
}
const { value: finfo } = efinfo;
let hs = S.assign({}, rsp.header, {
'Last-Modified': finfo.date
});
let rsp2 = rspFileInfo(RspFileInfoType.WITHBODY, rsp.status, hs, rsp.offset, rsp.length);
assert.deepEqual(conditionalRequest(finfo, {}, headers), rsp2);
return T.pure(false);
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:14,代码来源:file.test.ts
示例6: cacheControl
export function cacheControl(maxage: MaxAge, headers: H.ResponseHeaders): H.ResponseHeaders {
let cInt: number | null = null;
if (maxage.tag === MaxAgeType.MaxAgeSeconds) {
cInt = maxage.seconds;
}
if (maxage.tag === MaxAgeType.MaxAgeForever) {
cInt = 31536000;
}
let extraHeaders: H.ResponseHeaders = S.assign({}, headers);
if (cInt != null) {
extraHeaders['Cache-Control'] = `public, max-age=${cInt}`;
}
if (maxage.tag === MaxAgeType.MaxAgeForever) {
extraHeaders['Expires'] = 'Thu, 31 Dec 2037 23:55:55 GMT';
}
return extraHeaders;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:18,代码来源:static.ts
示例7: removePlaceholder
T.runTask(storage.handleFile(file, filestream as any), (err, finfo) => {
// sometimes the limit event was fired before we attach the listener
// so, check the truncated property here
if ((filestream as any).truncated && !aborting) filestream.emit('limit');
if (aborting) {
removePlaceholder(files, placeholder);
uploadedFiles.push(assign(file, finfo || {}) as any);
return pendingWrites.decrement();
}
if (err) {
removePlaceholder(files, placeholder);
pendingWrites.decrement();
return abortWithError(err);
}
replacePlaceholder(files, placeholder, finfo as any);
uploadedFiles.push(finfo as any);
pendingWrites.decrement();
indicateDone();
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:22,代码来源:parser.ts
示例8: getBuffer
return getBuffer(source).map(buffer =>
assign(file, {
buffer,
size: buffer.length,
move: writeFile
})
开发者ID:syaiful6,项目名称:jonggrang,代码行数:6,代码来源:memory.ts
示例9: sendResponse
.chain(mime => {
const headers = S.assign({}, srespond.headers, {
'Content-Type': mime
});
return sendResponse(file.toResponse(200, headers));
});
开发者ID:syaiful6,项目名称:jonggrang,代码行数:6,代码来源:static.ts
注:本文中的@jonggrang/object.assign函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论