UNPKG

prepack

Version:

Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.

63 lines (50 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IntegralValue = exports.NumberValue = undefined; var _index = require("./index.js"); class NumberValue extends _index.PrimitiveValue { constructor(realm, value, intrinsicName) { super(realm, intrinsicName); this.value = value; } equals(x) { return x instanceof NumberValue && this.value === x.value; } getHash() { let num = Math.abs(this.value); if (num < 100) num *= 10000000; return num | 0; // make a 32-bit integer out of this and get rid of NaN } mightBeFalse() { return this.value === 0 || isNaN(this.value); } throwIfNotConcreteNumber() { return this; } _serialize() { return this.value; } toDisplayString() { return this.value.toString(); } } exports.NumberValue = NumberValue; /** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ class IntegralValue extends NumberValue { constructor(realm, value, intrinsicName) { super(realm, value, intrinsicName); } static createFromNumberValue(realm, value, intrinsicName) { return Number.isInteger(value) ? new IntegralValue(realm, value, intrinsicName) : new NumberValue(realm, value, intrinsicName); } } exports.IntegralValue = IntegralValue; //# sourceMappingURL=NumberValue.js.map