node.js

设置镜像方法 npm config set registry https://registry.npm.taobao.org

查看config的registry方法 npm config get registry

1.编写简单的node.js扩展

参照:https://github.com/nodejs/node/tree/master/test/addons/hello-world

2.使用npm无法安装的库,可以在https://www.npmjs.com/search?q=libxmljs    上下载源码,自己使用node-gyp进行安装

.gyp文件用来定位编译属性,node-gyp根据该configure文件创建VS解决方案,使用 node-gyp  build目标文件

gyp是为Chromium项目创建的项目生成工具,可以从平台无关的配置生成平台相关的Visual Studio、Xcode、Makefile的项目文件。这样一来我们就不需要花额外的时间处理每个平台不同的项目配置以及项目之间的依赖关系。长久以来 linux 的二进制分发一直是巨坑,npm 为了方便干脆就直接源码分发,用户装的时候再现场编译。不过对另一些人二进制分发就比源码分发简单多了,所以还有个 node-pre-gyp 来干二进制扩展的分发。

3.node.js操作redis

3.1 连接redis

myRedis = require("redis");
cliRedis = myRedis.createClient(6379, "192.168.74.139", {});

//断链后自动通知,自动重连

cliRedis.on('error', function (err) {
    console.log("error............" + err);
});
cliRedis.on('ready', function (res) {
    console.log("ready............");

3.1选择数据库:

cliRedis.select('0', function (res) {});   //数据库索引是字符串
cliRedis.SELECT(15, function (res) {});

4.时间转换

var time = new Date(1456909271692);
//var time = new Date();
console.log(time.toLocaleDateString()); //年月字符串
console.log(time.toLocaleString()); //时间字符串
console.log(time.toLocaleTimeString()); //时间字符串

5.正则表达式

http://deerchao.net/tutorials/regex/regex.htm

6.时间大小比较

var a = Date.parse("2016-07-29 10:27:11");
      var b = Date.parse("2016-07-29 10:27:12");
      if(a < b)
      {
      alert("a < b")
     
      }
      else{
      alert("a > b")
      }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值