polyfill Mobile Safari's missing slice
This commit is contained in:
parent
952531809b
commit
ea400ab670
@ -131,11 +131,11 @@ exports.base32ToBuffer = function(encoded) {
|
|||||||
throw new Error('Invalid input - it is not base32 encoded string');
|
throw new Error('Invalid input - it is not base32 encoded string');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (decoded.slice) {
|
|
||||||
|
if (decoded.slice) { // Array or TypedArray
|
||||||
return decoded.slice(0, plainPos);
|
return decoded.slice(0, plainPos);
|
||||||
} else {
|
} else { // Mobile Safari TypedArray
|
||||||
// Mobile Safari's Uint8Array doesn't have slice
|
return new Uint8Array(Array.prototype.slice.call(decoded, 0, plainPos));
|
||||||
return Array.prototype.slice.call(decoded, 0, plainPos);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user