@thi.ng/emoji 0.1.44 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-07-22T13:15:57Z
3
+ - **Last updated**: 2024-08-18T14:11:34Z
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
+ ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/emoji@0.2.0) (2024-08-10)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add replaceNames(), add test ([a9726c8](https://github.com/thi-ng/umbrella/commit/a9726c8))
17
+
12
18
  ## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/emoji@0.1.0) (2023-02-27)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 198 standalone projects, maintained as part
10
+ > This is one of 199 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
  >
@@ -30,7 +30,11 @@ Bi-directional lookup tables mapping emoji names & their characters.
30
30
  There're lots of other emoji packages available, most of them with various
31
31
  additional functionality & dependencies. In contrast, this package merely
32
32
  provides simple bi-directional mappings between emoji names & their actual
33
- characters. Nothing more, nothing less.
33
+ characters.
34
+
35
+ The function [`replaceNames()`]() can be used to replace all _known_
36
+ `:emoji_name:` occurrences in a given string with their corresponding emoji
37
+ character...
34
38
 
35
39
  ### References
36
40
 
@@ -76,7 +80,7 @@ For Node.js REPL:
76
80
  const emoji = await import("@thi.ng/emoji");
77
81
  ```
78
82
 
79
- Package sizes (brotli'd, pre-treeshake): ESM: 11.78 KB
83
+ Package sizes (brotli'd, pre-treeshake): ESM: 11.84 KB
80
84
 
81
85
  ## Dependencies
82
86
 
@@ -86,14 +90,17 @@ None
86
90
 
87
91
  [Generated API docs](https://docs.thi.ng/umbrella/emoji/)
88
92
 
89
- ```ts
90
- import { EMOJI, NAMES } from "@thi.ng/emoji";
93
+ ```ts tangle:export/readme.ts
94
+ import { EMOJI, NAMES, replaceNames } from "@thi.ng/emoji";
91
95
 
92
- EMOJI["minibus"]
96
+ console.log(EMOJI["minibus"]);
93
97
  // "🚐"
94
98
 
95
- NAMES["🚐"]
99
+ console.log(NAMES["🚐"]);
96
100
  // "minibus"
101
+
102
+ console.log(replaceNames("Amazing :grin::heart_eyes::invalid:!"));
103
+ // "Amazing 😁😍:invalid:!"
97
104
  ```
98
105
 
99
106
  ## Authors
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./emoji.js";
2
2
  export * from "./names.js";
3
+ export * from "./replace.js";
3
4
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./emoji.js";
2
2
  export * from "./names.js";
3
+ export * from "./replace.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/emoji",
3
- "version": "0.1.44",
3
+ "version": "0.2.1",
4
4
  "description": "Bi-directional lookup tables mapping emoji names & their characters",
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
  "devDependencies": {
39
- "@microsoft/api-extractor": "^7.47.0",
39
+ "@microsoft/api-extractor": "^7.47.5",
40
40
  "esbuild": "^0.23.0",
41
- "typedoc": "^0.26.3",
42
- "typescript": "^5.5.3"
41
+ "typedoc": "^0.26.5",
42
+ "typescript": "^5.5.4"
43
43
  },
44
44
  "keywords": [
45
45
  "bidirectional",
@@ -74,11 +74,14 @@
74
74
  },
75
75
  "./names": {
76
76
  "default": "./names.js"
77
+ },
78
+ "./replace": {
79
+ "default": "./replace.js"
77
80
  }
78
81
  },
79
82
  "thi.ng": {
80
83
  "status": "alpha",
81
84
  "year": 2023
82
85
  },
83
- "gitHead": "324d6b7dbf31558329e9fb6452e29b2f7db9c61a\n"
86
+ "gitHead": "f6e26ea1142525171de5d36b9c3119f2782bb437\n"
84
87
  }
package/replace.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Takes a string and replaces all known `:emoji_name:` occurrences with their
3
+ * actual emoji character.
4
+ *
5
+ * @param src
6
+ */
7
+ export declare const replaceNames: (src: string) => string;
8
+ //# sourceMappingURL=replace.d.ts.map
package/replace.js ADDED
@@ -0,0 +1,5 @@
1
+ import { EMOJI } from "./emoji.js";
2
+ const replaceNames = (src) => src.replace(/:([a-z0-9_+-]+):/g, (orig, id) => EMOJI[id] || orig);
3
+ export {
4
+ replaceNames
5
+ };