Skip to content

Commit

Permalink
feat: get span value
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Mar 8, 2022
1 parent c9ca203 commit db8b8e6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ export function makeSpan<Length extends number>(value: number, length?: Length):

return span as Bytes<Length>
}

export function getSpanValue<Length extends number = 8>(span: Span<Length>): number {
const dataView = new DataView(span.buffer)

return dataView.getUint32(0, true)
}

0 comments on commit db8b8e6

Please sign in to comment.