Skip to content

Commit 46b5d19

Browse files
committed
Make Enum ordinal values start at 0 instead of 1
1 parent 0c55964 commit 46b5d19

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/Enum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Enum {
2424
*/
2525
constructor(...constants) {
2626
const flags = {};
27-
let bitValue = 1;
27+
let bitValue = 0;
2828
let length = 0;
2929

3030
for (const flag of constants) {

test/BitFlags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ describe('BitFlags', () => {
104104
expect(flags.values().map(constant => constant.name)).to.deep.equal(input);
105105

106106
let bit = 1;
107-
for (const value of flags) {
108-
expect(Number(value)).to.equal(bit);
107+
for (const flag of flags) {
108+
expect(Number(flag)).to.equal(bit);
109109
bit <<= 1;
110110
}
111111
});

test/Enum.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe('Enum', () => {
5757
let j = 0;
5858
for (const flag of flags) {
5959
expect(flag).to.be.an.instanceof(EnumConstant);
60-
expect(Number(flag)).to.not.equal(0);
6160
j++;
6261
}
6362

@@ -118,7 +117,7 @@ describe('Enum', () => {
118117
});
119118

120119
describe('#forEach()', () => {
121-
it('should iterate every value-key pair but where value is 0', () => {
120+
it('should iterate every value-key pair', () => {
122121
let i = 0;
123122

124123
flags.forEach((value, key, obj) => {
@@ -127,7 +126,6 @@ describe('Enum', () => {
127126
expect(value).to.satisfy((val) => {
128127
return (typeof val === 'number') || (val instanceof EnumConstant);
129128
});
130-
expect(Number(value)).to.not.equal(0);
131129
i++;
132130
});
133131

0 commit comments

Comments
 (0)