JSPM

rg-tools

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3
    • Score
      100M100P100Q35539F
    • License ISC

    提供了格式化时间、HTMLEscape相关的功能

    Package Exports

    • rg-tools
    • rg-tools/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rg-tools) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    安装

    npm install rg-tools

    导入

    const rango = require('rg-tools')

    格式化时间

    // 调用 dateFormat 对时间进行格式化
    let getTime = getDate.dateFormat(new Date())
    // 打印结果
    console.log(getTime) // 2023-04-11 20:08:55

    转义 HTML 中的特殊字符

    // 需转义的 HTML 字符串
    let htmlStr = '<a href="#">链接标签</a>'
    // 调用 htmlEscape 方法进行转义
    let getStr = getDate.htmlEscape(htmlStr)
    // 打印结果
    console.log(getStr) // &lt;a href=&quot;#&quot;&gt;链接标签&lt;/a&gt;

    还原 HTML 中的特殊字符

    // 调用 htmlEscape 方法进行还原
    let unStr = getDate.htmlUnEscape(getStr)
    // 打印结果
    console.log(getStr) // <a href="#">链接标签</a>

    开源协议

    ISC