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


TypeScript long.fromString函數代碼示例

本文整理匯總了TypeScript中long.fromString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromString函數的具體用法?TypeScript fromString怎麽用?TypeScript fromString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fromString函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should decode transportPeers as expected', () => {
   const obj = {
     peers: [
       {
         ip: '127.0.0.1',
         port: 5555,
         state: 2,
         os: 'linux',
         version: '1.1.1',
         broadhash: '123124125152asdadf',
         height: 5,
         clock: 86400,
         updated: Long.fromString('10', true),
         nonce: 'nonce1',
       },
       {
         ip: '127.0.0.2',
         port: 5535,
         state: 3,
         os: 'ubuntu',
         version: '1.0.1',
         broadhash: 'asdadf1342352352352',
         height: 5,
         clock: 865600,
         updated: Long.fromString('12', true),
         nonce: 'nonce2',
       },
     ],
   };
   const buf = Buffer.from('0a420a093132372e302e302e3110b32b180222056c696e75782a05312e312e31321231323331323431323531353261736461646638054080a305480a52066e6f6e6365310a440a093132372e302e302e32109f2b180322067562756e74752a05312e302e31321361736461646631333432333532333532333532380540c0ea34480c52066e6f6e636532', 'hex');
   const out = instance.decodeToObj(buf, 'transportPeers');
   expect(out).to.be.deep.equal(obj);
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:33,代碼來源:protobuf.spec.ts

示例2: it

 it('should call encode passing an object with the property signatures, of buffers and BigNum', async () => {
   result = await instance.signatures();
   expect(protoBufStub.stubs.encode.called).true;
   expect(protoBufStub.stubs.encode.firstCall.args)
     .deep.eq([
     {
       signatures: [
         {
           signatures: [Buffer.from('01', 'hex'), Buffer.from('02', 'hex'), Buffer.from('03', 'hex')],
           transaction: Long.fromString('100'),
         },
         {
           signatures: [Buffer.from('04', 'hex'), Buffer.from('05', 'hex'), Buffer.from('06', 'hex')],
           transaction: Long.fromString('102'),
         },
       ],
     },
     'transportSignatures', 'getSignaturesResponse']);
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:19,代碼來源:transportV2API.spec.ts

示例3: it

    it('converts IntegerValue', () => {
      const examples = [
        types.MIN_SAFE_INTEGER,
        -100,
        -1,
        0,
        1,
        100,
        types.MAX_SAFE_INTEGER
      ];
      for (const example of examples) {
        const obj = s.toValue(new fieldValue.IntegerValue(example));
        expect(obj).to.deep.equal({ integerValue: '' + example });

        const longVal = Long.fromString(example.toString(), false);
        expectValue(obj, 'integerValue').to.deep.equal(
          longVal,
          'for integer ' + example
        );
      }
    });
開發者ID:RameshBhupathi,項目名稱:firebase-js-sdk,代碼行數:21,代碼來源:serializer.test.ts

示例4:

'use strict'
// **Github:** https://github.com/fidm/quic
//
// **License:** MIT

// https://github.com/dcodeIO/long.js/pull/60
import Long from 'long'

// http://isthe.com/chongo/tech/comp/fnv/#FNV-param
const fnvOffset64 = Long.fromString('14695981039346656037', true, 10)
const fnvPrime64 = Long.fromString('1099511628211', true, 10)
export function fnv1a64Hash (data: Buffer, le: boolean): Buffer {
  let hash = Long.fromBits(fnvOffset64.getLowBits(), fnvOffset64.getHighBits(), true)
  for (const bit of data) {
    hash = hash.xor(bit)
    hash = hash.mul(fnvPrime64)
  }
  return Buffer.from(hash.toBytes(le))
}

export class SecureContext {
}

export class SourceToken {
}
開發者ID:toajs,項目名稱:quic,代碼行數:25,代碼來源:crypto.ts

示例5: steamID_64_ToAccountID

export function steamID_64_ToAccountID(steamID64: string) {
    let steamID_64_Identifier = long.fromString("0110000100000000", true, 16);
    let longValue = long.fromValue(steamID64).subtract(steamID_64_Identifier);
    return longValue.toString();
}
開發者ID:kencinder,項目名稱:steam-rom-manager,代碼行數:5,代碼來源:steam-id-64-to-account-id.ts


注:本文中的long.fromString函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。