mirror of
https://github.com/fluencelabs/libp2p-ts
synced 2025-03-16 18:20:50 +00:00
Add varint package
This commit is contained in:
parent
c028bcabac
commit
836c350f37
31
types/varint/index.d.ts
vendored
Normal file
31
types/varint/index.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Type definitions for varint 5.0.0
|
||||
// Project: https://github.com/chrisdickinson/varint
|
||||
// Definitions by: Jaco Greeff <https://github.com/jacogr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
declare module 'varint' {
|
||||
type VarintDecode = {
|
||||
(data: Buffer, offset?: number): number,
|
||||
|
||||
readonly bytes: number
|
||||
}
|
||||
|
||||
type VarintEncode = {
|
||||
(num: number, buf?: Buffer, offset?: number): Buffer,
|
||||
|
||||
readonly bytes: number
|
||||
}
|
||||
|
||||
interface Varint {
|
||||
readonly decode: VarintDecode;
|
||||
readonly encode: VarintEncode;
|
||||
|
||||
encodingLength (num: number): number;
|
||||
}
|
||||
|
||||
const varint: Varint;
|
||||
|
||||
export default varint;
|
||||
}
|
16
types/varint/tsconfig.json
Normal file
16
types/varint/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "bn.js-tests.ts"]
|
||||
}
|
1
types/varint/tslint.json
Normal file
1
types/varint/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
8
types/varint/varint-tests.ts
Normal file
8
types/varint/varint-tests.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// @ts-ignore
|
||||
import varint from 'varint';
|
||||
|
||||
varint.encode(300);
|
||||
varint.encode.bytes;
|
||||
|
||||
varint.decode(Buffer.from([0xa7, 0x02]));
|
||||
varint.decode.bytes;
|
Loading…
x
Reference in New Issue
Block a user