JSPM

joel-tools

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

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

    Package Exports

    • joel-tools
    • joel-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 (joel-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 joeltools

    导入

    const joeltools = require("./joel-tools");

    格式化时间

    // 调用 dateFormat 对时间进行格式化
    const dtStr = joeltools.dateFormat(new Date());
    // 结果 2025-09-16 17:31:36
    console.log(dtStr);

    转义 HTML 中的特殊字符

    // 带转换的 HTML 字符串
    const htmlStr = `<h1 class="title">Hello & welcome to my site</h1>`;
    // 调用 htmlEscape 方法进行转换
    const str = joeltools.htmlEscape(htmlStr);
    // 结果 &lt;h1 class=&quot;title&quot;&gt;Hello &amp; welcome to my site&lt;/h1&gt;
    console.log(str);

    还原 HTML 字符串

    // 调用 htmlUnEscape 方法进行转换
    const str2 = joeltools.htmlUnEscape(str);
    // 结果 <h1 class="title">Hello & welcome to my site</h1>
    console.log(str2);

    开源协议

    ISC