littoral-templates 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## 0.3.0
5
+
6
+ * Turn the package into an ESM module (back again).
7
+ (Should work with Deno in the meanwhile.)
8
+ * Update dependencies: no impact on shipped code.
9
+ * Add functions: `when`, `withNewlineAppended`, and `commaSeparated`.
10
+ * Rename `NestedString` to `Template`, leaving `NestedString` as an alias.
11
+ This is not a breaking change, but I might deprecate and remove `NestedString` in the future.
12
+ * Add {T|J}SDoc.
13
+
14
+
15
+ ## 0.2.2
16
+
17
+ * Fix internal `flatten` function for empty arrays.
18
+ + Use “fat arrow” syntax everywhere.
19
+ * Improve unit testing setup using Mocha + Chai.
20
+ (No impact on shipped code.)
21
+
22
+
4
23
  ## 0.2.1
5
24
 
6
25
  * Declare as a CommonJS module again.
package/README.md CHANGED
@@ -3,48 +3,155 @@
3
3
  A small JavaScript/TypeScript framework to do templating comfortably using the [template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) syntax in either JavaScript or TypeScript.
4
4
  It doesn't come with its own syntax, like frameworks like [mustache](https://mustache.github.io/), and [handlebars](https://handlebarsjs.com/) do.
5
5
 
6
- The repository's name is a play on "temporal literals" and "littoral", begin phonetically close to "literal".
7
- The latter word indicates the part of a body of water (lake, sea, or ocean) that's closest to shore, usually shallow, and possibly not always entirely submerged.
8
- The name tries to convey that implementing templates with this framework doesn't require you to "wade too far into the water".
9
-
10
6
  Instead, templates look as follows:
11
7
 
12
8
  ```typescript
13
- import { asString, indentWith } from "littoral-templates"
9
+ [
10
+ `top-level`,
11
+ [ `still top-level, but on a new line` ],
12
+ indent(1)([
13
+ `this is indented (1 level)`,
14
+ indent(2)([
15
+ `this is much more indented (3 levels)`
16
+ ])
17
+ ])
18
+ ]
19
+ ```
20
+
21
+ Instances of the `Template` type are arrays of strings nested to an arbitrary depth/level.
22
+ (Depth 0 corresponds to a single string).
23
+ To convert this to a proper string, use the `asString` function, as follows:
24
+
25
+ ```typescript
26
+ import {asString, indentWith} from "littoral-templates"
14
27
 
15
- const indent = indentWith("\t") // with apologies to the spaces people...
28
+ const indent = indentWith(" ")
16
29
 
17
30
  console.log(
18
- asString([
19
- `top-level`,
20
- [ `still top-level, but on a new line` ],
21
- indent(1)([
22
- `this is indented (1 level)`,
23
- indent(2)([
24
- `this is much more indented (3 levels)`
25
- ])
26
- ])
27
- ])
31
+ asString(<the template from the listing above>)
28
32
  )
29
-
30
33
  ```
31
34
 
32
- (The contents of the code above can be found in [`src/test/test-in-README.ts`](./src/test/test-in-README.ts) as well.)
33
35
  This code produces the following text on the JavaScript console:
34
36
 
35
37
  ```
36
38
  top-level
37
39
  still top-level, but on a new line
38
- this is indented (1 level)
39
- this is even more indented (3 levels)
40
+ this is indented (1 level)
41
+ this is even more indented (3 levels)
42
+ ```
43
+
44
+
45
+ ### Iterating over collections
46
+
47
+ A common activity in templates is to iterate over a collection and map each item to text.
48
+ These sub-texts would then have to be joined together, and taking care of correct indentation is then usually quite a hassle.
49
+ Using the `Template` type, you can simply use the `Array.map` function, as follows:
50
+
51
+ ```typescript
52
+ import {asString, indentWith} from "littoral-templates"
53
+
54
+ const indent = indentWith(" ")
55
+
56
+ console.log(
57
+ asString([
58
+ `my items:`,
59
+ indent(1)(
60
+ ["foo", "bar"].map((item, index) => `item ${index + 1}: "${item}"`)
61
+ )
62
+ ])
63
+ )
64
+ ```
65
+
66
+ This code produces the following text on the JavaScript console:
67
+
68
+ ```
69
+ my items:
70
+ item 1: foo
71
+ item 2: bar
72
+ ```
73
+
74
+
75
+ ### Including content conditionally
76
+
77
+ Another common activity in templates is to include some content conditionally.
78
+ This package provides the convenient `when` function for that.
79
+ An example of its usage is as follows:
80
+
81
+ ```typescript
82
+ [
83
+ `foo`,
84
+ `bar`,
85
+ when(n === 3)([
86
+ `lizard`,
87
+ `sfdeljknesv`
88
+ ])
89
+ ]
90
+ ```
40
91
 
92
+ After applying the `asString`, and assuming the variable `n` holds the value `3`, this evaluates to:
93
+
94
+ ```
95
+ foo
96
+ bar
97
+ lizard
98
+ sfdeljknesv
99
+ ```
100
+
101
+ In case the argument to the function call after `when(<some boolean condition>)` has side effects, you want to turn that into a thunk, as follows:
102
+
103
+ ```typescript
104
+ let touched = 0
105
+ const template = [
106
+ `foo`,
107
+ `bar`,
108
+ when(n === 3)(() => [
109
+ `${++touched}lizard`,
110
+ `sfdeljknesv`
111
+ ])
112
+ ]
41
113
  ```
42
114
 
115
+ Using side effects inside a template can be useful to store information that's needed elsewhere in the text-to-generate.
116
+ An example of that would be to keep track of imports that have to appear before their usage.
117
+
43
118
 
44
- ## TODOs
119
+ ### Other convenience functions
45
120
 
46
- * Publish to NPM (including proper cleaning and ignoring).
47
- * Proper test set up, e.g. using `mocha` and `chai`.
48
- * Skip `undefined | null`s.
49
- * Does an alternative to `npm-run-all` exist (that's better)?
121
+ Other convenience functions are:
122
+
123
+ * `withNewlineAppended`: Wrap this around a template function (see definition below) to produce a template function that adds a newline after any item fed to the original template function.
124
+
125
+ A _template function_ is any function that produces an instance of `Template`.
126
+
127
+ An example of the usage of `withNewlineAppended` is
128
+
129
+ ```typescript
130
+ [1, 2, 3].map(withNewlineAppended((num) => `${num}`))
131
+ ```
132
+
133
+ which should produce the following text:
134
+
135
+ ```
136
+ 1
137
+
138
+ 2
139
+
140
+ 3
141
+
142
+ ```
143
+
144
+ * `commaSeparated`: Given a list of strings, this function adds a comma after every string, except for the last one.
145
+
146
+ E.g., `commaSeparated(["1", "2", "3"])` becomes `["1,", "2,", "3"]`.
147
+ This is useful e.g. for rendering “pretty” import statements.
148
+
149
+ _Note_ that this only works on a list of strings, not an any instance of `Template`.
150
+
151
+
152
+ ### Package name
153
+
154
+ The repository's name is a play on "temporal literals" and "littoral", begin phonetically close to "literal".
155
+ The latter word indicates the part of a body of water (lake, sea, or ocean) that's closest to shore, usually shallow, and possibly not always entirely submerged.
156
+ The name tries to convey that implementing templates with this framework doesn't require you to "wade too far into the water".
50
157
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,69 @@
1
- export declare type NestedString = string | Array<NestedString>;
2
- declare type NestedStringFunction<T> = (_: NestedString) => T;
3
1
  /**
4
- * @returns {string} - the given nested string joined as one string, taking care of proper newline endings.
2
+ * A type definition for “templates” that consist of array of strings nested to an arbitrary depth.
3
+ * (Depth 0 corresponds to just a single string.)
4
+ *
5
+ * @since version 0.3.0
5
6
  */
6
- export declare const asString: (nestedString: NestedString) => string;
7
+ export type Template = string | Array<Template>;
7
8
  /**
8
- * @returns {function} - a function to instantiate a function to indent a nested string.
9
- * The function always returns strings.
9
+ * An alias for the {@link Template} type definition.
10
+ * Note: this type might be deprecated and removed (per a major version) in the future.
10
11
  */
11
- export declare const indentWith: (singleIndentation: string) => (indentLevel?: number) => NestedStringFunction<string[]>;
12
+ export type NestedString = Template;
13
+ type TemplateFunction<T> = (_: Template) => T;
14
+ /**
15
+ * @returns {string} - the given template joined as one string, taking care of proper newline endings.
16
+ */
17
+ export declare const asString: (template: Template) => string;
18
+ /**
19
+ * @returns {function} - a function to instantiate a function to indent a sub-template.
20
+ * The function always returns an array of strings.
21
+ *
22
+ * Its usage looks as follows:
23
+ * <pre>
24
+ * indentWith(" ")(2)([
25
+ * `this is indented 2 levels`
26
+ * ])
27
+ * </pre>
28
+ *
29
+ * Usually, one sets up the following function constant before:
30
+ * <pre>
31
+ * const indent = indentWith(" ")
32
+ * </pre>
33
+ */
34
+ export declare const indentWith: (singleIndentation: string) => (indentLevel?: number) => TemplateFunction<string[]>;
35
+ /**
36
+ * Allows for the following syntax:
37
+ * <pre>
38
+ * [
39
+ * when(<some boolean condition>)(
40
+ * <stuff to include when boolean condition is true>
41
+ * )
42
+ * ]
43
+ * </pre>
44
+ *
45
+ * and
46
+ *
47
+ * <pre>
48
+ * [
49
+ * when(<some boolean condition>)(
50
+ * () => <stuff to include when boolean condition is true>
51
+ * )
52
+ * ]
53
+ * </pre>
54
+ *
55
+ * In the latter case, it's guaranteed that the thunk ({@see https://en.wikipedia.org/wiki/Thunk})
56
+ * is only evaluated (/run) when the boolean condition is true.
57
+ * That is useful in case the stuff to include produces side effects.
58
+ */
59
+ export declare const when: (bool: boolean) => (whenResult: (() => Template) | Template) => Template;
60
+ /**
61
+ * @return a function that composes the given template function with the action of "adding a newline after".
62
+ */
63
+ export declare const withNewlineAppended: <T>(templateFunc: (t: T) => Template) => (t: T) => Template[];
64
+ /**
65
+ * @return the given array of strings but with commas added after each string except the last one.
66
+ */
67
+ export declare const commaSeparated: (strings: string[]) => string[];
12
68
  export {};
13
69
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,CAAA;AAEvD,aAAK,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,KAAK,CAAC,CAAA;AA0BrD;;GAEG;AACH,eAAO,MAAM,QAAQ,iBAXK,YAAY,WAW4E,CAAA;AAoBlH;;;GAGG;AACH,eAAO,MAAM,UAAU,sBAAuB,MAAM,oBAAmB,MAAM,KAAO,qBAAqB,MAAM,EAAE,CAIhH,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;AAE/C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAA;AAGnC,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,KAAK,CAAC,CAAA;AA6B7C;;GAEG;AACH,eAAO,MAAM,QAAQ,aAdN,QAAQ,WAc2F,CAAA;AAoBlH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,sBAAuB,MAAM,oBAClC,MAAM,KAAO,gBAAgB,CAAC,MAAM,EAAE,CAInD,CAAA;AAGL;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,IAAI,SAAU,OAAO,kBAEX,CAAC,MAAM,QAAQ,CAAC,GAAG,QAAQ,aAIQ,CAAA;AAG1D;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,QAAQ,SAC/D,CAAC,eAA0B,CAAA;AAGnC;;GAEG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,EAAE,aACiC,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
2
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
3
  if (ar || !(i in from)) {
@@ -8,32 +7,35 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
7
  }
9
8
  return to.concat(ar || Array.prototype.slice.call(from));
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.indentWith = exports.asString = void 0;
13
10
  /**
14
11
  * Polyfill/shim for ES2019's Array.prototype.flat(..).
15
12
  */
16
- function flatten(nestedString) {
17
- return Array.isArray(nestedString)
18
- ? nestedString.map(flatten).reduce(function (arrL, arrR) { return __spreadArray(__spreadArray([], arrL, true), arrR, true); })
19
- : [nestedString];
20
- }
13
+ var flatten = function (template) {
14
+ return Array.isArray(template)
15
+ ? template.map(flatten).reduce(function (arrL, arrR) { return __spreadArray(__spreadArray([], arrL, true), arrR, true); }, [])
16
+ : [template];
17
+ };
21
18
  /**
22
19
  * @returns {function(*=): *} - a function that maps over a single string using mapString, or an array of strings using mapStrings.
23
20
  * If an array is given, that array is completely (i.e.: recursively) flattened first, before the mapStrings function is applied.
21
+ * (This function is only used internally.)
24
22
  */
25
- function mapNestedString(mapString, mapStrings) {
26
- return function (nestedString) {
27
- return Array.isArray(nestedString)
28
- ? mapStrings(flatten(nestedString))
29
- : mapString(nestedString);
23
+ var mapNestedString = function (mapString, mapStrings) {
24
+ return function (template) {
25
+ return Array.isArray(template)
26
+ ? mapStrings(flatten(template))
27
+ : mapString(template);
30
28
  };
31
- }
32
- var withNewlineEnsured = function (str) { return str.charAt(str.length - 1) === '\n' ? str : (str + "\n"); };
29
+ };
30
+ var withNewlineEnsured = function (str) {
31
+ return str.charAt(str.length - 1) === '\n'
32
+ ? str
33
+ : (str + "\n");
34
+ };
33
35
  /**
34
- * @returns {string} - the given nested string joined as one string, taking care of proper newline endings.
36
+ * @returns {string} - the given template joined as one string, taking care of proper newline endings.
35
37
  */
36
- exports.asString = mapNestedString(withNewlineEnsured, function (strings) { return strings.map(withNewlineEnsured).join(""); });
38
+ export var asString = mapNestedString(withNewlineEnsured, function (strings) { return strings.map(withNewlineEnsured).join(""); });
37
39
  /**
38
40
  * Polyfill/shim for ES2015's String.prototype.repeat which doesn't work for some reason in the test...
39
41
  */
@@ -51,14 +53,72 @@ var repeat = function (str, n) {
51
53
  return result;
52
54
  };
53
55
  /**
54
- * @returns {function} - a function to instantiate a function to indent a nested string.
55
- * The function always returns strings.
56
+ * @returns {function} - a function to instantiate a function to indent a sub-template.
57
+ * The function always returns an array of strings.
58
+ *
59
+ * Its usage looks as follows:
60
+ * <pre>
61
+ * indentWith(" ")(2)([
62
+ * `this is indented 2 levels`
63
+ * ])
64
+ * </pre>
65
+ *
66
+ * Usually, one sets up the following function constant before:
67
+ * <pre>
68
+ * const indent = indentWith(" ")
69
+ * </pre>
70
+ */
71
+ export var indentWith = function (singleIndentation) {
72
+ return function (indentLevel) {
73
+ if (indentLevel === void 0) { indentLevel = 1; }
74
+ var indentationPrefix = repeat(singleIndentation, indentLevel);
75
+ var indentLine = function (str) { return str.split("\n").map(function (line) { return (line.length > 0 ? indentationPrefix : "") + line; }).join("\n"); };
76
+ return mapNestedString(function (string) { return [indentLine(string)]; }, function (strings) { return strings.map(indentLine); });
77
+ };
78
+ };
79
+ /**
80
+ * Allows for the following syntax:
81
+ * <pre>
82
+ * [
83
+ * when(<some boolean condition>)(
84
+ * <stuff to include when boolean condition is true>
85
+ * )
86
+ * ]
87
+ * </pre>
88
+ *
89
+ * and
90
+ *
91
+ * <pre>
92
+ * [
93
+ * when(<some boolean condition>)(
94
+ * () => <stuff to include when boolean condition is true>
95
+ * )
96
+ * ]
97
+ * </pre>
98
+ *
99
+ * In the latter case, it's guaranteed that the thunk ({@see https://en.wikipedia.org/wiki/Thunk})
100
+ * is only evaluated (/run) when the boolean condition is true.
101
+ * That is useful in case the stuff to include produces side effects.
56
102
  */
57
- var indentWith = function (singleIndentation) { return function (indentLevel) {
58
- if (indentLevel === void 0) { indentLevel = 1; }
59
- var indentationPrefix = repeat(singleIndentation, indentLevel);
60
- var indentLine = function (str) { return str.split("\n").map(function (line) { return (line.length > 0 ? indentationPrefix : "") + line; }).join("\n"); };
61
- return mapNestedString(function (string) { return [indentLine(string)]; }, function (strings) { return strings.map(indentLine); });
62
- }; };
63
- exports.indentWith = indentWith;
103
+ export var when = function (bool) {
104
+ return bool
105
+ ? function (whenResult) {
106
+ return typeof whenResult === "function"
107
+ ? whenResult()
108
+ : whenResult;
109
+ }
110
+ : function (_whenResult) { return []; };
111
+ };
112
+ /**
113
+ * @return a function that composes the given template function with the action of "adding a newline after".
114
+ */
115
+ export var withNewlineAppended = function (templateFunc) {
116
+ return function (t) { return [templateFunc(t), ""]; };
117
+ };
118
+ /**
119
+ * @return the given array of strings but with commas added after each string except the last one.
120
+ */
121
+ export var commaSeparated = function (strings) {
122
+ return strings.map(function (str, index) { return "".concat(str).concat(index + 1 < strings.length ? "," : ""); });
123
+ };
64
124
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA;;GAEG;AACH,SA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MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,EAAhD,CAAgD,CAAC;AAA7E,CAA6E,CAAA"}
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "littoral-templates",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript.",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",
10
+ "watch-build": "tsc --watch",
9
11
  "clean": "rm -rf dist",
10
12
  "pretest": "npm-run-all build",
11
- "test": "node dist/test/test-in-README.js"
13
+ "test": "mocha dist/test/*.js",
14
+ "watch-test": "mocha --watch dist/test/*.js"
12
15
  },
13
16
  "repository": {
14
17
  "type": "git",
@@ -25,8 +28,12 @@
25
28
  },
26
29
  "homepage": "https://github.com/dslmeinte/littoral-templates#readme",
27
30
  "devDependencies": {
28
- "@types/node": "^14.18.33",
29
- "npm-run-all": "^4.1.5",
30
- "typescript": "^4.8.4"
31
+ "@types/chai": "5.0.1",
32
+ "@types/mocha": "10.0.9",
33
+ "@types/node": "18.19.64",
34
+ "chai": "5.1.2",
35
+ "mocha": "10.8.2",
36
+ "npm-run-all": "4.1.5",
37
+ "typescript": "5.6.3"
31
38
  }
32
39
  }