{"id":16779035,"url":"https://github.com/liby/hexo-util-rs","last_synced_at":"2025-10-01T08:30:33.537Z","repository":{"id":43229868,"uuid":"511086571","full_name":"liby/hexo-util-rs","owner":"liby","description":"High performance Hexo util binding to Node.js.","archived":false,"fork":false,"pushed_at":"2024-12-29T16:34:55.000Z","size":7749,"stargazers_count":14,"open_issues_count":12,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T20:05:38.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@libyo/hexo-util","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-06T10:13:14.000Z","updated_at":"2024-04-22T04:34:31.000Z","dependencies_parsed_at":"2023-11-25T05:21:50.101Z","dependency_job_id":"4691354a-aaae-468e-873a-f3bbffbc7bf2","html_url":"https://github.com/liby/hexo-util-rs","commit_stats":{"total_commits":111,"total_committers":7,"mean_commits":"15.857142857142858","dds":0.6036036036036037,"last_synced_commit":"b8ca899e51e89ae6e72ed1155faea757739d4b0c"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liby%2Fhexo-util-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liby%2Fhexo-util-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liby%2Fhexo-util-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liby%2Fhexo-util-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liby","download_url":"https://codeload.github.com/liby/hexo-util-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234841993,"owners_count":18895143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T07:29:14.305Z","updated_at":"2025-10-01T08:30:28.113Z","avatar_url":"https://github.com/liby.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@napi-rs/hexo-util` · [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![https://github.com/liby/hexo-util-rs/actions](https://github.com/liby/hexo-util-rs/workflows/CI/badge.svg)](https://github.com/liby/hexo-util-rs/actions) [![NPM version](https://badge.fury.io/js/@libyo%2Fhexo-util.svg)](https://www.npmjs.com/package/@libyo/hexo-util)\n\n\u003e **Note**\n\u003e\n\u003e Utilities for Hexo.\n\u003e Generated from [napi-rs/package-template](https://github.com/napi-rs/package-template).\n\n\u003e **Warning**\n\u003e\n\u003e This project is in Beta stage. And there may some bugs existed.\n\n## Installation\n\n```bash\n$ npm install @libyo/hexo-util\n// or\n$ yarn add @libyo/hexo-util\n// or\n$ pnpm add @libyo/hexo-util\n```\n\n## Usage\n\n```js\nconst util = require('@libyo/hexo-util')\n```\n\n| Function name                              | Is RIIR |                                                                             Usage                                                                              | Is Rename                        |\n| :----------------------------------------- | ------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------- |\n| `Cache()`                                  |      No |                                            [A simple plain object cache](https://github.com/hexojs/hexo-util#cache)                                            |                                  |\n| `CacheStream()`                            |      No |                                     [Caches contents piped to the stream](https://github.com/hexojs/hexo-util#cachestream)                                     |                                  |\n| `camelCaseKeys(obj, options)`              |      No |                                [Convert object keys to camelCase](https://github.com/hexojs/hexo-util#camelcasekeysobj-options)                                |                                  |\n| `createSha1Hash()`                         |      No |                                         [Return SHA1 hash object](https://github.com/hexojs/hexo-util#createsha1hash)                                          |                                  |\n| `decodeUrl(str)`                           |     Yes |                                         [Decode encoded URL or path](https://github.com/hexojs/hexo-util#decodeurlstr)                                         | `decodeURL` =\u003e `decodeUrl`       |\n| `deepMerge(target, source)`                |      No |                      [Merges the enumerable properties of two objects deeply](https://github.com/hexojs/hexo-util#deepmergetarget-source)                      |                                  |\n| `encodeUrl(str)`                           |     Yes |                                   [Encode URL or path into a safe format](https://github.com/hexojs/hexo-util#encodeurlstr)                                    | `encodeURL` =\u003e `encodeUrl`       |\n| `escapeDiacritic(str)`                     |     Yes |                               [Escapes diacritic characters in a string](https://github.com/hexojs/hexo-util#escapediacriticstr)                               |                                  |\n| `escapeHtml(str)`                          |     Yes |                                    [Escapes HTML entities in a string.](https://github.com/hexojs/hexo-util#escapehtmlstr)                                     | `escapeHTML` =\u003e `escapeHtml`     |\n| `escapeRegExp(str)`                        |     Yes |                            [Escapes special characters in a regular expression](https://github.com/hexojs/hexo-util#escaperegexstr)                            | `escapeRegex` =\u003e `escapeRegExp`  |\n| `full_url_for(path)`                       |      No |                               [Returns a url with the config.url prefixed](https://github.com/hexojs/hexo-util#full_url_forpath)                               | `full_url_for` =\u003e `fullUrlFor`   |\n| `gravatar(str, [options])`                 |      No |                            [Returns the gravatar image url from an email](https://github.com/hexojs/hexo-util#gravatarstr-options)                             |                                  |\n| `hash(str)`                                |      No |                                               [Generates SHA1 hash](https://github.com/hexojs/hexo-util#hashstr)                                               |                                  |\n| `highlight(str, [options])`                |      No |                                [Syntax highlighting for a code block](https://github.com/hexojs/hexo-util#highlightstr-options)                                |                                  |\n| `htmlTag(tag, attrs, text, escape)`        |      No |                                     [Creates a html tag](https://github.com/hexojs/hexo-util#htmltagtag-attrs-text-escape)                                     |                                  |\n| `isExternalLink(url, sitehost, [exclude])` |     Yes | [Returns if a given url is external link relative to given `sitehost` and `[exclude]`](https://github.com/hexojs/hexo-util#isexternallinkurl-sitehost-exclude) |                                  |\n| `Pattern(rule)`                            |      No |                         [Parses the string and tests if the string matches the rule](https://github.com/hexojs/hexo-util#patternrule)                          |                                  |\n| `Permalink(rule, [options])`               |      No |                                        [Parses a permalink](https://github.com/hexojs/hexo-util#permalinkrule-options)                                         |                                  |\n| `prettyUrls(url, [options])`               |     n/a |                                    [Rewrite urls to pretty URLs](https://github.com/hexojs/hexo-util#prettyurlsurl-options)                                    |                                  |\n| `prismHighlight(str, [options])`           |      No |                      [Syntax highlighting for a code block using PrismJS](https://github.com/hexojs/hexo-util#prismhighlightstr-options)                       |                                  |\n| `relativeUrl(from, to)`                    |      No |                              [Returns the relative URL from from to to](https://github.com/hexojs/hexo-util#relative_urlfrom-to)                               | `relative_url` =\u003e `relativeUrl`  |\n| `slugize(str, [options])`                  |     Yes |                         [Transforms a string into a clean URL-friendly string](https://github.com/hexojs/hexo-util#slugizestr-options)                         |                                  |\n| `spawn(command, [args], [options])`        |      No |                         [Launches a new process with the given command](https://github.com/hexojs/hexo-util#spawncommand-args-options)                         |                                  |\n| `stripTags(str)`                           |     Yes |                                       [Removes HTML tags in a string](https://github.com/hexojs/hexo-util#striphtmlstr)                                        | `stripHTML` =\u003e `stripTags`       |\n| `stripIndent(str)`                         |     Yes |                           [Strip leading whitespace from each line in a string](https://github.com/hexojs/hexo-util#stripindentstr)                            |                                  |\n| `wordWrap(str, [options])`                 |     n/a |                             [Wraps the string no longer than line width](https://github.com/hexojs/hexo-util#wordwrapstr-options)                              |                                  |\n| `tocObj(str, [options])`                   |     n/a |              [Generate a table of contents in JSON format based on the given html string](https://github.com/hexojs/hexo-util#tocobjstr-options)               |                                  |\n| `truncate(str, [options])`                 |     n/a |              [Truncates a given text after a given length if text is longer than length](https://github.com/hexojs/hexo-util#truncatestr-options)              |                                  |\n| `unescapeHtml(str)`                        |     Yes |                                   [Unescapes HTML entities in a string](https://github.com/hexojs/hexo-util#unescapehtmlstr)                                   | `unescapeHTML` =\u003e `unescapeHtml` |\n| `urlFor(path, [option])`                   |      No |                              [Returns a url with the root path prefixed](https://github.com/hexojs/hexo-util#url_forpath-option)                               | `url_for` =\u003e `urlFor`            |\n\n\u003e **Note**\n\u003e\n\u003e [`full_url_for`, `url_for`, `relative_url` require `bind` or `call` to parse the user config when initializing](https://github.com/hexojs/hexo-util#bindhexo).\n\n## Performance\n\nSee [benchmark](https://github.com/liby/hexo-util-rs/tree/main/benchmark) for benchmark code.\n\nHardware info:\n\n```\nSystem Version: macOS 12.4 (21F79)\nKernel Version: Darwin 21.5.0\nProcessor Name: 8-Core Intel Core i9\nProcessor Speed: 2.3 GHz\nL2 Cache (per Core): 256 KB\nL3 Cache: 16 MB![img.png](img.png)\nMemory: 32 GB\n```\n\nBenchmark:\n\n\u003cdetails\u003e\n\u003csummary\u003eStrip HTML\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"mini fixture\" suite...\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    1 343 399 ops/s, ±0.55%   | 12.9% slower\n\n  hexo-util-rs:\n    1 542 449 ops/s, ±0.44%   | fastest\n\n  hexo-util:\n    933 979 ops/s, ±1.30%     | 39.45% slower\n\n  striptags:\n    466 526 ops/s, ±1.55%     | 69.75% slower\n\n  string-strip-html:\n    13 805 ops/s, ±11.48%      | slowest, 99.1% slower\n\nFinished 5 cases!\n  Fastest: hexo-util-rs\n  Slowest: string-strip-html\nRunning \"large fixture\" suite...\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    816 ops/s, ±2.62%   | fastest\n\n  hexo-util-rs:\n    631 ops/s, ±3.68%   | 22.67% slower\n\n  hexo-util:\n    285 ops/s, ±4.13%   | 65.07% slower\n\n  striptags:\n    141 ops/s, ±1.45%   | 82.72% slower\n\n  string-strip-html:\n    7 ops/s, ±8.74%     | slowest, 99.14% slower\n\nFinished 5 cases!\n  Fastest: hexo-util-rs-buffer\n  Slowest: string-strip-html\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSlugify\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"slugify and escape diacritic\" suite...\nProgress: 100%\n\n  hexo-util-rs:\n    1 104 153 ops/s, ±0.30%   | fastest\n\n  hexo-util:\n    255 709 ops/s, ±0.61%     | slowest, 76.84% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eisExternalLink\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"Internal absolute url\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    1 038 833 ops/s, ±0.37%\nProgress: 100%\n\n  hexo-util-rs:\n    1 038 833 ops/s, ±0.37%   | fastest\n\n  hexo-util:\n    214 596 ops/s, ±0.30%     | slowest, 79.34% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"External absolute url\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    953 787 ops/s, ±0.41%\nProgress: 100%\n\n  hexo-util-rs:\n    953 787 ops/s, ±0.41%   | fastest\n\n  hexo-util:\n    203 306 ops/s, ±0.45%   | slowest, 78.68% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Relative absolute url\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    42 956 520 ops/s, ±0.87%\nProgress: 100%\n\n  hexo-util-rs:\n    42 956 520 ops/s, ±0.87%   | fastest\n\n  hexo-util:\n    18 071 147 ops/s, ±0.63%   | slowest, 57.93% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEncode URL\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"Encode URL - auth\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    1 299 520 ops/s, ±0.86%\nProgress: 100%\n\n  hexo-util-rs:\n    1 299 520 ops/s, ±0.86%   | fastest\n\n  hexo-util:\n    255 364 ops/s, ±0.92%     | slowest, 80.35% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Encode URL - Internationalized domain name\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    599 196 ops/s, ±0.87%\nProgress: 100%\n\n  hexo-util-rs:\n    599 196 ops/s, ±0.87%   | fastest\n\n  hexo-util:\n    177 869 ops/s, ±1.89%   | slowest, 70.32% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Encode URL - path with unicode\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    1 348 834 ops/s, ±1.38%\nProgress: 100%\n\n  hexo-util-rs:\n    1 348 834 ops/s, ±1.38%   | fastest\n\n  hexo-util:\n    1 111 192 ops/s, ±7.06%   | slowest, 17.62% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eDecode URL\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"Decode URL - regular\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    1 632 744 ops/s, ±0.75%\nProgress: 100%\n\n  hexo-util-rs:\n    1 632 744 ops/s, ±0.75%   | fastest\n\n  hexo-util:\n    272 866 ops/s, ±1.70%     | slowest, 83.29% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Decode URL - path with space\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    2 630 212 ops/s, ±1.67%\nProgress: 100%\n\n  hexo-util-rs:\n    2 630 212 ops/s, ±1.67%   | fastest\n\n  hexo-util:\n    1 959 248 ops/s, ±0.72%   | slowest, 25.51% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Decode URL - space\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    1 228 376 ops/s, ±6.64%\nProgress: 100%\n\n  hexo-util-rs:\n    1 228 376 ops/s, ±6.64%   | fastest\n\n  hexo-util:\n    239 213 ops/s, ±1.72%     | slowest, 80.53% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Decode URL - hash and query\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    781 550 ops/s, ±1.90%\nProgress: 100%\n\n  hexo-util-rs:\n    781 550 ops/s, ±1.90%   | fastest\n\n  hexo-util:\n    166 420 ops/s, ±1.78%   | slowest, 78.71% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"Decode URL - Internationalized domain name\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    492 862 ops/s, ±6.49%\nProgress: 100%\n\n  hexo-util-rs:\n    492 862 ops/s, ±6.49%   | fastest\n\n  hexo-util:\n    155 205 ops/s, ±1.46%   | slowest, 68.51% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEscape Diacritic\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"default\" suite...\nProgress: 50%\n\n  hexo-util-rs:\n    4 152 262 ops/s, ±1.20%\nProgress: 100%\n\n  hexo-util-rs:\n    4 152 262 ops/s, ±1.20%   | fastest\n\n  hexo-util:\n    2 334 729 ops/s, ±1.62%   | slowest, 43.77% slower\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eUnescape HTML\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"mini fixture\" suite...\nProgress: 33%\n\n  hexo-util-rs-buffer:\n    996 155 ops/s, ±1.41%\nProgress: 67%\n\n  hexo-util-rs-buffer:\n    996 155 ops/s, ±1.41%\n\n  hexo-util-rs:\n    1 188 802 ops/s, ±0.36%\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    996 155 ops/s, ±1.41%     | 16.21% slower\n\n  hexo-util-rs:\n    1 188 802 ops/s, ±0.36%   | fastest\n\n  hexo-util:\n    677 794 ops/s, ±0.37%     | slowest, 42.99% slower\n\nFinished 3 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"large fixture\" suite...\nProgress: 33%\n\n  hexo-util-rs-buffer:\n    30 402 ops/s, ±0.64%\nProgress: 67%\n\n  hexo-util-rs-buffer:\n    30 402 ops/s, ±0.64%\n\n  hexo-util-rs:\n    27 585 ops/s, ±1.81%\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    30 402 ops/s, ±0.64%   | fastest\n\n  hexo-util-rs:\n    27 585 ops/s, ±1.81%   | 9.27% slower\n\n  hexo-util:\n    15 185 ops/s, ±0.58%   | slowest, 50.05% slower\n\nFinished 3 cases!\n  Fastest: hexo-util-rs-buffer\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEscape HTML\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"mini fixture\" suite...\nProgress: 33%\n\n  hexo-util-rs-buffer:\n    1 406 688 ops/s, ±2.06%\nProgress: 67%\n\n  hexo-util-rs-buffer:\n    1 406 688 ops/s, ±2.06%\n\n  hexo-util-rs:\n    2 013 858 ops/s, ±0.73%\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    1 406 688 ops/s, ±2.06%   | 30.15% slower\n\n  hexo-util-rs:\n    2 013 858 ops/s, ±0.73%   | fastest\n\n  hexo-util:\n    954 610 ops/s, ±0.40%     | slowest, 52.6% slower\n\nFinished 3 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\nRunning \"large fixture\" suite...\nProgress: 33%\n\n  hexo-util-rs-buffer:\n    101 859 ops/s, ±1.56%\nProgress: 67%\n\n  hexo-util-rs-buffer:\n    101 859 ops/s, ±1.56%\n\n  hexo-util-rs:\n    96 883 ops/s, ±2.48%\nProgress: 100%\n\n  hexo-util-rs-buffer:\n    101 859 ops/s, ±1.56%   | fastest\n\n  hexo-util-rs:\n    96 883 ops/s, ±2.48%    | 4.89% slower\n\n  hexo-util:\n    32 949 ops/s, ±1.36%    | slowest, 67.65% slower\n\nFinished 3 cases!\n  Fastest: hexo-util-rs-buffer\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEscape RegExp\u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"default\" suite...\nProgress: 50%\n  hexo-util-rs:\n    4 833 899 ops/s, ±0.47%\nProgress: 100%\n  hexo-util-rs:\n    4 833 899 ops/s, ±0.47%   | fastest\n  hexo-util:\n    3 128 195 ops/s, ±1.36%   | slowest, 35.29% slower\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWord Wrap \u003c/summary\u003e\n\n```\n❯ yarn bench\nRunning \"Word Wrap\" suite...\nProgress: 100%\n\n  hexo-util:\n    1 289 014 ops/s, ±0.41%   | slowest, 66.98% slower\n\n  hexo-util-rs:\n    3 903 226 ops/s, ±0.89%   | fastest\n\nFinished 2 cases!\n  Fastest: hexo-util-rs\n  Slowest: hexo-util\n```\n\n\u003c/details\u003e\n\n## License\n\n[MIT](https://github.com/liby/hexo-util-rs/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliby%2Fhexo-util-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliby%2Fhexo-util-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliby%2Fhexo-util-rs/lists"}