cloudfunctions/SegmentPortraitPic/node_modules/bson/lib/double.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Double = void 0;
/**
* A class representation of the BSON Double type.
* @public
*/
var Double = /** @class */ (function () {
/**
* Create a Double type
*
* @param value - the number we want to represent as a double.
*/
function Double(value) {
if (!(this instanceof Double))
return new Double(value);
if (value instanceof Number) {
value = value.valueOf();
}
this.value = +value;
}
/**
* Access the number value.
*
* @returns returns the wrapped double number.
*/
Double.prototype.valueOf = function () {
return this.value;
};
Double.prototype.toJSON = function () {
return this.value;
};
Double.prototype.toString = function (radix) {
return this.value.toString(radix);
};
/** @internal */
Double.prototype.toExtendedJSON = function (options) {
if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) {
return this.value;
}
// NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user
// explicitly provided `-0` then we need to ensure the sign makes it into the output
if (Object.is(Math.sign(this.value), -0)) {
return { $numberDouble: "-" + this.value.toFixed(1) };
}
var $numberDouble;
if (Number.isInteger(this.value)) {
$numberDouble = this.value.toFixed(1);
if ($numberDouble.length >= 13) {
$numberDouble = this.value.toExponential(13).toUpperCase();
}
}
else {
$numberDouble = this.value.toString();
}
return { $numberDouble: $numberDouble };
};
/** @internal */
Double.fromExtendedJSON = function (doc, options) {
var doubleValue = parseFloat(doc.$numberDouble);
后面还有 15 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
