JSPM

7xia-utils

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q34771F
    • License ISC

    提供了日期格式化, html字符转译等功能

    Package Exports

    • 7xia-utils
    • 7xia-utils/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 (7xia-utils) 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 7xia-utils or npm i 7xia-utils

    导入

    const 7xiaUtils = require('7xia-utils')

    日期格式化

    // 调用 dateFormat 传入一个日期 对时间格式进行处理
    const date = 7xiaUtils.dateFormat(new Date())
    console.log('北京时间:' + date)
    // 2023-03-28 11:11:59

    escape HTML字符转译

    // 调用 htmlEscape 对HTML字符进行转译
    const str = '<h1 title="a" >这是<span>h1</span>标签</h1>'
    const scape = 7xiaUtils.htmlEscape(str)
    console.log(8, scape)
    // &lt;h1 title=&quot;a&quot; &gt;这是h1标签&lt;/h1&gt

    还原HTML特殊字符转译

    // 调用 htmlUnEscape 还原已转译的HTML特殊字符
    const unScape = time.htmlUnEscape(scape)
    console.log(11, unScape)
    // <h1 title="a" >这是<span>h1</span>标签</h1>

    开源协议

    ISC