Skip to content

Commit 87b4e5f

Browse files
Merge branch 'TurboWarp:develop' into InlineFields
2 parents d5975ba + 9657efb commit 87b4e5f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/extensions/scratch3_pen/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ class Scratch3PenBlocks {
298298
}),
299299
blockIconURI: blockIconURI,
300300
blocks: [
301+
// tw: additional message when on the stage for clarity
302+
{
303+
blockType: BlockType.LABEL,
304+
text: formatMessage({
305+
id: 'tw.pen.stageSelected',
306+
default: 'Stage selected: less pen blocks',
307+
description: 'Label that appears in the Pen category when the stage is selected'
308+
}),
309+
filter: [TargetType.STAGE]
310+
},
301311
{
302312
opcode: 'clear',
303313
blockType: BlockType.COMMAND,

src/util/base64-util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ class Base64Util {
2020

2121
/**
2222
* Convert a Uint8Array to a base64 encoded string.
23-
* @param {Uint8Array} array - the array to convert.
23+
* @param {Uint8Array|Array<number>} array - the array to convert.
2424
* @return {string} - the base64 encoded string.
2525
*/
2626
static uint8ArrayToBase64 (array) {
27+
if (Array.isArray(array)) {
28+
array = new Uint8Array(array);
29+
}
2730
let binary = '';
2831
const len = array.byteLength;
2932
for (let i = 0; i < len; i++) {

test/unit/util_base64.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const Base64Util = require('../../src/util/base64-util');
33

44
test('uint8ArrayToBase64', t => {
55
t.equal(Base64Util.uint8ArrayToBase64(new Uint8Array([0, 50, 80, 200])), 'ADJQyA==');
6+
t.equal(Base64Util.uint8ArrayToBase64([0, 50, 80, 200]), 'ADJQyA==');
67
t.end();
78
});
89

@@ -25,11 +26,13 @@ test('round trips', t => {
2526
new Uint8Array(0),
2627
new Uint8Array([10, 90, 0, 255, 255, 255, 10, 2]),
2728
new Uint8Array(10000),
28-
new Uint8Array(1000000)
29+
new Uint8Array(100000)
2930
];
3031
for (const uint8array of data) {
3132
const uint8ToBase64 = Base64Util.uint8ArrayToBase64(uint8array);
33+
const arrayToBase64 = Base64Util.uint8ArrayToBase64(Array.from(uint8array));
3234
const bufferToBase64 = Base64Util.arrayBufferToBase64(uint8array.buffer);
35+
t.equal(uint8ToBase64, arrayToBase64);
3336
t.equal(uint8ToBase64, bufferToBase64);
3437
const decoded = Base64Util.base64ToUint8Array(uint8ToBase64);
3538
t.same(uint8array, decoded);

0 commit comments

Comments
 (0)