Commit d9945c0f authored by Scott Sun's avatar Scott Sun

scott

parent 57aed9de
var cs = require('console');
var dog = {}
dog.name = "大毛"
dog.color= "绿色"
print("输出普通信息:")
cs.log('result:%s', 'test%s')
cs.log('result:%d', 144)
cs.log('result:%i', 244)
cs.log('result:%f', 123.412)
cs.log('result:%o', dog)
cs.log('result:%j', {name:"haha", age:16})
cs.log('%c', 'color:blue;')
print("输出提示信息:")
cs.info('result:%s', 'test%s')
cs.info('result:%d', 144)
cs.info('result:%i', 244)
cs.info('result:%f', 123.412)
cs.info('result:%o', dog)
cs.info('result:%j', {name:"haha", age:16})
cs.info('%c', 'color:blue;')
print("输出调试信息:")
cs.debug('result:%s', 'test%s')
cs.debug('result:%d', 144)
cs.debug('result:%i', 244)
cs.debug('result:%f', 123.412)
cs.debug('result:%o', dog)
cs.debug('result:%j', {name:"haha", age:16})
cs.debug('%c', 'color:blue;')
print("输出警告信息:")
cs.warn('result:%s', 'test%s')
cs.warn('result:%d', 144)
cs.warn('result:%i', 244)
cs.warn('result:%f', 123.412)
cs.warn('result:%o', dog)
cs.warn('result:%j', {name:"haha", age:16})
cs.warn('%c', 'color:blue;')
print("输出错误信息:")
cs.error('result:%s', 'test%s')
cs.error('result:%d', 144)
cs.error('result:%i', 244)
cs.error('result:%f', 123.412)
cs.error('result:%o', dog)
cs.error('result:%j', {name:"haha", age:16})
cs.error('%c', 'color:blue;')
print("控制台断言:")
cs.assert(false,'%s','job1')
cs.assert(true,'%s','job2')
var Events = require('events')
var process = require('process')
var os = require('os')
var evt = new Events()
evt.on("myevent", function(time){
console.log(time, "On Myevent")
})
evt.on("myemit", function(time, item){
console.log(time, "good" + item)
})
for(var i = 0; i < 10; i++) {
evt.emit("myevent", os.getNow());
if(i === 5) {
evt.clearEvent('myevent');
break
}
}
evt.emit('myemit', os.getNow(), 'job');
process.mainLoop();
\ No newline at end of file
...@@ -2,11 +2,22 @@ ...@@ -2,11 +2,22 @@
var _ = require('lodash'); var _ = require('lodash');
// 查看当前包路径 // 查看当前包路径
print(__package__.libraryPaths()); print(__package__.libraryPaths());
var process = require('process');
_.forEach(process.argv, function(n){
print("argv = " + n);
});
// 打印命令行参数 // 打印命令行参数
var arr = [1,2,3,5,8] var arr = [1,2,3,5,8]
var res = _.forEach(arr, function(n){ var res = _.forEach(arr, function(n){
print(n) print(n)
}); });
print(res) print(res)
\ No newline at end of file
var list = [ { "name": "小米" }, { "ark": [ 1, 2, 3 ] }, { "personData": [ { "type": "a" }, { "type": "b", "children": [ "asd", "dasd" ] } ] } ]
var dc = require("deepcopy")
var list2 = dc(list)
list2[1]['ark']=212
console.log(list)
console.log(list2)
\ No newline at end of file
...@@ -2,3 +2,11 @@ ...@@ -2,3 +2,11 @@
## 2019-12-26 ## 2019-12-26
* 入门
1. tjspm的基本使用
2. 开发一个包 深拷贝 deepcopy
3. 加密生成jsc文件
* api核心
1. console
2. events
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment