- 主题:请教几个javascript的问题
一份代码里的:
var _ = require('underscore'), // 这种变量命名到底是是啥意思?
Promise = require("node-promise").Promise,
when = require("node-promise").when, //在node里找不到这个when 啊?
……
// execute the command
when(canExecute, function (canExecute){
if(canExecute){
when(that.genericCommand(cmd), function (result) {
promise.resolve(result);
}, function (error) {
promise.resolve(DriverResponse.Failure(Status.State.ERROR, DriverResponse.Errors.BAD_STATE));
}
);
} else {
promise.resolve(DriverResponse.Failure(Status.State.ERROR, DriverResponse.Errors.BAD_STATE));
}
});
--
FROM 106.39.16.*
require应该是JS依赖加载require.js的玩法
【 在 zhanghaoX 的大作中提到: 】
: 一份代码里的:
: var _ = require('underscore'), // 这种变量命名到底是是啥意思?
: Promise = require("node-promise").Promise,
: ...................
--
FROM 123.66.166.*
用在后端的就是commonJs方式 用在前端的就是CMD,AMD
--
FROM 124.207.174.*
【 在 zhanghaoX (环顾四方有效) 的大作中提到: 】
: 一份代码里的:
: var _ = require('underscore'), // 这种变量命名到底是是啥意思?
nothing special with _, just a name
just the name the library author sets as conventional
: Promise = require("node-promise").Promise,
: when = require("node-promise").when, //在node里找不到这个when 啊?
https://www.npmjs.com/package/node-promise
: ……
: // execute the command
: when(canExecute, function (canExecute){
: if(canExecute){
: when(that.genericCommand(cmd), function (result) {
: promise.resolve(result);
: }, function (error) {
: promise.resolve(DriverResponse.Failure(Status.State.ERROR, DriverResponse.Errors.BAD_STATE));
: }
: );
: } else {
: promise.resolve(DriverResponse.Failure(Status.State.ERROR, DriverResponse.Errors.BAD_STATE));
: }
: });
--
FROM 180.173.170.*
all module styles (that I know of) can be used both in node.js and browsers
【 在 wopie (山里人) 的大作中提到: 】
: 用在后端的就是commonJs方式 用在前端的就是CMD,AMD
--
FROM 180.173.170.*
浏览器加载模块要sea require之类支持才能做到
【 在 XeCycle 的大作中提到: 】
: all module styles (that I know of) can be used both in node.js and browsers
:
--
FROM 124.207.174.*
seajs? why create a chinese-specific sub-ecosystem in js.
go with ES6 modules, and have babel produce desired module styles.
browserify will be the canonical solution before HTTP/2.0 really gets in.
【 在 wopie (山里人) 的大作中提到: 】
: 浏览器加载模块要sea require之类支持才能做到
--
FROM 202.120.55.*