Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Latest commit

 

History

History
26 lines (21 loc) · 1.26 KB

readme.md

File metadata and controls

26 lines (21 loc) · 1.26 KB

castLabs recruitment task

by Wojciech Tyczyński, June 2019

Solution based on vanilla ES8 Javascript. Tested on:

Browser Version Passed
Mozilla Firefox 67.0.4
Google Chrome 75.0.3770.100
Microsoft Edge 44.18362.1.0
Internet Explorer 11.175.18362.0
Safari 12.1.1

Does not work on latest installment of Internet Explorer 11 due to really weak ES6 support.

Bonus question: Which problem can occur if the content of mdat box is very large?

Answer: Solution implemented by me converts mdat box to string using

return String.fromCharCode.apply(null, uint8Array);

This approach has major downside - it can easily raise RangeError when there are more characters (>= 100k). It could be probably resolved by using

return new TextDecoder("utf-8").decode(uint8Array);

However, TextDecoder is not implemented in Microsoft Edge. Moreover, even using TextDecoder javascript thread may stuck for really large blocks of text. I believe the best approach for this kind of problem would be to use FileReader, which offers asynchronous onload callback.