Skip to content

Commit 59c7b5a

Browse files
committed
not use arguments in define function
1 parent d2c6d01 commit 59c7b5a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/esl.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ var require;
198198
}
199199

200200
if (hangModules.length || missModules.length) {
201-
throw new Error('[MODULE_TIMEOUT]Hang( '
201+
throw new Error(
202+
'[MODULE_TIMEOUT]Hang( '
202203
+ (hangModules.join(', ') || 'none')
203204
+ ' ) Miss( '
204205
+ (missModules.join(', ') || 'none')
@@ -223,25 +224,25 @@ var require;
223224
* @param {Array=} dependencies 依赖模块列表
224225
* @param {Function=} factory 创建模块的工厂方法
225226
*/
226-
function define() {
227-
var argsLen = arguments.length;
228-
if (!argsLen) {
227+
function define(id, dependencies, factory) {
228+
if (!arguments.length) {
229229
return;
230230
}
231231

232-
var id;
233-
var dependencies;
234-
var factory = arguments[--argsLen];
235-
236-
while (argsLen--) {
237-
var arg = arguments[argsLen];
238-
239-
if (typeof arg === 'string') {
240-
id = arg;
232+
if (typeof id !== 'string') {
233+
if (id instanceof Array) {
234+
factory = dependencies;
235+
dependencies = id;
241236
}
242-
else if (arg instanceof Array) {
243-
dependencies = arg;
237+
else {
238+
factory = id;
239+
dependencies = null;
244240
}
241+
id = null;
242+
}
243+
else if (!(dependencies instanceof Array)) {
244+
factory = dependencies;
245+
dependencies = null;
245246
}
246247

247248
// 出现window不是疏忽

0 commit comments

Comments
 (0)