@jdeighan/coffee-utils 7.0.66 → 7.0.67
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/package.json +2 -1
- package/src/placeholders.coffee +25 -0
- package/src/placeholders.js +31 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.67",
|
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
|
6
6
|
"main": "coffee_utils.js",
|
|
7
7
|
"exports": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./svelte": "./src/svelte_utils.js",
|
|
19
19
|
"./store": "./src/DataStores.js",
|
|
20
20
|
"./taml": "./src/taml.js",
|
|
21
|
+
"./placeholders": "./src/placeholders.js",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"engines": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# placeholders.coffee
|
|
2
|
+
|
|
3
|
+
import {assert, undef, defined, croak} from '@jdeighan/coffee-utils'
|
|
4
|
+
|
|
5
|
+
hDefOptions = {
|
|
6
|
+
pre: '__'
|
|
7
|
+
post: '__'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
export phStr = (name, hOptions=hDefOptions) ->
|
|
13
|
+
|
|
14
|
+
{pre, post} = hOptions
|
|
15
|
+
return "#{pre}#{name}#{post}"
|
|
16
|
+
|
|
17
|
+
# ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export phReplace = (str, hValues, hOptions=hDefOptions) ->
|
|
20
|
+
|
|
21
|
+
{pre, post} = hOptions
|
|
22
|
+
return str.replace(
|
|
23
|
+
/// #{pre} ([A-Za-z_][A-Za-z0-9_]*) #{post} ///g,
|
|
24
|
+
(_, name) -> hValues[name]
|
|
25
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
// placeholders.coffee
|
|
3
|
+
var hDefOptions;
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
assert,
|
|
7
|
+
undef,
|
|
8
|
+
defined,
|
|
9
|
+
croak
|
|
10
|
+
} from '@jdeighan/coffee-utils';
|
|
11
|
+
|
|
12
|
+
hDefOptions = {
|
|
13
|
+
pre: '__',
|
|
14
|
+
post: '__'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
export var phStr = function(name, hOptions = hDefOptions) {
|
|
19
|
+
var post, pre;
|
|
20
|
+
({pre, post} = hOptions);
|
|
21
|
+
return `${pre}${name}${post}`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export var phReplace = function(str, hValues, hOptions = hDefOptions) {
|
|
26
|
+
var post, pre;
|
|
27
|
+
({pre, post} = hOptions);
|
|
28
|
+
return str.replace(RegExp(`${pre}([A-Za-z_][A-Za-z0-9_]*)${post}`, "g"), function(_, name) {
|
|
29
|
+
return hValues[name];
|
|
30
|
+
});
|
|
31
|
+
};
|