@thi.ng/strings
Advanced tools
Comparing version 3.4.13 to 3.5.0
# Change Log | ||
- **Last updated**: 2023-08-27T11:20:59Z | ||
- **Last updated**: 2023-09-15T12:33:37Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,12 @@ | ||
## [3.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.5.0) (2023-09-15) | ||
#### 🚀 Features | ||
- add more HTML entities ([9fa5d91](https://github.com/thi-ng/umbrella/commit/9fa5d91)) | ||
- add support for numeric HTML entities ([8d942ba](https://github.com/thi-ng/umbrella/commit/8d942ba)) | ||
- add `RE_ENTITIES_NUM` | ||
- update unescapeEntities() to also support numeric entities | ||
- add unitless() formatter ([d5025ce](https://github.com/thi-ng/umbrella/commit/d5025ce)) | ||
### [3.4.12](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.4.12) (2023-08-22) | ||
@@ -14,0 +24,0 @@ |
@@ -11,4 +11,5 @@ /** | ||
export declare const RE_ENTITIES_REV: RegExp; | ||
export declare const RE_ENTITIES_NUM: RegExp; | ||
export declare const escapeEntities: (src: string) => string; | ||
export declare const unescapeEntities: (src: string) => string; | ||
//# sourceMappingURL=entities.d.ts.map |
@@ -23,2 +23,5 @@ /** | ||
"£": "£", | ||
"¥": "¥", | ||
"₹": "₹", | ||
元: "元", | ||
"§": "§", | ||
@@ -29,2 +32,5 @@ "¶": "¶", | ||
"™": "™", | ||
"℃": "℃", | ||
"℉": "℉", | ||
K: "K", | ||
"◂": "◂", | ||
@@ -47,2 +53,21 @@ "▸": "▸", | ||
"³": "³", | ||
"½": "½", | ||
"⅓": "⅓", | ||
"⅔": "⅔", | ||
"¼": "¼", | ||
"¾": "¾", | ||
"⅕": "⅕", | ||
"⅙": "⅙", | ||
"⅛": "⅛", | ||
Ä: "Ä", | ||
Ë: "Ë", | ||
Ï: "Ï", | ||
Ö: "Ö", | ||
Ü: "Ü", | ||
ä: "ä", | ||
ë: "ë", | ||
ï: "ï", | ||
ö: "ö", | ||
ü: "ü", | ||
ß: "ß", | ||
α: "α", | ||
@@ -94,4 +119,7 @@ β: "β", | ||
export const RE_ENTITIES_REV = new RegExp(`(${Object.keys(ENTITIES_REV).join("|")})`, "g"); | ||
export const RE_ENTITIES_NUM = /&#(x?)([0-9a-f]+);/gi; | ||
const $esc = (re, index) => (src) => src.replace(re, (x) => index[x]); | ||
export const escapeEntities = $esc(RE_ENTITIES, ENTITIES); | ||
export const unescapeEntities = $esc(RE_ENTITIES_REV, ENTITIES_REV); | ||
export const unescapeEntities = (src) => src | ||
.replace(RE_ENTITIES_REV, (x) => ENTITIES_REV[x]) | ||
.replace(RE_ENTITIES_NUM, (_, hex, x) => String.fromCharCode(parseInt(x, hex ? 16 : 10))); |
{ | ||
"name": "@thi.ng/strings", | ||
"version": "3.4.13", | ||
"version": "3.5.0", | ||
"description": "Various string formatting & utility functions", | ||
@@ -203,3 +203,3 @@ "type": "module", | ||
}, | ||
"gitHead": "5929dd20497668496af13415cdf784a4d6f69aa3\n" | ||
"gitHead": "b2ef5a1b8932d067af4ec2fc7da03d59d6868dc7\n" | ||
} |
@@ -144,3 +144,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (brotli'd, pre-treeshake): ESM: 4.61 KB | ||
Package sizes (brotli'd, pre-treeshake): ESM: 4.84 KB | ||
@@ -162,9 +162,10 @@ ## Dependencies | ||
| Screenshot | Description | Live demo | Source | | ||
|:---------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------| | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/big-font.png" width="240"/> | Large ASCII font text generator using @thi.ng/rdom | [Demo](https://demo.thi.ng/umbrella/big-font/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/big-font) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/crypto-chart.png" width="240"/> | Basic crypto-currency candle chart with multiple moving averages plots | [Demo](https://demo.thi.ng/umbrella/crypto-chart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/crypto-chart) | | ||
| | Basic SPA example with atom-based UI router | [Demo](https://demo.thi.ng/umbrella/login-form/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/login-form) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/xml-converter.png" width="240"/> | XML/HTML/SVG to hiccup/JS conversion | [Demo](https://demo.thi.ng/umbrella/xml-converter/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/xml-converter) | | ||
| Screenshot | Description | Live demo | Source | | ||
|:---------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------| | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/big-font.png" width="240"/> | Large ASCII font text generator using @thi.ng/rdom | [Demo](https://demo.thi.ng/umbrella/big-font/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/big-font) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/crypto-chart.png" width="240"/> | Basic crypto-currency candle chart with multiple moving averages plots | [Demo](https://demo.thi.ng/umbrella/crypto-chart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/crypto-chart) | | ||
| | Basic SPA example with atom-based UI router | [Demo](https://demo.thi.ng/umbrella/login-form/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/login-form) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mastodon-feed.jpg" width="240"/> | Mastodon API feed reader with support for different media types, fullscreen media modal, HTML rewriting | [Demo](https://demo.thi.ng/umbrella/mastodon-feed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mastodon-feed) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) | | ||
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/xml-converter.png" width="240"/> | XML/HTML/SVG to hiccup/JS conversion | [Demo](https://demo.thi.ng/umbrella/xml-converter/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/xml-converter) | | ||
@@ -171,0 +172,0 @@ ## API |
@@ -9,3 +9,4 @@ import type { Stringer } from "./api.js"; | ||
export declare const grams: Stringer<number>; | ||
export declare const unitless: Stringer<number>; | ||
export {}; | ||
//# sourceMappingURL=units.d.ts.map |
13
units.js
@@ -69,1 +69,14 @@ import { memoizeJ } from "@thi.ng/memoize/memoizej"; | ||
], " g", 2); | ||
export const unitless = units([ | ||
[1e-15, "f", 1], | ||
[1e-12, "p", 1], | ||
[1e-9, "n", 1], | ||
[1e-6, "µ", 1], | ||
[1e-3, "m", 1], | ||
[1, ""], | ||
[1e3, "k", 1], | ||
[1e6, "M", 1], | ||
[1e9, "G", 1], | ||
[1e12, "T", 1], | ||
[1e15, "P", 1], | ||
], "", 0); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104079
2254
213