Node
风澈云间
这个作者很懒,什么都没留下…
展开
-
Node 命令行读取当前目录下的文件(转自《了不起的Node》)
/** * Module dependencies*/var fs = require('fs');var stdin = process.stdin;var stdout = process.stdout;var stats = [];fs.readdir(process.cwd(),function(err,files){ console.log(''); if(!file转载 2014-05-22 17:18:39 · 951 阅读 · 0 评论 -
Node 事件监听和分发 Event Emitter(转自《了不起的Node》)
var EventEmitter = require('events').EventEmitter;var a = new EventEmitter;a.on('event',function() { console.log('event called');});a.emit('event');转载 2014-05-21 22:40:23 · 684 阅读 · 0 评论 -
node 暴漏模块中的api(转自了不起的node)
exports.name = "json";exports.des = "node.js";var local = "a var";exports.local = function (){ return local;};转载 2014-05-21 21:17:05 · 510 阅读 · 0 评论 -
node 实现获取时间发生间隔
Date.prototype.__defineGetter__('ago',function(){ var diff = (((new Date()).getTime() - this.getTime()) / 1000); var day_diff = Math.floor(diff / 86400); return (day_diff == 0 && (diff < 60 && " ju转载 2014-05-21 20:46:29 · 723 阅读 · 0 评论