littoral-templates 0.2.1-beta.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## 0.2.2
5
+
6
+ * Fix internal `flatten` function for empty arrays.
7
+ + Use “fat arrow” syntax everywhere.
8
+ * Improve unit testing setup using Mocha + Chai.
9
+ (No impact on shipped code.)
10
+
11
+
4
12
  ## 0.2.1
5
13
 
6
14
  * Declare as a CommonJS module again.
package/README.md CHANGED
@@ -12,7 +12,7 @@ Instead, templates look as follows:
12
12
  ```typescript
13
13
  import { asString, indentWith } from "littoral-templates"
14
14
 
15
- const indent = indentWith("\t") // with apologies to the spaces people...
15
+ const indent = indentWith(" ")
16
16
 
17
17
  console.log(
18
18
  asString([
@@ -35,9 +35,8 @@ This code produces the following text on the JavaScript console:
35
35
  ```
36
36
  top-level
37
37
  still top-level, but on a new line
38
- this is indented (1 level)
39
- this is even more indented (3 levels)
40
-
38
+ this is indented (1 level)
39
+ this is even more indented (3 levels)
41
40
  ```
42
41
 
43
42
 
@@ -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,oBAAY,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,CAAA;AAEvD,aAAK,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,KAAK,CAAC,CAAA;AAwBrD;;GAEG;AACH,eAAO,MAAM,QAAQ,iBAVF,YAAY,WAUmF,CAAA;AAoBlH;;;GAGG;AACH,eAAO,MAAM,UAAU,sBAAuB,MAAM,oBAAmB,MAAM,KAAO,qBAAqB,MAAM,EAAE,CAIhH,CAAA"}
package/dist/index.js CHANGED
@@ -13,22 +13,22 @@ exports.indentWith = exports.asString = void 0;
13
13
  /**
14
14
  * Polyfill/shim for ES2019's Array.prototype.flat(..).
15
15
  */
16
- function flatten(nestedString) {
16
+ var flatten = function (nestedString) {
17
17
  return Array.isArray(nestedString)
18
- ? nestedString.map(flatten).reduce(function (arrL, arrR) { return __spreadArray(__spreadArray([], arrL, true), arrR, true); })
18
+ ? nestedString.map(flatten).reduce(function (arrL, arrR) { return __spreadArray(__spreadArray([], arrL, true), arrR, true); }, [])
19
19
  : [nestedString];
20
- }
20
+ };
21
21
  /**
22
22
  * @returns {function(*=): *} - a function that maps over a single string using mapString, or an array of strings using mapStrings.
23
23
  * If an array is given, that array is completely (i.e.: recursively) flattened first, before the mapStrings function is applied.
24
24
  */
25
- function mapNestedString(mapString, mapStrings) {
25
+ var mapNestedString = function (mapString, mapStrings) {
26
26
  return function (nestedString) {
27
27
  return Array.isArray(nestedString)
28
28
  ? mapStrings(flatten(nestedString))
29
29
  : mapString(nestedString);
30
30
  };
31
- }
31
+ };
32
32
  var withNewlineEnsured = function (str) { return str.charAt(str.length - 1) === '\n' ? str : (str + "\n"); };
33
33
  /**
34
34
  * @returns {string} - the given nested string joined as one string, taking care of proper newline endings.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA;;GAEG;AACH,SAAS,OAAO,CAAC,YAA0B;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;QAC9B,CAAC,CAAC,Y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C,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAjD,CAAiD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAA3F,CAA2F,CAAA;IACvI,OAAO,eAAe,CAAC,UAAC,MAAc,IAAe,OAAA,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAApB,CAAoB,EAAE,UAAC,OAAiB,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAvB,CAAuB,CAAC,CAAA;AAC9H,CAAC,EAJwD,CAIxD,CAAA;AAJY,QAAA,UAAU,cAItB"}
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "littoral-templates",
3
- "version": "0.2.1-beta.0",
3
+ "version": "0.2.2",
4
4
  "description": "A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
+ "watch-build": "tsc --watch",
9
10
  "clean": "rm -rf dist",
10
11
  "pretest": "npm-run-all build",
11
- "test": "node dist/test/test-in-README.js"
12
+ "test": "mocha dist/test/*.js",
13
+ "watch-test": "mocha --watch dist/test/*.js"
12
14
  },
13
15
  "repository": {
14
16
  "type": "git",
@@ -25,7 +27,11 @@
25
27
  },
26
28
  "homepage": "https://github.com/dslmeinte/littoral-templates#readme",
27
29
  "devDependencies": {
30
+ "@types/chai": "^4.3.4",
31
+ "@types/mocha": "^10.0.0",
28
32
  "@types/node": "^14.18.33",
33
+ "chai": "^4.3.7",
34
+ "mocha": "^10.1.0",
29
35
  "npm-run-all": "^4.1.5",
30
36
  "typescript": "^4.8.4"
31
37
  }