當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript object.assign函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。