nodejs随记04

aes加密

资料

process

  • 改变工作目录: process.chdir(path);

路径计算

获取调用执行所在文件地址

function getCaller() {
  try {
    var err = new Error();
    var callerfile;
    var currentfile;
    var origPrepareStackTrace = Error.prepareStackTrace;

    Error.prepareStackTrace = function (err, stack) { return stack; };
    currentfile = err.stack.shift().getFileName();
    Error.prepareStackTrace = origPrepareStackTrace;

    while (err.stack.length) {
      callerfile = err.stack.shift().getFileName();
      if(currentfile !== callerfile) return callerfile;
    }
  } catch (err) {}
  return undefined;
};
  • 相关: a, b, c;

计算运行时间

console.time('test');
.....
console.timeEnd('test');
posted @ 2015-12-22 15:35  JinksPeng  阅读(189)  评论(0编辑  收藏  举报