首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

About nginScript

  • 目前支持什么
  • 什么不支持呢
  • 下载并安装
  • 作为Linux软件包进行安装
  • 从源头上构建

nginScript是JavaScript语言的一个子集,它允许在http和stream中实现位置和变量处理程序。nginScript是根据ECMAScript 5.1和一些ECMAScript 6扩展创建的。合规性仍在不断发展。

目前支持什么

  • 布尔值,数字,字符串,对象,数组,函数和正则表达式
  • ES5.1操作符,ES7指数操作符
  • ES5.1声明:varifelseswitchforfor inwhiledo whilebreakcontinuereturntrycatchthrowfinally
  • ES6 NumberMath属性和方法
  • String 方法:
    • ES5.1: ,fromCharCodeconcatslicesubstringsubstrcharAtcharCodeAtindexOflastIndexOftoLowerCasetoUpperCasetrimsearch,,matchsplitreplace
    • ES6: ,fromCodePointcodePointAtincludes,,startsWithendsWithrepeat
    • 非标:fromUTF8toUTF8fromBytestoBytes
  • Object 方法:
    • ES5.1: create(无属性列表的支持), ,keysdefinePropertydefinePropertiesgetOwnPropertyDescriptorgetPrototypeOfhasOwnPropertyisPrototypeOfpreventExtensionsisExtensiblefreeze,,isFrozensealisSealed
  • Array 方法:
    • ES5.1: ,isArrayslicesplicepushpopunshiftshiftreversesortjoinconcatindexOflastIndexOfforEachsomeeveryfilter,,mapreducereduceRight
    • ES6: ,of,,fillfindfindIndex
    • ES7: includes
  • ES5.1 Function方法:callapplybind
  • ES5.1 RegExp方法:testexec
  • ES5.1 Date方法
  • ES5.1全局函数:isFiniteisNaNparseFloatparseIntdecodeURIdecodeURIComponentencodeURIencodeURIComponent

什么不支持呢

  • ES6 letconst声明
  • 标签
  • arguments 排列
  • eval 功能
  • JSON 目的
  • Error 目的
  • setTimeoutsetIntervalsetImmediate功能
  • 非整数分数(.235),二进制(0b0101),八进制(0o77)文字

下载与安装

nginScript有两个模块可用:

  • ngx_http_js_module
  • ngx_stream_js_module

这两个模块都不是默认生成的,它们应该从源代码编译或作为Linux软件包安装。

作为Linux软件包进行安装

对于Linux,可以使用nginScript模块

  • nginx-module-njs - nginScript动态模块
  • nginx-module-njs-dbg- 调试nginx-module-njs包的符号

从源头上构建

可以使用以下命令复制具有nginScript源的存储库:(需要Mercurial客户端):

代码语言:javascript
复制
hg clone http://hg.nginx.org/njs

然后,模块应该使用--add-module配置参数进行编译:

代码语言:javascript
复制
./configure --add-module=path-to-njs/nginx

这些模块也可以构建为动态:

代码语言:javascript
复制
./configure --add-dynamic-module=path-to-njs/nginx

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com