Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 672af9a

Browse files
committed
add return types to functions
1 parent eefe14f commit 672af9a

File tree

1 file changed

+45
-47
lines changed

1 file changed

+45
-47
lines changed

src/Layout.ts

+45-47
Original file line numberDiff line numberDiff line change
@@ -2478,159 +2478,157 @@ export class Constant<T> extends Layout<T> {
24782478
}
24792479

24802480
/** Factory for {@link GreedyCount}. */
2481-
export const greedy = ((elementSpan: number, property?: string) => new GreedyCount(elementSpan, property));
2481+
export const greedy = ((elementSpan: number, property?: string): GreedyCount => new GreedyCount(elementSpan, property));
24822482

24832483
/** Factory for {@link OffsetLayout}. */
2484-
export const offset
2485-
= ((layout: Layout<number>, offset?: number, property?: string) => new OffsetLayout(layout, offset, property));
2484+
export const offset = ((layout: Layout<number>, offset?: number, property?: string): OffsetLayout =>
2485+
new OffsetLayout(layout, offset, property));
24862486

24872487
/** Factory for {@link UInt|unsigned int layouts} spanning one
24882488
* byte. */
2489-
export const u8 = ((property?: string) => new UInt(1, property));
2489+
export const u8 = ((property?: string): UInt => new UInt(1, property));
24902490

24912491
/** Factory for {@link UInt|little-endian unsigned int layouts}
24922492
* spanning two bytes. */
2493-
export const u16 = ((property?: string) => new UInt(2, property));
2493+
export const u16 = ((property?: string): UInt => new UInt(2, property));
24942494

24952495
/** Factory for {@link UInt|little-endian unsigned int layouts}
24962496
* spanning three bytes. */
2497-
export const u24 = ((property?: string) => new UInt(3, property));
2497+
export const u24 = ((property?: string): UInt => new UInt(3, property));
24982498

24992499
/** Factory for {@link UInt|little-endian unsigned int layouts}
25002500
* spanning four bytes. */
2501-
export const u32 = ((property?: string) => new UInt(4, property));
2501+
export const u32 = ((property?: string): UInt => new UInt(4, property));
25022502

25032503
/** Factory for {@link UInt|little-endian unsigned int layouts}
25042504
* spanning five bytes. */
2505-
export const u40 = ((property?: string) => new UInt(5, property));
2505+
export const u40 = ((property?: string): UInt => new UInt(5, property));
25062506

25072507
/** Factory for {@link UInt|little-endian unsigned int layouts}
25082508
* spanning six bytes. */
2509-
export const u48 = ((property?: string) => new UInt(6, property));
2509+
export const u48 = ((property?: string): UInt => new UInt(6, property));
25102510

25112511
/** Factory for {@link NearUInt64|little-endian unsigned int
25122512
* layouts} interpreted as Numbers. */
2513-
export const nu64 = ((property?: string) => new NearUInt64(property));
2513+
export const nu64 = ((property?: string): NearUInt64 => new NearUInt64(property));
25142514

25152515
/** Factory for {@link UInt|big-endian unsigned int layouts}
25162516
* spanning two bytes. */
2517-
export const u16be = ((property?: string) => new UIntBE(2, property));
2517+
export const u16be = ((property?: string): UIntBE => new UIntBE(2, property));
25182518

25192519
/** Factory for {@link UInt|big-endian unsigned int layouts}
25202520
* spanning three bytes. */
2521-
export const u24be = ((property?: string) => new UIntBE(3, property));
2521+
export const u24be = ((property?: string): UIntBE => new UIntBE(3, property));
25222522

25232523
/** Factory for {@link UInt|big-endian unsigned int layouts}
25242524
* spanning four bytes. */
2525-
export const u32be = ((property?: string) => new UIntBE(4, property));
2525+
export const u32be = ((property?: string): UIntBE => new UIntBE(4, property));
25262526

25272527
/** Factory for {@link UInt|big-endian unsigned int layouts}
25282528
* spanning five bytes. */
2529-
export const u40be = ((property?: string) => new UIntBE(5, property));
2529+
export const u40be = ((property?: string): UIntBE => new UIntBE(5, property));
25302530

25312531
/** Factory for {@link UInt|big-endian unsigned int layouts}
25322532
* spanning six bytes. */
2533-
export const u48be = ((property?: string) => new UIntBE(6, property));
2533+
export const u48be = ((property?: string): UIntBE => new UIntBE(6, property));
25342534

25352535
/** Factory for {@link NearUInt64BE|big-endian unsigned int
25362536
* layouts} interpreted as Numbers. */
2537-
export const nu64be = ((property?: string) => new NearUInt64BE(property));
2537+
export const nu64be = ((property?: string): NearUInt64BE => new NearUInt64BE(property));
25382538

25392539
/** Factory for {@link Int|signed int layouts} spanning one
25402540
* byte. */
2541-
export const s8 = ((property?: string) => new Int(1, property));
2541+
export const s8 = ((property?: string): Int => new Int(1, property));
25422542

25432543
/** Factory for {@link Int|little-endian signed int layouts}
25442544
* spanning two bytes. */
2545-
export const s16 = ((property?: string) => new Int(2, property));
2545+
export const s16 = ((property?: string): Int => new Int(2, property));
25462546

25472547
/** Factory for {@link Int|little-endian signed int layouts}
25482548
* spanning three bytes. */
2549-
export const s24 = ((property?: string) => new Int(3, property));
2549+
export const s24 = ((property?: string): Int => new Int(3, property));
25502550

25512551
/** Factory for {@link Int|little-endian signed int layouts}
25522552
* spanning four bytes. */
2553-
export const s32 = ((property?: string) => new Int(4, property));
2553+
export const s32 = ((property?: string): Int => new Int(4, property));
25542554

25552555
/** Factory for {@link Int|little-endian signed int layouts}
25562556
* spanning five bytes. */
2557-
export const s40 = ((property?: string) => new Int(5, property));
2557+
export const s40 = ((property?: string): Int => new Int(5, property));
25582558

25592559
/** Factory for {@link Int|little-endian signed int layouts}
25602560
* spanning six bytes. */
2561-
export const s48 = ((property?: string) => new Int(6, property));
2561+
export const s48 = ((property?: string): Int => new Int(6, property));
25622562

25632563
/** Factory for {@link NearInt64|little-endian signed int layouts}
25642564
* interpreted as Numbers. */
2565-
export const ns64 = ((property?: string) => new NearInt64(property));
2565+
export const ns64 = ((property?: string): NearInt64 => new NearInt64(property));
25662566

25672567
/** Factory for {@link Int|big-endian signed int layouts}
25682568
* spanning two bytes. */
2569-
export const s16be = ((property?: string) => new IntBE(2, property));
2569+
export const s16be = ((property?: string): IntBE => new IntBE(2, property));
25702570

25712571
/** Factory for {@link Int|big-endian signed int layouts}
25722572
* spanning three bytes. */
2573-
export const s24be = ((property?: string) => new IntBE(3, property));
2573+
export const s24be = ((property?: string): IntBE => new IntBE(3, property));
25742574

25752575
/** Factory for {@link Int|big-endian signed int layouts}
25762576
* spanning four bytes. */
2577-
export const s32be = ((property?: string) => new IntBE(4, property));
2577+
export const s32be = ((property?: string): IntBE => new IntBE(4, property));
25782578

25792579
/** Factory for {@link Int|big-endian signed int layouts}
25802580
* spanning five bytes. */
2581-
export const s40be = ((property?: string) => new IntBE(5, property));
2581+
export const s40be = ((property?: string): IntBE => new IntBE(5, property));
25822582

25832583
/** Factory for {@link Int|big-endian signed int layouts}
25842584
* spanning six bytes. */
2585-
export const s48be = ((property?: string) => new IntBE(6, property));
2585+
export const s48be = ((property?: string): IntBE => new IntBE(6, property));
25862586

25872587
/** Factory for {@link NearInt64BE|big-endian signed int layouts}
25882588
* interpreted as Numbers. */
2589-
export const ns64be = ((property?: string) => new NearInt64BE(property));
2589+
export const ns64be = ((property?: string): NearInt64BE => new NearInt64BE(property));
25902590

25912591
/** Factory for {@link Float|little-endian 32-bit floating point} values. */
2592-
export const f32 = ((property?: string) => new Float(property));
2592+
export const f32 = ((property?: string): Float => new Float(property));
25932593

25942594
/** Factory for {@link FloatBE|big-endian 32-bit floating point} values. */
2595-
export const f32be = ((property?: string) => new FloatBE(property));
2595+
export const f32be = ((property?: string): FloatBE => new FloatBE(property));
25962596

25972597
/** Factory for {@link Double|little-endian 64-bit floating point} values. */
2598-
export const f64 = ((property?: string) => new Double(property));
2598+
export const f64 = ((property?: string): Double => new Double(property));
25992599

26002600
/** Factory for {@link DoubleBE|big-endian 64-bit floating point} values. */
2601-
export const f64be = ((property?: string) => new DoubleBE(property));
2601+
export const f64be = ((property?: string): DoubleBE => new DoubleBE(property));
26022602

26032603
/** Factory for {@link Structure} values. */
2604-
export const struct
2605-
= (<T>(fields: Layout<T[keyof T]>[], property?: string, decodePrefixes?: boolean) =>
2604+
export const struct = (<T>(fields: Layout<T[keyof T]>[], property?: string, decodePrefixes?: boolean): Structure<T> =>
26062605
new Structure<T>(fields, property, decodePrefixes));
26072606

26082607
/** Factory for {@link BitStructure} values. */
2609-
export const bits
2610-
= ((word: UInt | UIntBE, msb: boolean | string, property?: string) => new BitStructure(word, msb, property));
2608+
export const bits = ((word: UInt | UIntBE, msb: boolean | string, property?: string): BitStructure =>
2609+
new BitStructure(word, msb, property));
26112610

26122611
/** Factory for {@link Sequence} values. */
2613-
export const seq
2614-
= (<T>(elementLayout: Layout<T>, count: number | ExternalLayout, property?: string) =>
2612+
export const seq = (<T>(elementLayout: Layout<T>, count: number | ExternalLayout, property?: string): Sequence<T> =>
26152613
new Sequence<T>(elementLayout, count, property));
26162614

26172615
/** Factory for {@link Union} values. */
2618-
export const union
2619-
= ((discr: Layout<LayoutObject> | UnionDiscriminator, defaultLayout: Layout<LayoutObject> | null, property: string) =>
2616+
export const union = ((discr: Layout<LayoutObject> | UnionDiscriminator,
2617+
defaultLayout: Layout<LayoutObject> | null, property: string): Union =>
26202618
new Union(discr, defaultLayout, property));
26212619

26222620
/** Factory for {@link UnionLayoutDiscriminator} values. */
2623-
export const unionLayoutDiscriminator
2624-
= ((layout: ExternalLayout, property: string) => new UnionLayoutDiscriminator(layout, property));
2621+
export const unionLayoutDiscriminator = ((layout: ExternalLayout, property: string): UnionLayoutDiscriminator =>
2622+
new UnionLayoutDiscriminator(layout, property));
26252623

26262624
/** Factory for {@link Blob} values. */
2627-
export const blob = ((length: number | ExternalLayout, property?: string) => new Blob(length, property));
2625+
export const blob = ((length: number | ExternalLayout, property?: string): Blob => new Blob(length, property));
26282626

26292627
/** Factory for {@link CString} values. */
2630-
export const cstr = ((property?: string) => new CString(property));
2628+
export const cstr = ((property?: string): CString => new CString(property));
26312629

26322630
/** Factory for {@link UTF8} values. */
2633-
export const utf8 = ((maxSpan: number, property?: string) => new UTF8(maxSpan, property));
2631+
export const utf8 = ((maxSpan: number, property?: string): UTF8 => new UTF8(maxSpan, property));
26342632

26352633
/** Factory for {@link Constant} values. */
2636-
export const constant = (<T>(value: T, property?: string) => new Constant(value, property));
2634+
export const constant = (<T>(value: T, property?: string): Constant<T> => new Constant(value, property));

0 commit comments

Comments
 (0)