UNPKG

2.74 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _index = require("./index.js");
9
10var _invariant = _interopRequireDefault(require("../invariant.js"));
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14/**
15 * Copyright (c) 2017-present, Facebook, Inc.
16 * All rights reserved.
17 *
18 * This source code is licensed under the BSD-style license found in the
19 * LICENSE file in the root directory of this source tree. An additional grant
20 * of patent rights can be found in the PATENTS file in the same directory.
21 */
22
23/* strict-local */
24class ConcreteValue extends _index.Value {
25 constructor(realm, intrinsicName) {
26 (0, _invariant.default)(realm, "realm required");
27 super(realm, intrinsicName);
28 }
29
30 mightNotBeFalse() {
31 return !this.mightBeFalse();
32 }
33
34 mightBeNull() {
35 return this instanceof _index.NullValue;
36 }
37
38 mightNotBeNull() {
39 return !(this instanceof _index.NullValue);
40 }
41
42 mightBeNumber() {
43 return this instanceof _index.NumberValue;
44 }
45
46 mightNotBeNumber() {
47 return !(this instanceof _index.NumberValue);
48 }
49
50 mightNotBeObject() {
51 return !(this instanceof _index.ObjectValue);
52 }
53
54 mightBeObject() {
55 return this instanceof _index.ObjectValue;
56 }
57
58 mightBeString() {
59 return this instanceof _index.StringValue;
60 }
61
62 mightNotBeString() {
63 return !(this instanceof _index.StringValue);
64 }
65
66 mightBeUndefined() {
67 return this instanceof _index.UndefinedValue;
68 }
69
70 mightNotBeUndefined() {
71 return !(this instanceof _index.UndefinedValue);
72 }
73
74 mightHaveBeenDeleted() {
75 return this instanceof _index.EmptyValue;
76 }
77
78 promoteEmptyToUndefined() {
79 if (this instanceof _index.EmptyValue) return this.$Realm.intrinsics.undefined;
80 return this;
81 }
82
83 throwIfNotConcrete() {
84 return this;
85 }
86
87 throwIfNotConcreteNumber() {
88 (0, _invariant.default)(false, "expected this to be a number if concrete");
89 }
90
91 throwIfNotConcreteString() {
92 (0, _invariant.default)(false, "expected this to be a string if concrete");
93 }
94
95 throwIfNotConcreteBoolean() {
96 (0, _invariant.default)(false, "expected this to be a boolean if concrete");
97 }
98
99 throwIfNotConcreteSymbol() {
100 (0, _invariant.default)(false, "expected this to be a symbol if concrete");
101 }
102
103 throwIfNotConcreteObject() {
104 return this.throwIfNotObject();
105 }
106
107 throwIfNotConcretePrimitive() {
108 (0, _invariant.default)(false, "expected this to be a primitive value if concrete");
109 }
110
111 throwIfNotObject() {
112 (0, _invariant.default)(false, "expected this to be an object if concrete");
113 }
114
115}
116
117exports.default = ConcreteValue;
118//# sourceMappingURL=ConcreteValue.js.map
\No newline at end of file