Skip to content

Commit aafe049

Browse files
Project: Rename from Fat Binary to Universal Hex.
1 parent b02d8c5 commit aafe049

File tree

7 files changed

+60
-60
lines changed

7 files changed

+60
-60
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# micro:bit Fat Binary
1+
# micro:bit Universal Hex
22

3-
[![CircleCI](https://circleci.com/gh/microbit-foundation/microbit-fb.svg?style=svg)](https://circleci.com/gh/microbit-foundation/microbit-fb)
3+
[![CircleCI](https://circleci.com/gh/microbit-foundation/microbit-universal-hex.svg?style=svg)](https://circleci.com/gh/microbit-foundation/microbit-universal-hex)
44

5-
TypeScript/JavaScript library to create micro:bit fat binaries.
5+
TypeScript/JavaScript library to create micro:bit Universal Hexes.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "@microbit-foundation/microbit-fb",
2+
"name": "@microbit-foundation/microbit-universal-hex",
33
"version": "0.1.0",
4-
"description": "Create micro:bit fat binaries.",
4+
"description": "Create micro:bit Universal Hexes.",
55
"keywords": [
66
"microbit",
7-
"fat-binary",
8-
"fat binary",
9-
"fb"
7+
"universal-hex",
8+
"universal hex",
9+
"uh"
1010
],
11-
"main": "./dist/bundles/microbit-fb.umd.js",
12-
"mainMin": "./dist/bundles/microbit-fb.umd.min.js",
11+
"main": "./dist/bundles/microbit-uh.umd.js",
12+
"mainMin": "./dist/bundles/microbit-uh.umd.min.js",
1313
"module": "./dist/esm5/index.js",
1414
"typings": "./dist/types/index.d.ts",
1515
"sideEffects": false,
1616
"repository": {
1717
"type": "git",
18-
"url": "https://github.com/microbit-foundation/microbit-fb"
18+
"url": "https://github.com/microbit-foundation/microbit-universal-hex"
1919
},
2020
"config": {
21-
"umdName": "microbitFb"
21+
"umdName": "microbitUh"
2222
},
2323
"author": "Micro:bit Educational Foundation <[email protected]>",
2424
"license": "MIT",

src/__tests__/fat-binary.spec.ts renamed to src/__tests__/universal-hex.spec.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
22

3-
import * as fb from '../fat-binary';
3+
import * as uh from '../universal-hex';
44

55
const hex1 = fs.readFileSync(
66
'./src/__tests__/hex-files/1-duck-umbrella.hex',
@@ -40,7 +40,7 @@ describe('Test iHexToCustomFormat()', () => {
4040
':1000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
4141
':0400000BFFFFFFFFF5\n';
4242

43-
const result = fb.iHexToCustomFormat(hexStr, 0x9903);
43+
const result = uh.iHexToCustomFormat(hexStr, 0x9903);
4444

4545
expect(result).toEqual(expected);
4646
expect(result.length).toEqual(512);
@@ -78,7 +78,7 @@ describe('Test iHexToCustomFormat()', () => {
7878
':0C10D000FFFFFFFF2D6D0300000000007B\n' +
7979
':0000000BF5\n';
8080

81-
const result = fb.iHexToCustomFormat(hexStr, 0x9901);
81+
const result = uh.iHexToCustomFormat(hexStr, 0x9901);
8282

8383
expect(result).toEqual(expected);
8484
expect(result.length).toEqual(512);
@@ -131,7 +131,7 @@ describe('Test iHexToCustomFormat()', () => {
131131
':1000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
132132
':1000000BFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5\n';
133133

134-
const result = fb.iHexToCustomFormat(hexStr, 0x9901);
134+
const result = uh.iHexToCustomFormat(hexStr, 0x9901);
135135

136136
expect(result).toEqual(expected);
137137
expect(result.length).toEqual(1024);
@@ -163,8 +163,8 @@ describe('Test iHexToCustomFormat()', () => {
163163
const expected9901 = [...expected9900];
164164
expected9901[1] = ':0400000A9901C0DEBA\n';
165165

166-
const result9900 = fb.iHexToCustomFormat(hexStr, 0x9900);
167-
const result9901 = fb.iHexToCustomFormat(hexStr, 0x9901);
166+
const result9900 = uh.iHexToCustomFormat(hexStr, 0x9900);
167+
const result9901 = uh.iHexToCustomFormat(hexStr, 0x9901);
168168

169169
expect(result9900).toEqual(expected9900.join(''));
170170
expect(result9900.length).toEqual(512);
@@ -199,11 +199,11 @@ describe('Test iHexToCustomFormat()', () => {
199199
const expectedFFFF = [...expected9903];
200200
expectedFFFF[1] = ':0400000AFFFFC0DE56\n';
201201

202-
const result9903 = fb.iHexToCustomFormat(hexStr, 0x9903);
203-
const result9904 = fb.iHexToCustomFormat(hexStr, 0x9904);
204-
const result9910 = fb.iHexToCustomFormat(hexStr, 0x9910);
205-
const result0000 = fb.iHexToCustomFormat(hexStr, 0);
206-
const resultFFFF = fb.iHexToCustomFormat(hexStr, 0xffff);
202+
const result9903 = uh.iHexToCustomFormat(hexStr, 0x9903);
203+
const result9904 = uh.iHexToCustomFormat(hexStr, 0x9904);
204+
const result9910 = uh.iHexToCustomFormat(hexStr, 0x9910);
205+
const result0000 = uh.iHexToCustomFormat(hexStr, 0);
206+
const resultFFFF = uh.iHexToCustomFormat(hexStr, 0xffff);
207207

208208
expect(result9903).toEqual(expected9903.join(''));
209209
expect(result9904).toEqual(expected9904.join(''));
@@ -230,7 +230,7 @@ describe('Test iHexToCustomFormat()', () => {
230230
':0000000BF5\n' +
231231
':00000001FF\n';
232232

233-
const result = fb.iHexToCustomFormat(hexStr, 0x9903);
233+
const result = uh.iHexToCustomFormat(hexStr, 0x9903);
234234

235235
expect(result).toEqual(expected);
236236
});
@@ -274,7 +274,7 @@ describe('Test iHexToCustomFormat()', () => {
274274
':0000000BF5\n' +
275275
':00000001FF\n';
276276

277-
const result = fb.iHexToCustomFormat(hexStr, 0x9901);
277+
const result = uh.iHexToCustomFormat(hexStr, 0x9901);
278278

279279
expect(result).toEqual(expected);
280280
});
@@ -354,21 +354,21 @@ describe('Test iHexToCustomFormat()', () => {
354354
':0000000BF5\n' +
355355
':00000001FF\n';
356356

357-
const result = fb.iHexToCustomFormat(hexStr, 0x9901);
357+
const result = uh.iHexToCustomFormat(hexStr, 0x9901);
358358

359359
expect(result).toEqual(expected);
360360
});
361361

362362
it('Empty Hex string produces an empty-ish output', () => {
363-
const result = fb.iHexToCustomFormat('', 0x9903);
363+
const result = uh.iHexToCustomFormat('', 0x9903);
364364

365365
expect(result).toEqual('');
366366
});
367367
});
368368

369-
describe('Test createFatBinary()', () => {
369+
describe('Test createUniversalHex()', () => {
370370
it('Empty input equals empty output', () => {
371-
const result = fb.createFatBinary([]);
371+
const result = uh.createUniversalHex([]);
372372

373373
expect(result).toEqual('');
374374
});
@@ -385,30 +385,30 @@ describe('Test createFatBinary()', () => {
385385
);
386386
387387
it('.', () => {
388-
const result1 = fb.iHexToCustomFormat(hex1, 0x9901);
388+
const result1 = uh.iHexToCustomFormat(hex1, 0x9901);
389389
fs.writeFileSync('./src/__tests__/hex-files/test-output-1.hex', result1);
390-
const result2 = fb.iHexToCustomFormat(hex2, 0x9903);
390+
const result2 = uh.iHexToCustomFormat(hex2, 0x9903);
391391
fs.writeFileSync('./src/__tests__/hex-files/test-output-2.hex', result2);
392392
393393
expect('').toEqual('');
394394
});
395395
396396
it('..', () => {
397-
const result = fb.createFatBinary([
397+
const result = uh.createUniversalHex([
398398
{ hex: hex1, boardID: 0x9901 },
399399
{ hex: hex2, boardID: 0x9903 },
400400
]);
401-
fs.writeFileSync('./src/__tests__/hex-files/test-output-fat.hex', result);
401+
fs.writeFileSync('./src/__tests__/hex-files/test-output-universal.hex', result);
402402
403403
expect('').toEqual('');
404404
});
405405
*/
406406
});
407407

408-
describe('Separate fat binaries', () => {
408+
describe('Separate a Universal Hex', () => {
409409
it('Throws an error on empty input', () => {
410410
expect(() => {
411-
const result = fb.separateFatBinary('');
411+
const result = uh.separateUniversalHex('');
412412
}).toThrow('Empty');
413413
});
414414

@@ -420,7 +420,7 @@ describe('Separate fat binaries', () => {
420420
':00000001FF\n';
421421

422422
expect(() => {
423-
fb.separateFatBinary(normalHex);
423+
uh.separateUniversalHex(normalHex);
424424
}).toThrow('format invalid');
425425
});
426426

@@ -436,7 +436,7 @@ describe('Separate fat binaries', () => {
436436
':00000001FF\n';
437437

438438
expect(() => {
439-
fb.separateFatBinary(simpleBlock);
439+
uh.separateUniversalHex(simpleBlock);
440440
}).toThrow('Block Start record invalid: :0400000A9901BA');
441441
});
442442

@@ -487,15 +487,15 @@ describe('Separate fat binaries', () => {
487487
':1056F0005746591C62408C4607430F2F5CD86F49B0\n' +
488488
':00000001FF\n';
489489

490-
const result = fb.separateFatBinary(firstBlock + secondBlock);
490+
const result = uh.separateUniversalHex(firstBlock + secondBlock);
491491
expect(result[0].boardId).toEqual(0x9901);
492492
expect(result[0].hex).toEqual(firstHex);
493493
expect(result[1].boardId).toEqual(0x9903);
494494
expect(result[1].hex).toEqual(secondHex);
495495
});
496496

497497
it('Separate a full hex file', () => {
498-
const result = fb.separateFatBinary(hexCombined);
498+
const result = uh.separateUniversalHex(hexCombined);
499499
// fs.writeFileSync(
500500
// './src/__tests__/hex-files/test-separate-0.hex',
501501
// result[0].hex
@@ -513,7 +513,7 @@ describe('Separate fat binaries', () => {
513513
});
514514
});
515515

516-
describe('Loopback hex to fat binaries', () => {
516+
describe('Loopback Intel Hex to Universal Hex', () => {
517517
it('From a small sample', () => {
518518
const hexStr =
519519
':020000040000FA\n' +
@@ -547,15 +547,15 @@ describe('Loopback hex to fat binaries', () => {
547547
':1056E00080220020ED00D20415437F3BFB18424688\n' +
548548
':1056F0005746591C62408C4607430F2F5CD86F49B0\n' +
549549
':00000001FF\n';
550-
const fatBinary = fb.iHexToCustomFormat(hexStr, 0x9901);
550+
const universalHex = uh.iHexToCustomFormat(hexStr, 0x9901);
551551

552-
const result = fb.separateFatBinary(fatBinary);
552+
const result = uh.separateUniversalHex(universalHex);
553553

554554
expect(result[0].hex).toEqual(hexStr);
555555
});
556556

557557
it('From full MakeCode files', () => {
558-
const fatBinary = fb.createFatBinary([
558+
const universalHex = uh.createUniversalHex([
559559
{
560560
hex: hex1,
561561
boardId: 0x1,
@@ -566,7 +566,7 @@ describe('Loopback hex to fat binaries', () => {
566566
},
567567
]);
568568

569-
const result = fb.separateFatBinary(fatBinary);
569+
const result = uh.separateUniversalHex(universalHex);
570570

571571
expect(result[0].boardId).toEqual(1);
572572
expect(result[0].hex).toEqual(hex1);

src/ihex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as utils from './utils';
22

3-
/** Values for the Record Type field, including fat-binaries custom types. */
3+
/** Values for the Record Type field, including Universal Hex custom types. */
44
enum RecordType {
55
Data = 0x00,
66
EndOfFile = 0x01,
@@ -104,7 +104,7 @@ function calcChecksumByte(dataBytes: Uint8Array): number {
104104
*
105105
* @param address - The two least significant bytes for the data address.
106106
* @param recordType - Record type, could be one of the standard types or any
107-
* of the custom types created for forming fat binaries.
107+
* of the custom types created for forming a Universal Hex.
108108
* @param dataBytes - Byte array with the data to include in the record.
109109
* @returns A string with the Intel Hex record.
110110
*/

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './fat-binary';
1+
export * from './universal-hex';

src/fat-binary.ts renamed to src/universal-hex.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* Converts standard Intel Hex strings into fat binaries with records organised
3-
* in self contained 512-byte blocks.
2+
* Converts standard Intel Hex strings into a Universal Hex with records
3+
* organised in self contained 512-byte blocks.
44
*
5-
* (c) 2020 Micro:bit Educational Foundation and the microbit-fb contributors.
5+
* (c) 2020 Micro:bit Educational Foundation and the project contributors.
66
* SPDX-License-Identifier: MIT
77
*/
88
import * as ihex from './ihex';
@@ -16,7 +16,7 @@ interface IndividualHex {
1616
}
1717

1818
/**
19-
* Converts a hex file string into a fat-binary ready hex string using custom
19+
* Converts a hex file string into a Universal Hex ready hex string using custom
2020
* records and 512 byte blocks.
2121
*
2222
* Block format:
@@ -116,7 +116,7 @@ function iHexToCustomFormat(iHexStr: string, boardId: number): string {
116116
return blockLines.length ? blockLines.join('\n') + '\n' : '';
117117
}
118118

119-
function createFatBinary(hexes: IndividualHex[]): string {
119+
function createUniversalHex(hexes: IndividualHex[]): string {
120120
if (!hexes.length) return '';
121121

122122
const eofRecord = ihex.endOfFileRecord();
@@ -151,14 +151,14 @@ function createFatBinary(hexes: IndividualHex[]): string {
151151
}
152152

153153
/**
154-
* Separates a Fat Binary into the individual hexes.
154+
* Separates a Universal Hex into the individual hexes.
155155
*
156-
* @param intelHexStr Intel Hex string with the Fat Binary.
156+
* @param intelHexStr Intel Hex string with the Universal Hex.
157157
* @returns An array of object with boardId and hex keys.
158158
*/
159-
function separateFatBinary(intelHexStr: string): IndividualHex[] {
159+
function separateUniversalHex(intelHexStr: string): IndividualHex[] {
160160
const records = ihex.iHexToRecordStrs(intelHexStr);
161-
if (!records.length) throw new Error('Empty fat binary.');
161+
if (!records.length) throw new Error('Empty Universal Hex.');
162162

163163
// The format has to start with an Extended Linear Address and Block Start
164164
if (
@@ -167,7 +167,7 @@ function separateFatBinary(intelHexStr: string): IndividualHex[] {
167167
ihex.getRecordType(records[records.length - 1]) !==
168168
ihex.RecordType.EndOfFile
169169
) {
170-
throw new Error('Fat binary block format invalid.');
170+
throw new Error('Universal Hex block format invalid.');
171171
}
172172

173173
const passThroughRecords = [
@@ -221,7 +221,7 @@ function separateFatBinary(intelHexStr: string): IndividualHex[] {
221221
}
222222
}
223223

224-
// Form the return object with the same format as createFatBinary() input
224+
// Form the return object with the same format as createUniversalHex() input
225225
const returnArray: IndividualHex[] = [];
226226
Object.keys(hexes).forEach((boardId: string) => {
227227
// Ensure all hexes (and not just the last) contain the EoF record
@@ -237,4 +237,4 @@ function separateFatBinary(intelHexStr: string): IndividualHex[] {
237237
return returnArray;
238238
}
239239

240-
export { iHexToCustomFormat, createFatBinary, separateFatBinary };
240+
export { iHexToCustomFormat, createUniversalHex, separateUniversalHex };

0 commit comments

Comments
 (0)