1 Star 0 Fork 0

hhardyy/react

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
evalToString.js 666 Bytes
一键复制 编辑 原始数据 按行查看 历史
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
'use strict';
function evalToString(ast /* : Object */) /* : string */ {
switch (ast.type) {
case 'StringLiteral':
return ast.value;
case 'BinaryExpression': // `+`
if (ast.operator !== '+') {
throw new Error('Unsupported binary operator ' + ast.operator);
}
return evalToString(ast.left) + evalToString(ast.right);
default:
throw new Error('Unsupported type ' + ast.type);
}
}
module.exports = evalToString;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/hhardyy/react.git
git@gitee.com:hhardyy/react.git
hhardyy
react
react
master

搜索帮助