mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Authored by 64302444+amitpanwar789@users.noreply.github.com
This commit is contained in:
parent
06e3ec3c0d
commit
6c906d2ef9
@ -113,30 +113,6 @@ define([], function() {
|
||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an integer encoded in 4 bytes, little endian
|
||||
* @param {Array} byteArray
|
||||
* @param {Integer} firstIndex
|
||||
* @returns {Integer}
|
||||
*/
|
||||
function readIntegerFrom4Bytes(byteArray, firstIndex) {
|
||||
var dataView = new DataView(byteArray.buffer, firstIndex, 4);
|
||||
var integer = dataView.getUint32(0, true);
|
||||
return integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an integer encoded in 2 bytes, little endian
|
||||
* @param {Array} byteArray
|
||||
* @param {Integer} firstIndex
|
||||
* @returns {Integer}
|
||||
*/
|
||||
function readIntegerFrom2Bytes(byteArray, firstIndex) {
|
||||
var dataView = new DataView(byteArray.buffer, firstIndex, 2);
|
||||
var integer = dataView.getUint16(0, true);
|
||||
return integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a float encoded in 2 bytes
|
||||
* @param {Array} byteArray
|
||||
@ -150,22 +126,6 @@ define([], function() {
|
||||
return float;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Uint8Array to a lowercase hex string
|
||||
* @param {Array} byteArray
|
||||
* @returns {String}
|
||||
*/
|
||||
function uint8ArrayToHex(byteArray) {
|
||||
var s = '';
|
||||
var hexDigits = '0123456789abcdef';
|
||||
for (var i = 0; i < byteArray.length; i++) {
|
||||
var v = byteArray[i];
|
||||
s += hexDigits[(v & 0xff) >> 4];
|
||||
s += hexDigits[v & 0xf];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a Uint8Array from the given file starting at byte offset begin until end
|
||||
* @param {File} file The file object to be read
|
||||
@ -240,10 +200,7 @@ define([], function() {
|
||||
allCaseFirstLetters: allCaseFirstLetters,
|
||||
removeDuplicateStringsInSmallArray: removeDuplicateStringsInSmallArray,
|
||||
endsWith: endsWith,
|
||||
readIntegerFrom4Bytes: readIntegerFrom4Bytes,
|
||||
readIntegerFrom2Bytes: readIntegerFrom2Bytes,
|
||||
readFloatFrom4Bytes: readFloatFrom4Bytes,
|
||||
uint8ArrayToHex: uint8ArrayToHex,
|
||||
readFileSlice: readFileSlice,
|
||||
binarySearch: binarySearch,
|
||||
leftShift: leftShift
|
||||
|
Loading…
x
Reference in New Issue
Block a user