本文整理汇总了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;未经允许,请勿转载。 |
请发表评论