本文整理汇总了TypeScript中jsw-logger.JSWLogger类的典型用法代码示例。如果您正苦于以下问题:TypeScript JSWLogger类的具体用法?TypeScript JSWLogger怎么用?TypeScript JSWLogger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSWLogger类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initLogger
static initLogger(showLogs: boolean = false, throwExceptions: boolean = true) {
JSWLogger.__dropInstance();
JSWLogger.getInstance({ hideAllLogs: !showLogs, throwError: throwExceptions });
}
示例2: hlprint
hlprint(s: string): number {
var num;
for (var i = 0, len = s.length; i < len; i++) {
if (s.charCodeAt(i) < 32) {
num = s.charCodeAt(i) <= 15 ? "0" + s.charCodeAt(i).toString(16) : s.charCodeAt(i).toString(16);
this.logger.silly(num + " ");
} else {
num = s.charCodeAt(i) <= 15 ? "0" + s.charCodeAt(i).toString(16) : s.charCodeAt(i).toString(16);
this.logger.silly(num + " ");
}
}
this.logger.silly("\n\n");
return num;
}
示例3: parseFloat
/*
encodeFloat_(data: string|number, precisionBits: number, exponentBits: number): string {
var bias = maxBits[exponentBits - 1] - 1,
minExp = -bias + 1,
maxExp = bias,
minUnnormExp = minExp - precisionBits,
n = parseFloat(`${data}`),
status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0,
exp = 0,
len = 2 * bias + 1 + precisionBits + 3,
bin: Array<number> = new Array(len),
signal: boolean = (n = status !== 0 ? 0 : n) < 0,
intPart = Math.floor(n = Math.abs(n)),
floatPart: number = n - intPart,
lastBit,
rounded,
result,
i,
j;
// for (i = len; i; bin[--i] = 0);
i = len;
while (i) {
bin[--i] = 0;
}
// for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
i = bias + 2;
while (intPart && i) {
bin[--i] = intPart % 2;
intPart = Math.floor(intPart / 2);
}
// for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
i = bias + 1;
while (floatPart > 0 && i) {
floatPart *= 2;
bin[++i] = floatPart >= 1 ? 1 : 0;
--floatPart;
}
// for (i = -1; ++i < len && !bin[i];);
i = 0;
while (i < len && !bin[i]) {
i++;
}
if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp &&
exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
if (!(rounded = bin[lastBit])) {
// for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
j = lastBit + 2;
while (!rounded && j < len) {
rounded = bin[j++];
}
}
// for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
j = lastBit;
while (rounded && j >= 0) {
j--;
bin[j] = bin[j] ? 0 : 1;
rounded = 0;
}
}
for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
++i;
} else if (exp < minExp) {
exp != bias + 1 - len && exp < minUnnormExp && this.logger.warn("encodeFloat::float underflow");
i = bias + 1 - (exp = minExp - 1);
}
if (intPart || status !== 0) {
this.logger.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
exp = maxExp + 1;
i = bias + 2;
if (status == -Infinity) {
signal = true; // 1
} else if (isNaN(status)) {
bin[i] = 1;
}
}
// for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
n = Math.abs(exp + bias);
j = exponentBits;
result = "";
while (j) {
j--;
result = (n % 2) + result;
n = n >>= 1;
}
//.........这里部分代码省略.........
示例4: encodeFloat
encodeFloat(data: /*string|*/number, precisionBits: number, exponentBits: number): string {
var bias = maxBits[exponentBits - 1] - 1
, minExp = -bias + 1
, maxExp = bias
, minUnnormExp = minExp - precisionBits
//, n = parseFloat(_.toString(data))
, n = data
, status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0
, exp = 0
, len = 2 * bias + 1 + precisionBits + 3
, bin = new Array(len)
, signal = (n = status !== 0 ? 0 : n) < 0
, intPart = Math.floor(n = Math.abs(n))
, floatPart = n - intPart
, lastBit
, rounded
, result
, i
, j;
for (i = len; i; bin[--i] = 0);
for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
// for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
for (i = bias + 1; floatPart > 0 && i; (bin[++i] = _.toNumber(((floatPart *= 2) >= 1)) ) && --floatPart);
for (i = -1; ++i < len && !bin[i];);
if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp && exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
if (!(rounded = bin[lastBit])) {
for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
}
// for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = _.toNumber(!bin[j])) && (rounded = 0));
// j = lastBit + 1;
// while (rounded && --j >= 0) {
// bin[j] = _.toNumber(!bin[j]);
// rounded = 0;
// }
}
for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
++i;
} else if (exp < minExp) {
exp != bias + 1 - len && exp < minUnnormExp && this.logger.warn("encodeFloat::float underflow");
i = bias + 1 - (exp = minExp - 1);
}
if (intPart || status !== 0) {
this.logger.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
exp = maxExp + 1;
i = bias + 2;
if (status == -Infinity) {
signal = true;
} else if (isNaN(status)) {
bin[i] = 1;
}
}
for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
var r = [];
for (n = 0, j = 0, i = (result = (signal ? "1" : "0") + result + bin.slice(i, i + precisionBits).join("")).length, r = []; i; j = (j + 1) % 8) {
n += (1 << j) * result.charAt(--i);
if (j == 7) {
r[r.length] = String.fromCharCode(n);
n = 0;
}
}
r[r.length] = n
? String.fromCharCode(n)
: "";
return (this.bigEndian ? r.reverse() : r).join("");
}