我一直试图将invRegex.py移植到node.js实现一段时间,但我仍然在努力解决它.由于ret.js标记器,我已经有了正则表达式解析树,并且它工作得很好,但是以一种节省内存的方式实际生成和连接所有不同的元素对我来说是非常具有挑战性的.为了简单起见,我可以说我有以下正则表达式:
[01]{1,2}@[a-f]
Run Code Online (Sandbox Code Playgroud)
提供以invRegex.py
产生以下输出(标签化以占用更少的空间):
0@a 0@b 0@c 0@d 0@e 0@f
00@a 00@b 00@c 00@d 00@e 00@f
01@a 01@b 01@c 01@d 01@e 01@f
1@a 1@b 1@c 1@d 1@e 1@f
10@a 10@b 10@c 10@d 10@e 10@f
11@a 11@b 11@c 11@d 11@e 11@f
Run Code Online (Sandbox Code Playgroud)
考虑到我能够获得每个单独的令牌并生成所有有效单个输出的数组:
[01]{1,2} = function () {
return ['0', '00', '01', '1', '10', '11'];
};
@ = function () {
return ['@'];
};
[a-f] = function () {
return ['a', 'b', 'c', 'd', 'e', …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Webpack 1.13.12 和 eslint 3.11.0 和 eslint-plugin-promise 3.4.0。我正在尝试使用这个问题的答案来让 Superagent 生成 Web 服务调用的结果。
import agent from 'superagent';
require('superagent-as-promised')(agent);
import Promise from 'promise';
const API_URL = 'http://localhost/services/merchant';
export function createVendorCall() {
const responsePromise = yield Promise.resolve(agent.put(`${API_URL}/create`));
let response = responsePromise.next();
return response.body;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试对此进行检查时,eslint 抱怨说The keyword 'yield' is reserved.
我已尝试require-yield
在 .eslintrc.json 文件中设置为 0,但它仍然不会 lint。使用内联注释禁用 eslint 也不起作用。
我应该怎么办?我是否以错误的方式使用 Superagent,或者是否有我必须禁用的规则?
编辑:这个问题被标记为这个问题的重复。然而,这个问题没有使用 linter,并且有不同的错误消息。这里的问题是 eslint 将看似有效的语法标记为错误。
javascript ×2
ecmascript-6 ×1
es6-promise ×1
eslint ×1
generator ×1
iterator ×1
node.js ×1
python ×1
superagent ×1