Skip to content

Commit

Permalink
Merge pull request #6 from mstar-kk/master
Browse files Browse the repository at this point in the history
Add type definitions file index.d.ts
  • Loading branch information
T-PWK authored Jan 4, 2022
2 parents 4fc39c9 + 621bfb9 commit 81c4c41
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
coverage/
node_modules
44 changes: 44 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Type definitions for biguint-format
// Project: biguint-format https://github.com/T-PWK/flake-idgen
// Definitions by: m-star https://github.com/mstar-kk

/// <reference types="node" />

interface FORMATS {
dec: typeof toDecimalString;
hex: typeof toHexString;
bin: typeof toBinaryString;
oct: typeof toOctetString;
}

interface formatOption {
format?: string;
groupsize?: number;
delimiter?: string;
padstr?: string;
size?: number;
trim?: boolean;
prefix?: string;
}

export default function (
buffer: Buffer,
base: 'dec' | 'hex' | 'bin' | 'oct',
options?: formatOption
): string;

export function createBuffer(size: number): Buffer;

export function createBufferFrom(object: object): Buffer;

export function toDecimalString(buffer: Buffer, options?: formatOption): string;

export function toBinaryString(buffer: Buffer, options?: formatOption): string;

/*
* Converts given input (node Buffer or array of bytes) to hexadecimal string 0xDDDD where D is [0-9a-f].
* All leading 0's are stripped out i.e. [0x00, 0x00, 0x00, 0x01] -> '0x1'
*/
export function toHexString(buffer: Buffer, options?: formatOption): string;

export function toOctetString(buffer: Buffer, options?: formatOption): string;
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
],
"bugs": {
"url": "https://github.com/T-PWK/biguint-format/issues"
},
"devDependencies": {
"@types/node": "^16.7.10"
}
}

0 comments on commit 81c4c41

Please sign in to comment.