qcloud-iotexplorer-common-libs
Advanced tools
Comparing version 3.0.0-alpha.8 to 3.0.0-alpha.9
@@ -46,3 +46,3 @@ "use strict"; | ||
function putString2bytes(destbytes, srcString, destOffset, srcOffset, count) { | ||
const stringBytes = this.stringToByteArray(srcString); | ||
const stringBytes = stringToByteArray(srcString); | ||
for (let i = 0; i < count; i++) { | ||
@@ -77,3 +77,3 @@ destbytes[count + i] = stringBytes[i]; | ||
for (let i = 0; i < len; i++) { | ||
bytes[i] = this.convertUint8toByte(uint8s[i]); | ||
bytes[i] = convertUint8toByte(uint8s[i]); | ||
} | ||
@@ -118,3 +118,3 @@ return bytes; | ||
for (let i = 0; i < len; i++) { | ||
uint8s[i] = this.convertByte2Uint8(bytes[i]); | ||
uint8s[i] = convertByte2Uint8(bytes[i]); | ||
} | ||
@@ -135,3 +135,3 @@ return uint8s; | ||
for (let i = 0; i < count; i++) { | ||
destUint8s[destOffset + i] = this.convertByte2Uint8(srcBytes[srcOffset | ||
destUint8s[destOffset + i] = convertByte2Uint8(srcBytes[srcOffset | ||
+ i]); | ||
@@ -176,3 +176,3 @@ } | ||
.forEach((numByte) => { | ||
retArr.push(this.byteToHex(numByte & 0xff)); | ||
retArr.push(byteToHex(numByte & 0xff)); | ||
}); | ||
@@ -189,4 +189,4 @@ return retArr.join(optSeparator || ''); | ||
function convertByte2HexString(b) { | ||
const u8 = this.convertByte2Uint8(b); | ||
return this.byteToHex(u8); | ||
const u8 = convertByte2Uint8(b); | ||
return byteToHex(u8); | ||
} | ||
@@ -201,3 +201,3 @@ exports.convertByte2HexString = convertByte2HexString; | ||
function convertU8ToHexString(u8) { | ||
return this.byteToHex(u8); | ||
return byteToHex(u8); | ||
} | ||
@@ -217,3 +217,3 @@ exports.convertU8ToHexString = convertU8ToHexString; | ||
} | ||
const hexString = this.convertByte2HexString(uint8); | ||
const hexString = convertByte2HexString(uint8); | ||
let low; | ||
@@ -257,4 +257,4 @@ let high; | ||
function combine2bytesToU16(high, low) { | ||
const highU8 = this.convertByte2Uint8(high); | ||
const lowU8 = this.convertByte2Uint8(low); | ||
const highU8 = convertByte2Uint8(high); | ||
const lowU8 = convertByte2Uint8(low); | ||
// eslint-disable-next-line no-mixed-operators | ||
@@ -267,3 +267,3 @@ return highU8 << 8 | lowU8; | ||
for (let i = 0; i < len; i++) { | ||
data[i] = this.convertUint8toByte('1'); | ||
data[i] = convertUint8toByte('1'); | ||
} | ||
@@ -280,4 +280,4 @@ return data; | ||
function genSpecBytes(len) { | ||
const u8 = this.convertByte2Uint8(len); | ||
return this.getSpecBytesFromChar(u8); | ||
const u8 = convertByte2Uint8(len); | ||
return getSpecBytesFromChar(u8); | ||
} | ||
@@ -287,3 +287,3 @@ exports.genSpecBytes = genSpecBytes; | ||
const bytes = new Int8Array([...bssidBytes]); | ||
return this.getParsedBssid(bytes); | ||
return getParsedBssid(bytes); | ||
} | ||
@@ -305,3 +305,3 @@ exports.parseBssid = parseBssid; | ||
k = 0xff & bssidByte; | ||
hexK = this.byteToHex(k); | ||
hexK = byteToHex(k); | ||
sb += hexK; | ||
@@ -350,3 +350,3 @@ } | ||
// TODO(user): Use native implementations if/when available | ||
const out = new Int8Array(this.getStringBytesLength(str)); | ||
const out = new Int8Array(getStringBytesLength(str)); | ||
let p = 0; | ||
@@ -421,3 +421,3 @@ for (let i = 0; i < str.length; i++) { | ||
case 'UTF-8': | ||
return this.stringToUtf8ByteArray(string); | ||
return stringToUtf8ByteArray(string); | ||
} | ||
@@ -439,3 +439,3 @@ } | ||
for (let i = 0; i < len; i += 2) { | ||
data[((i / 2 | 0))] = this.convertNumberToByte(((parseInt(s.charAt(i), 16) << 4) + parseInt(s.charAt(i + 1), 16)) | 0); | ||
data[((i / 2 | 0))] = convertNumberToByte(((parseInt(s.charAt(i), 16) << 4) + parseInt(s.charAt(i + 1), 16)) | 0); | ||
} | ||
@@ -455,3 +455,4 @@ return data; | ||
const view = new DataView(buf.buffer); | ||
return fixedLength === undefined ? view.getFloat32(0) : view.getFloat32(0).toFixed(fixedLength); | ||
return fixedLength === undefined ? view.getFloat32(0) : view.getFloat32(0) | ||
.toFixed(fixedLength); | ||
} | ||
@@ -462,4 +463,5 @@ exports.hexArray2Float32 = hexArray2Float32; | ||
const dataView = new DataView(buf.buffer); | ||
const hex = dataView.getUint32(0).toString(16); | ||
return this.hexString2hexArray(`${'0000000000'.slice(0, 8 - hex.length)}${hex}`); | ||
const hex = dataView.getUint32(0) | ||
.toString(16); | ||
return hexString2hexArray(`${'0000000000'.slice(0, 8 - hex.length)}${hex}`); | ||
} | ||
@@ -469,3 +471,3 @@ exports.float32ToHexArray = float32ToHexArray; | ||
if (typeof s === 'string') { | ||
s = this.hexString2hexArray(s); | ||
s = hexString2hexArray(s); | ||
} | ||
@@ -512,3 +514,3 @@ if (s.length !== 4) { | ||
} | ||
return this.convertNumberToByte((crc & 0xff)); | ||
return convertNumberToByte((crc & 0xff)); | ||
} | ||
@@ -519,3 +521,3 @@ exports.crc8Byte = crc8Byte; | ||
for (let i = 0; i < len; ++i) { | ||
crc = this.crc8Byte((crc ^ bs[i])); | ||
crc = crc8Byte((crc ^ bs[i])); | ||
} | ||
@@ -552,3 +554,3 @@ return crc; | ||
// 20 = 0x14 | ||
const result = this.splitUint8To2bytes(20); | ||
const result = splitUint8To2bytes(20); | ||
if (result[0] === 1 && result[1] === 4) { | ||
@@ -565,3 +567,3 @@ console.log('test_splitUint8To2bytes(): pass'); | ||
const low = 0x04; | ||
if (this.combine2bytesToOne(high, low) === 20) { | ||
if (combine2bytesToOne(high, low) === 20) { | ||
console.log('test_combine2bytesToOne(): pass'); | ||
@@ -580,4 +582,4 @@ } | ||
const b3 = -1; | ||
if (this.convertByte2Uint8(b1) === 97 && this.convertByte2Uint8(b2) === 128 | ||
&& this.convertByte2Uint8(b3) === 255) { | ||
if (convertByte2Uint8(b1) === 97 && convertByte2Uint8(b2) === 128 | ||
&& convertByte2Uint8(b3) === 255) { | ||
console.log('test_convertChar2Uint8(): pass'); | ||
@@ -596,4 +598,4 @@ } | ||
const c3 = 255; | ||
if (this.convertUint8toByte(c1) === 97 && this.convertUint8toByte(c2) === -128 | ||
&& this.convertUint8toByte(c3) === -1) { | ||
if (convertUint8toByte(c1) === 97 && convertUint8toByte(c2) === -128 | ||
&& convertUint8toByte(c3) === -1) { | ||
console.log('test_convertUint8toByte(): pass'); | ||
@@ -608,4 +610,4 @@ } | ||
const b = [15, -2, 52, -102, -93, -60]; | ||
console.log(this.parseBssid(b)); | ||
if (this.parseBssid(b) === '0ffe349aa3c4') { | ||
console.log(parseBssid(b)); | ||
if (parseBssid(b) === '0ffe349aa3c4') { | ||
console.log('test_parseBssid(): pass'); | ||
@@ -619,8 +621,8 @@ } | ||
// testMain() { | ||
// this.testConvertUint8toByte(); | ||
// this.testConvertChar2Uint8(); | ||
// this.testSplitUint8To2bytes(); | ||
// this.testCombine2bytesToOne(); | ||
// this.testParseBssid(); | ||
// testConvertUint8toByte(); | ||
// testConvertChar2Uint8(); | ||
// testSplitUint8To2bytes(); | ||
// testCombine2bytesToOne(); | ||
// testParseBssid(); | ||
// } | ||
//# sourceMappingURL=byte-util.js.map |
{ | ||
"name": "qcloud-iotexplorer-common-libs", | ||
"version": "3.0.0-alpha.8", | ||
"version": "3.0.0-alpha.9", | ||
"description": "腾讯云IOT前端通用工具库", | ||
@@ -21,3 +21,3 @@ "bugs": { | ||
"dependencies": { | ||
"qcloud-iotexplorer-logger": "3.0.0-alpha.8", | ||
"qcloud-iotexplorer-logger": "3.0.0-alpha.9", | ||
"rxjs": "^7.8.0", | ||
@@ -31,3 +31,3 @@ "shortid-for-miniprogram": "^2.2.15", | ||
}, | ||
"gitHead": "674e0cca069a33a99965f5bd2bc5ceaab04a3648" | ||
"gitHead": "bfa873f67554763526e400c2c2cde89686e46ff8" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15120
1016134
+ Addedqcloud-iotexplorer-logger@3.0.0-alpha.9(transitive)
- Removedqcloud-iotexplorer-logger@3.0.0-alpha.8(transitive)