Skip to content

Commit f1b7e24

Browse files
committed
Fix typo (endianess -> endianness)
1 parent e776857 commit f1b7e24

File tree

9 files changed

+37
-33
lines changed

9 files changed

+37
-33
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Parser = require("binary-parser").Parser;
4444

4545
// Build an IP packet header Parser
4646
const ipHeader = new Parser()
47-
.endianess("big")
47+
.endianness("big")
4848
.bit4("version")
4949
.bit4("headerLength")
5050
.uint8("tos")
@@ -329,17 +329,17 @@ Move the buffer offset for `relOffset` bytes from the current position. Use a
329329
negative `relOffset` value to rewind the offset. This method was previously
330330
named `skip(length)`.
331331

332-
### endianess(endianess)
333-
Define what endianess to use in this parser. `endianess` can be either
334-
`"little"` or `"big"`. The default endianess of `Parser` is set to big-endian.
332+
### endianness(endianness)
333+
Define what endianness to use in this parser. `endianness` can be either
334+
`"little"` or `"big"`. The default endianness of `Parser` is set to big-endian.
335335

336336
```javascript
337337
const parser = new Parser()
338-
.endianess("little")
339-
// You can specify endianess explicitly
338+
.endianness("little")
339+
// You can specify endianness explicitly
340340
.uint16be("a")
341341
.uint32le("a")
342-
// Or you can omit endianess (in this case, little-endian is used)
342+
// Or you can omit endianness (in this case, little-endian is used)
343343
.uint16("b")
344344
.int32("c");
345345
```
@@ -518,7 +518,7 @@ These options can be used in all parsers.
518518
```javascript
519519
// simple maginc number validation
520520
const ClassFile = Parser.start()
521-
.endianess("big")
521+
.endianness("big")
522522
.uint32("magic", { assert: 0xcafebabe });
523523

524524
// Doing more complex assertion with a predicate function

example/bmp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Parser } from "../lib/binary_parser";
1212
// DWORD bfOffBits;
1313
// } BITMAPFILEHEADER, *PBITMAPFILEHEADER;
1414
const bmpFileHeader = new Parser()
15-
.endianess("little")
15+
.endianness("little")
1616
.string("type", {
1717
length: 2,
1818
assert: "BM",
@@ -37,7 +37,7 @@ const bmpFileHeader = new Parser()
3737
// DWORD biClrImportant;
3838
// } BITMAPINFOHEADER;
3939
const bmpInfoHeader = new Parser()
40-
.endianess("little")
40+
.endianness("little")
4141
.uint32("size")
4242
.int32("width")
4343
.int32("height")

example/classfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const CpInfo = Parser.start()
7373
});
7474

7575
const ClassFile = Parser.start()
76-
.endianess("big")
76+
.endianness("big")
7777
.uint32("magic", { assert: 0xcafebabe })
7878
.uint16("minor_version")
7979
.uint16("major_version")

example/elf32.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { inspect } from "util";
55
import { Parser } from "../lib/binary_parser";
66

77
const ELF32ProgramHeader = new Parser()
8-
.endianess("little")
8+
.endianness("little")
99
.uint32("type")
1010
.uint32("offset")
1111
.uint32("vaddr")
@@ -23,7 +23,7 @@ const ELF32ProgramHeaderTable = new Parser().array("items", {
2323
});
2424

2525
const ELF32SectionHeader = new Parser()
26-
.endianess("little")
26+
.endianness("little")
2727
.uint32("name")
2828
.uint32("type")
2929
.uint32("flags")
@@ -51,7 +51,7 @@ const ELF32SectionHeaderStringTable = new Parser().seek(1).array("items", {
5151
});
5252

5353
const ELF32Header = new Parser()
54-
.endianess("little")
54+
.endianness("little")
5555
.buffer("ident", { length: 16 })
5656
.uint16("type")
5757
.uint16("machine")

example/ip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Parser } from "../lib/binary_parser";
22

33
const ipHeader = new Parser()
4-
.endianess("big")
4+
.endianness("big")
55
.bit4("version")
66
.bit4("headerLength")
77
.uint8("tos")

example/jpg.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SOI = Parser.start();
99
const EOI = Parser.start();
1010

1111
const APP0 = Parser.start()
12-
.endianess("big")
12+
.endianness("big")
1313
.uint16("length")
1414
.string("id", {
1515
encoding: "ascii",
@@ -31,7 +31,7 @@ const APP0 = Parser.start()
3131

3232
// @ts-ignore
3333
const COM = Parser.start()
34-
.endianess("big")
34+
.endianness("big")
3535
.uint16("length")
3636
.string("comment", {
3737
encoding: "ascii",
@@ -41,7 +41,7 @@ const COM = Parser.start()
4141
});
4242

4343
const SOS = Parser.start()
44-
.endianess("big")
44+
.endianness("big")
4545
.uint16("length")
4646
.uint8("componentCount")
4747
.array("components", {
@@ -53,7 +53,7 @@ const SOS = Parser.start()
5353
.uint8("spectrumSelect");
5454

5555
const DQT = Parser.start()
56-
.endianess("big")
56+
.endianness("big")
5757
.uint16("length")
5858
.array("tables", {
5959
type: Parser.start().uint8("precisionAndTableId").array("table", {
@@ -66,7 +66,7 @@ const DQT = Parser.start()
6666
});
6767

6868
const SOF0 = Parser.start()
69-
.endianess("big")
69+
.endianness("big")
7070
.uint16("length")
7171
.uint8("precision")
7272
.uint16("width")
@@ -81,14 +81,14 @@ const SOF0 = Parser.start()
8181
});
8282

8383
const Ignore = Parser.start()
84-
.endianess("big")
84+
.endianness("big")
8585
.uint16("length")
8686
.seek(function (this: any) {
8787
return this.length - 2;
8888
});
8989

9090
const Segment = Parser.start()
91-
.endianess("big")
91+
.endianness("big")
9292
.uint16("marker")
9393
.choice("segment", {
9494
tag: "marker",

example/tcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Parser } from "../lib/binary_parser";
22

33
const tcpHeader = new Parser()
4-
.endianess("big")
4+
.endianness("big")
55
.uint16("srcPort")
66
.uint16("dstPort")
77
.uint32("seq")

lib/binary_parser.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type ComplexTypes =
145145
| "wrapper"
146146
| "";
147147

148-
type Endianess = "be" | "le";
148+
type Endianness = "be" | "le";
149149

150150
type PrimitiveTypes =
151151
| "uint8"
@@ -281,7 +281,7 @@ export class Parser {
281281
next?: Parser;
282282
head?: Parser;
283283
compiled?: Function;
284-
endian: Endianess = "be";
284+
endian: Endianness = "be";
285285
constructorFn?: Function;
286286
alias?: string;
287287
useContextVariables = false;
@@ -724,21 +724,25 @@ export class Parser {
724724
return this.setNextParser("saveOffset", varName, options);
725725
}
726726

727-
endianess(endianess: "little" | "big"): this {
728-
switch (endianess.toLowerCase()) {
727+
endianness(endianness: "little" | "big"): this {
728+
switch (endianness.toLowerCase()) {
729729
case "little":
730730
this.endian = "le";
731731
break;
732732
case "big":
733733
this.endian = "be";
734734
break;
735735
default:
736-
throw new Error('endianess must be one of "little" or "big"');
736+
throw new Error('endianness must be one of "little" or "big"');
737737
}
738738

739739
return this;
740740
}
741741

742+
endianess(endianess: "little" | "big"): this {
743+
return this.endianness(endianess);
744+
}
745+
742746
useContextVars(useContextVariables = true): this {
743747
this.useContextVariables = useContextVariables;
744748

test/primitive_parser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function primitiveParserTests(
8686
ok(Math.abs(result.a - 12.345) < FLT_EPSILON);
8787
ok(Math.abs(result.b - -0.0678) < FLT_EPSILON);
8888
});
89-
it("should handle endianess", () => {
89+
it("should handle endianness", () => {
9090
const parser = Parser.start().int32le("little").int32be("big");
9191

9292
const buffer = factory([
@@ -147,7 +147,7 @@ function primitiveParserTests(
147147
});
148148

149149
const parser2 = new Parser()
150-
.endianess("little")
150+
.endianness("little")
151151
.bit1("a")
152152
.bit2("b")
153153
.bit4("c")
@@ -171,7 +171,7 @@ function primitiveParserTests(
171171
});
172172

173173
const parser2 = new Parser()
174-
.endianess("little")
174+
.endianness("little")
175175
.bit3("a")
176176
.bit9("b")
177177
.bit4("c");
@@ -198,7 +198,7 @@ function primitiveParserTests(
198198
});
199199

200200
const parser2 = new Parser()
201-
.endianess("little")
201+
.endianness("little")
202202
.bit1("a")
203203
.bit24("b")
204204
.bit4("c")
@@ -345,7 +345,7 @@ function primitiveParserTests(
345345

346346
it("should parse until function returns true when readUntil is function", () => {
347347
const parser = new Parser()
348-
.endianess("big")
348+
.endianness("big")
349349
.uint8("cmd")
350350
.buffer("data", {
351351
readUntil: (item: number) => item === 2,

0 commit comments

Comments
 (0)