@thi.ng/strings 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2021-11-21T17:09:28Z
3
+ - **Last updated**: 2021-12-02T00:12:39Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.3.0) (2021-12-02)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add currency formatters ([52b7340](https://github.com/thi-ng/umbrella/commit/52b7340))
17
+
12
18
  ## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.2.0) (2021-11-17)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -32,7 +32,7 @@ This project is part of the
32
32
 
33
33
  ## About
34
34
 
35
- Various (80+) string formatting, word wrapping & utility functions, some
35
+ Various (~100) string formatting, word wrapping & utility functions, some
36
36
  higher-order, some memoized.
37
37
 
38
38
  Partially based on Clojure version of [thi.ng/strf](http://thi.ng/strf).
@@ -48,6 +48,7 @@ Partially based on Clojure version of [thi.ng/strf](http://thi.ng/strf).
48
48
 
49
49
  ### Numeric formatters
50
50
 
51
+ - `currency` / `chf` / `eur` / `gpb` / `usd` / `yen`
51
52
  - `radix`
52
53
  - `int` / `intLocale`
53
54
  - `float` / `floatFixedWidth`
@@ -142,7 +143,7 @@ node --experimental-repl-await
142
143
  > const strings = await import("@thi.ng/strings");
143
144
  ```
144
145
 
145
- Package sizes (gzipped, pre-treeshake): ESM: 4.53 KB
146
+ Package sizes (gzipped, pre-treeshake): ESM: 4.63 KB
146
147
 
147
148
  ## Dependencies
148
149
 
package/currency.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { Stringer } from "./api.js";
2
+ export declare const currency: (sym: string, pre?: boolean | undefined, prec?: number | undefined) => Stringer<number>;
3
+ export declare const chf: Stringer<number>;
4
+ export declare const eur: Stringer<number>;
5
+ export declare const gbp: Stringer<number>;
6
+ export declare const usd: Stringer<number>;
7
+ export declare const yen: Stringer<number>;
8
+ //# sourceMappingURL=currency.d.ts.map
package/currency.js ADDED
@@ -0,0 +1,10 @@
1
+ import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
+ export const currency = memoizeJ((sym, pre = true, prec = 2) => {
3
+ const ff = (x) => x.toFixed(prec);
4
+ return pre ? (x) => sym + ff(x) : (x) => ff(x) + sym;
5
+ });
6
+ export const chf = currency("CHF ");
7
+ export const eur = currency("€");
8
+ export const gbp = currency("£");
9
+ export const usd = currency("$");
10
+ export const yen = currency("¥");
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./api.js";
2
2
  export * from "./ansi.js";
3
3
  export * from "./case.js";
4
4
  export * from "./center.js";
5
+ export * from "./currency.js";
5
6
  export * from "./cursor.js";
6
7
  export * from "./entities.js";
7
8
  export * from "./escape.js";
package/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "./api.js";
2
2
  export * from "./ansi.js";
3
3
  export * from "./case.js";
4
4
  export * from "./center.js";
5
+ export * from "./currency.js";
5
6
  export * from "./cursor.js";
6
7
  export * from "./entities.js";
7
8
  export * from "./escape.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "Various string formatting & utility functions",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -97,6 +97,9 @@
97
97
  "./center": {
98
98
  "import": "./center.js"
99
99
  },
100
+ "./currency": {
101
+ "import": "./currency.js"
102
+ },
100
103
  "./cursor": {
101
104
  "import": "./cursor.js"
102
105
  },
@@ -197,5 +200,5 @@
197
200
  "thi.ng": {
198
201
  "year": 2015
199
202
  },
200
- "gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
203
+ "gitHead": "32cf1a96854f9bb97aca65ffa05ca862ea377059\n"
201
204
  }