javascript - 如何在 module.exports 中调用多个函数
问题描述
我有一个单独的 js 文件中的函数列表。需要在 node.js 中调用整个文件。这些函数负责创建 j3pop 标头。代码如下所示:
(function1{}())
(function2{}())
(function3{}())
如何将它们全部导出并按顺序调用?
这就是我在文件中获得第三个函数的方式:
module.exports = { (function() {
'use strict';
console.log("inside");
var afterReadyCbCalled = false;
var originalHeaders = ["X-Origin-DC", "gytp","Cache-Control", "max-age=0","X-Forwarded-For", "103.255.4.53","X-Client-SrcPort", "45244","Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Language", "en-US,en;q=0.5","X-Forwarded-Proto", "https","X-TLS-Version", "771","Upgrade-Insecure-Requests", "1","ISTL-REFERER", "https://www.sahibinden.com/",];
var originalBody = "";
function afterReadyCb() {
if (afterReadyCbCalled) return;
afterReadyCbCalled = true;
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var isValid = xhr.getResponseHeader("ISTL-INFINITE-LOOP");
if (isValid != null && isValid != '') return;
var a = xhr.getResponseHeader("ISTL-REDIRECT-TO");
if (a != null && a != '') {
location.replace(a);
} else {
if (window.history != null && typeof history.replaceState === 'function') {
var responseURL = xhr.responseURL != null ? xhr.responseURL : xhr.getResponseHeader("ISTL-RESPONSE-URL");
if (responseURL != null && responseURL != '') {
history.replaceState(null, '', responseURL);
}
}
document.open();
document.write(xhr.responseText);
document.close();
}
};
xhr.open("get", location.href, true);
for (var i = 0; i < originalHeaders.length; i += 2) {
var headerName = originalHeaders[i];
try {
xhr.setRequestHeader(headerName, originalHeaders[i + 1]);
} catch (e) {}
}
xhr.setRequestHeader("ISTL-INFINITE-LOOP", '1');
xhr.send(originalBody);
var evt = document.createEvent('Event');
evt.initEvent('QLpZFJdHv', true, true);
dispatchEvent(evt);
}
addEventListener('afterReady', afterReadyCb, false);
setTimeout(afterReadyCb, 400);
}());
}
不知道休息
解决方案
会不会只是:
module.exports = {
(function() {
(function() {})()
(function() {})()
(function() {})()
})()
}
推荐阅读
- c# - Get specific string after specific character
- c# - Reflection vs MEF or both
- javascript - 第 105:14 行:“accountSelector”未定义 no-undef
- javascript - Trying to use AngularFire's Cloud Messaging Angular module throws Missing App configuration values
- selenium-webdriver - 为 UI 自动化隐藏用户名/密码的最佳实践
- r - Purrr For 循环的实现
- python - 如何使用追加将循环中的计算值放入数组中
- android - 如何将焦点从 RowsSupportFragment 的行移动到下一个布局组件?
- typescript - Angular 7:ActivateRoute 捕获 paramId 获取空值
- react-native - 显示下拉警报后 UI 被阻止