mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
Add an enumerable() method for loops.
This is a helper to aid in iterating over items. This returns a list of objects that contain: - "item": The current value. - "prev": The previous value in the list. - "next": The next value in the list. - "i": The zero-based index in the list. Issue #1518 Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
goog.provide('shaka.util.Uint8ArrayUtils');
|
||||
|
||||
goog.require('shaka.util.Iterables');
|
||||
goog.require('shaka.util.StringUtils');
|
||||
|
||||
|
||||
@@ -65,8 +66,9 @@ shaka.util.Uint8ArrayUtils = class {
|
||||
// byte.
|
||||
const bytes = window.atob(str.replace(/-/g, '+').replace(/_/g, '/'));
|
||||
const result = new Uint8Array(bytes.length);
|
||||
for (let i = 0; i < bytes.length; ++i) {
|
||||
result[i] = bytes.charCodeAt(i);
|
||||
const enumerate = (it) => shaka.util.Iterables.enumerate(it);
|
||||
for (const {i, item} of enumerate(bytes)) {
|
||||
result[i] = item.charCodeAt(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user