@thi.ng/strings 3.7.37 → 3.8.1
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 +7 -1
- package/README.md +6 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/named-number.d.ts +32 -0
- package/named-number.js +18 -0
- package/package.json +9 -6
- package/uuid.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-07-
|
|
3
|
+
- **Last updated**: 2024-07-22T13:15:57Z
|
|
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.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.8.0) (2024-07-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add namedNumber() ([979ad33](https://github.com/thi-ng/umbrella/commit/979ad33))
|
|
17
|
+
|
|
12
18
|
### [3.7.34](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.34) (2024-06-21)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
3
|
-
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/strings)
|
|
6
6
|

|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 198 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -151,7 +151,7 @@ For Node.js REPL:
|
|
|
151
151
|
const str = await import("@thi.ng/strings");
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 5.
|
|
154
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 5.52 KB
|
|
155
155
|
|
|
156
156
|
## Dependencies
|
|
157
157
|
|
|
@@ -160,9 +160,11 @@ Package sizes (brotli'd, pre-treeshake): ESM: 5.43 KB
|
|
|
160
160
|
- [@thi.ng/hex](https://github.com/thi-ng/umbrella/tree/develop/packages/hex)
|
|
161
161
|
- [@thi.ng/memoize](https://github.com/thi-ng/umbrella/tree/develop/packages/memoize)
|
|
162
162
|
|
|
163
|
+
Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
|
|
164
|
+
|
|
163
165
|
## Usage examples
|
|
164
166
|
|
|
165
|
-
|
|
167
|
+
Eight projects in this repo's
|
|
166
168
|
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
|
|
167
169
|
directory are using this package:
|
|
168
170
|
|
|
@@ -173,7 +175,6 @@ directory are using this package:
|
|
|
173
175
|
| <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) |
|
|
174
176
|
| | 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) |
|
|
175
177
|
| <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) |
|
|
176
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/procedural-text.jpg" width="240"/> | Procedural stochastic text generation via custom DSL, parse grammar & AST transformation | [Demo](https://demo.thi.ng/umbrella/procedural-text/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/procedural-text) |
|
|
177
178
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/render-audio.png" width="240"/> | Generative audio synth offline renderer and WAV file export | [Demo](https://demo.thi.ng/umbrella/render-audio/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/render-audio) |
|
|
178
179
|
| <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) |
|
|
179
180
|
| <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) |
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./initials.js";
|
|
|
14
14
|
export * from "./int.js";
|
|
15
15
|
export * from "./interpolate.js";
|
|
16
16
|
export * from "./join.js";
|
|
17
|
+
export * from "./named-number.js";
|
|
17
18
|
export * from "./pad-left.js";
|
|
18
19
|
export * from "./pad-right.js";
|
|
19
20
|
export * from "./parse.js";
|
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./initials.js";
|
|
|
14
14
|
export * from "./int.js";
|
|
15
15
|
export * from "./interpolate.js";
|
|
16
16
|
export * from "./join.js";
|
|
17
|
+
export * from "./named-number.js";
|
|
17
18
|
export * from "./pad-left.js";
|
|
18
19
|
export * from "./pad-right.js";
|
|
19
20
|
export * from "./parse.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Stringer } from "./api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Array of the english names of digits 0-9
|
|
4
|
+
*/
|
|
5
|
+
export declare const NAMED_DIGITS: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Higher-order formatter. Takes an array of named numbers (e.g. `["zero",
|
|
8
|
+
* "one", "two"...]`) and returns a function which accepts any number and either
|
|
9
|
+
* returns the corresponding name (from the given array) or otherwise the result
|
|
10
|
+
* of {@link int}.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* The default names used are {@link NAMED_DIGITS}.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts tangle:../export/named-number.ts
|
|
17
|
+
* import { namedNumber } from "@thi.ng/strings";
|
|
18
|
+
*
|
|
19
|
+
* console.log(namedNumber()(9));
|
|
20
|
+
* // "nine"
|
|
21
|
+
*
|
|
22
|
+
* console.log(namedNumber()(10));
|
|
23
|
+
* // "10"
|
|
24
|
+
*
|
|
25
|
+
* console.log(namedNumber(["null", "eins", "zwei"])(2));
|
|
26
|
+
* // "zwei"
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param names
|
|
30
|
+
*/
|
|
31
|
+
export declare const namedNumber: (names?: string[]) => Stringer<number>;
|
|
32
|
+
//# sourceMappingURL=named-number.d.ts.map
|
package/named-number.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { int } from "./int.js";
|
|
2
|
+
const NAMED_DIGITS = [
|
|
3
|
+
"zero",
|
|
4
|
+
"one",
|
|
5
|
+
"two",
|
|
6
|
+
"three",
|
|
7
|
+
"four",
|
|
8
|
+
"five",
|
|
9
|
+
"six",
|
|
10
|
+
"seven",
|
|
11
|
+
"eight",
|
|
12
|
+
"nine"
|
|
13
|
+
];
|
|
14
|
+
const namedNumber = (names = NAMED_DIGITS) => (x) => x >= 0 && x < names.length ? names[x | 0] : int(x);
|
|
15
|
+
export {
|
|
16
|
+
NAMED_DIGITS,
|
|
17
|
+
namedNumber
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/errors": "^2.5.
|
|
41
|
-
"@thi.ng/hex": "^2.3.
|
|
42
|
-
"@thi.ng/memoize": "^3.3.
|
|
39
|
+
"@thi.ng/api": "^8.11.7",
|
|
40
|
+
"@thi.ng/errors": "^2.5.13",
|
|
41
|
+
"@thi.ng/hex": "^2.3.51",
|
|
42
|
+
"@thi.ng/memoize": "^3.3.9"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-extractor": "^7.47.0",
|
|
@@ -133,6 +133,9 @@
|
|
|
133
133
|
"./join": {
|
|
134
134
|
"default": "./join.js"
|
|
135
135
|
},
|
|
136
|
+
"./named-number": {
|
|
137
|
+
"default": "./named-number.js"
|
|
138
|
+
},
|
|
136
139
|
"./pad-left": {
|
|
137
140
|
"default": "./pad-left.js"
|
|
138
141
|
},
|
|
@@ -203,5 +206,5 @@
|
|
|
203
206
|
"thi.ng": {
|
|
204
207
|
"year": 2015
|
|
205
208
|
},
|
|
206
|
-
"gitHead": "
|
|
209
|
+
"gitHead": "324d6b7dbf31558329e9fb6452e29b2f7db9c61a\n"
|
|
207
210
|
}
|
package/uuid.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 16.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* Use [`uuid()`](https://docs.thi.ng/umbrella/
|
|
8
|
+
* Use [`uuid()`](https://docs.thi.ng/umbrella/uuid/functions/uuid.html) to
|
|
9
9
|
* also generate an UUID from scratch (rather than just format one).
|
|
10
10
|
*
|
|
11
11
|
* @param id -
|