Skip to content

Commit

Permalink
add readFields type overload
Browse files Browse the repository at this point in the history
  • Loading branch information
stepankuzmin committed Aug 20, 2024
1 parent 5e17dd5 commit a9d0a8d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,30 @@ export default class Pbf {

// === READING =================================================================

/**
* @template {string | number} K, V
* @overload
* @param {(tag: number, result: {key: K, value: V}, pbf: Pbf) => void} readField
* @param {{key: K, value: V}} result
* @param {number} [end]
* @returns {Record<K, V>}
*/

/**
* @template T
* @overload
* @param {(tag: number, result: T, pbf: Pbf) => void} readField
* @param {T} result
* @param {number} [end]
* @returns {T}
*/

/**
* @template T
* @param {(tag: number, result: T, pbf: Pbf) => void} readField
* @param {T} result
* @param {number} [end]
* @returns {T}
*/
readFields(readField, result, end = this.length) {
while (this.pos < end) {
Expand Down

0 comments on commit a9d0a8d

Please sign in to comment.