"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /** * 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. */ exports.default = convert; var _errors = require("../errors.js"); var _index = require("../values/index.js"); var _singletons = require("../singletons.js"); function convert(realm, val) { if (typeof val === "number") { return new _index.NumberValue(realm, val); } else if (typeof val === "string") { return new _index.StringValue(realm, val); } else if (val === null) { return realm.intrinsics.null; } else if (val === undefined) { return realm.intrinsics.undefined; } else if (val === true) { return realm.intrinsics.true; } else if (val === false) { return realm.intrinsics.false; } else if (Array.isArray(val)) { return _singletons.Create.CreateArrayFromList(realm, val.map(function (item) { return convert(realm, item); })); } else if ((typeof val === "undefined" ? "undefined" : _typeof(val)) === "object") { var obj = new _index.ObjectValue(realm, realm.intrinsics.ObjectPrototype); for (var key in val) { obj.$DefineOwnProperty(key, { enumerable: true, writable: true, configurable: true, value: convert(realm, val[key]) }); } return obj; } else { throw new _errors.FatalError("need to convert value of type " + (typeof val === "undefined" ? "undefined" : _typeof(val))); } } //# sourceMappingURL=native-to-interp.js.map