UNPKG

1.14 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _index = require("../methods/index.js");
9
10var _index2 = require("./index.js");
11
12/**
13 * Copyright (c) 2017-present, Facebook, Inc.
14 * All rights reserved.
15 *
16 * This source code is licensed under the BSD-style license found in the
17 * LICENSE file in the root directory of this source tree. An additional grant
18 * of patent rights can be found in the PATENTS file in the same directory.
19 */
20
21/* strict-local */
22class StringValue extends _index2.PrimitiveValue {
23 constructor(realm, value, intrinsicName) {
24 super(realm, intrinsicName);
25 this.value = value;
26 }
27
28 equals(x) {
29 return x instanceof StringValue && this.value === x.value;
30 }
31
32 getHash() {
33 return (0, _index.hashString)(this.value);
34 }
35
36 mightBeFalse() {
37 return this.value.length === 0;
38 }
39
40 throwIfNotConcreteString() {
41 return this;
42 }
43
44 _serialize() {
45 return this.value;
46 }
47
48 toDisplayString() {
49 // TODO: proper escaping
50 return `"${this.value}"`;
51 }
52
53}
54
55exports.default = StringValue;
56//# sourceMappingURL=StringValue.js.map
\No newline at end of file