prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
73 lines (69 loc) • 2.09 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.typeToString = typeToString;
exports.getTypeFromName = getTypeFromName;
var _index = require("./values/index.js");
function typeToString(type) {
function isInstance(proto, Constructor) {
return proto instanceof Constructor || proto === Constructor.prototype;
}
let proto = type.prototype;
if (isInstance(proto, _index.UndefinedValue)) {
return "undefined";
} else if (isInstance(proto, _index.NullValue)) {
return "object";
} else if (isInstance(proto, _index.StringValue)) {
return "string";
} else if (isInstance(proto, _index.BooleanValue)) {
return "boolean";
} else if (isInstance(proto, _index.NumberValue)) {
return "number";
} else if (isInstance(proto, _index.SymbolValue)) {
return "symbol";
} else if (isInstance(proto, _index.ObjectValue)) {
if (_index.Value.isTypeCompatibleWith(type, _index.FunctionValue)) {
return "function";
}
return "object";
} else {
return undefined;
}
} /**
* 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.
*/
function getTypeFromName(typeName) {
switch (typeName) {
case "empty":
return _index.EmptyValue;
case "void":
return _index.UndefinedValue;
case "null":
return _index.NullValue;
case "boolean":
return _index.BooleanValue;
case "string":
return _index.StringValue;
case "symbol":
return _index.SymbolValue;
case "number":
return _index.NumberValue;
case "object":
return _index.ObjectValue;
case "array":
return _index.ArrayValue;
case "function":
return _index.FunctionValue;
case "integral":
return _index.IntegralValue;
default:
return undefined;
}
}
//# sourceMappingURL=utils.js.map