littoral-templates 0.4.0-rc.1 → 0.4.0-rc.2
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 +4 -0
- package/dist/functions.d.ts +16 -1
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +19 -3
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +23 -0
- package/dist/internals.d.ts.map +1 -0
- package/dist/internals.js +84 -0
- package/dist/internals.js.map +1 -0
- package/dist/{string-utils.d.ts → strings.d.ts} +2 -5
- package/dist/strings.d.ts.map +1 -0
- package/dist/{string-utils.js → strings.js} +3 -9
- package/dist/strings.js.map +1 -0
- package/package.json +9 -7
- package/dist/string-utils.d.ts.map +0 -1
- package/dist/string-utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
* Thunks returning a `Template` are now `Template`s as well.
|
6
6
|
* The 3rd (Curried) argument of `indentWith`, and the 2nd (Curried) argument of `when` are now variadic.
|
7
|
+
* The EOL string can now be set explicitly (with the `setEOLExplicitly` function), or be taken from the OS (with the asynchronous `setEOLFromOS` function).
|
8
|
+
This EOL string is then used to insert newlines, and – to some extent – normalize them.
|
9
|
+
* An object constant `commonIndentations` is added with the most common indentation styles: “2 spaces”, “4 spaces”, and “1 tab”.
|
10
|
+
* The `flatten` function now splits on `/\r*\n/` rather than just `/\n/`.
|
7
11
|
|
8
12
|
|
9
13
|
## 0.3.0
|
package/dist/functions.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Template } from "./
|
1
|
+
import { Template } from "./index.js";
|
2
2
|
/**
|
3
3
|
* @returns {string} - the given template joined as one string, taking care of proper newline endings.
|
4
4
|
*/
|
@@ -21,6 +21,21 @@ export declare const asString: (template: Template) => string;
|
|
21
21
|
* </pre>
|
22
22
|
*/
|
23
23
|
export declare const indentWith: (singleIndentation: string) => (indentLevel?: number) => (...templates: Template[]) => string[];
|
24
|
+
/**
|
25
|
+
* An enumeration of common indentation styles.
|
26
|
+
* Use these in a type-safe way as follows, e.g. for “1 tab”:
|
27
|
+
*
|
28
|
+
* ```
|
29
|
+
* const indent = indentWith(commonIndentations["1 tab"])
|
30
|
+
*
|
31
|
+
* indent([`foo`])
|
32
|
+
* ```
|
33
|
+
*/
|
34
|
+
export declare const commonIndentations: {
|
35
|
+
readonly "2 spaces": " ";
|
36
|
+
readonly "4 spaces": " ";
|
37
|
+
readonly "1 tab": "\t";
|
38
|
+
};
|
24
39
|
/**
|
25
40
|
* Allows for the following syntax:
|
26
41
|
* <pre>
|
package/dist/functions.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAC,MAAM,YAAY,CAAA;AAkB3C;;GAEG;AACH,eAAO,MAAM,QAAQ,aAAc,QAAQ,KAAG,MACI,CAAA;AAGlD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,sBAAuB,MAAM,oBAClC,MAAM,oBAGM,QAAQ,EAAE,aAEnC,CAAA;AAGL;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAA;AAGV;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,SAAU,OAAO,sBAAqB,QAAQ,EAAE,KAAK,QAGnD,CAAA;AAGnB;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAA+B,QAAQ,yBACpC,CAAA"}
|
package/dist/functions.js
CHANGED
@@ -7,7 +7,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
7
7
|
}
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
9
9
|
};
|
10
|
-
import { repeat
|
10
|
+
import { repeat } from "./index.js";
|
11
|
+
import { withEOLEnsured } from "./internals.js";
|
11
12
|
/**
|
12
13
|
* “Flattens” the given template to an array of strings, each of which represent exactly one line.
|
13
14
|
*/
|
@@ -18,13 +19,13 @@ var flatten = function (template) {
|
|
18
19
|
if (Array.isArray(template)) {
|
19
20
|
return template.map(flatten).reduce(function (arrL, arrR) { return __spreadArray(__spreadArray([], arrL, true), arrR, true); }, []);
|
20
21
|
}
|
21
|
-
return template.split(
|
22
|
+
return template.split(/\r*\n/);
|
22
23
|
};
|
23
24
|
/**
|
24
25
|
* @returns {string} - the given template joined as one string, taking care of proper newline endings.
|
25
26
|
*/
|
26
27
|
export var asString = function (template) {
|
27
|
-
return flatten(template).map(
|
28
|
+
return flatten(template).map(withEOLEnsured).join("");
|
28
29
|
};
|
29
30
|
/**
|
30
31
|
* @returns a function to instantiate a function to indent a sub-template.
|
@@ -57,6 +58,21 @@ export var indentWith = function (singleIndentation) {
|
|
57
58
|
}; // Note: Template[] has type Template as well!
|
58
59
|
};
|
59
60
|
};
|
61
|
+
/**
|
62
|
+
* An enumeration of common indentation styles.
|
63
|
+
* Use these in a type-safe way as follows, e.g. for “1 tab”:
|
64
|
+
*
|
65
|
+
* ```
|
66
|
+
* const indent = indentWith(commonIndentations["1 tab"])
|
67
|
+
*
|
68
|
+
* indent([`foo`])
|
69
|
+
* ```
|
70
|
+
*/
|
71
|
+
export var commonIndentations = {
|
72
|
+
"2 spaces": " ",
|
73
|
+
"4 spaces": " ",
|
74
|
+
"1 tab": "\t"
|
75
|
+
};
|
60
76
|
/**
|
61
77
|
* Allows for the following syntax:
|
62
78
|
* <pre>
|
package/dist/functions.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAW,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAG7C;;GAEG;AACH,IAAM,OAAO,GAAG,UAAC,QAAkB;IAC/B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,IAAI,IAAK,uCAAI,IAAI,SAAK,IAAI,SAAjB,CAAkB,EAAE,EAAE,CAAC,CAAA;IAC/E,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAClC,CAAC,CAAA;AAGD;;GAEG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAC,QAAkB;IACvC,OAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAA9C,CAA8C,CAAA;AAGlD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,iBAAyB;IAChD,OAAA,UAAC,WAAuB;QAAvB,4BAAA,EAAA,eAAuB;QACpB,IAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;QACrD,IAAM,QAAQ,GAAG,UAAC,IAAY,IAAK,OAAA,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAxC,CAAwC,CAAA;QAC3E,OAAO;YAAC,mBAAwB;iBAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;gBAAxB,8BAAwB;;YAC5B,OAAA,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAhC,CAAgC,CAAA,CAAI,8CAA8C;IAC1F,CAAC;AALD,CAKC,CAAA;AAGL;;;;;;;;;GASG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAC9B,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,IAAI;CACP,CAAA;AAGV;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,IAAM,IAAI,GAAG,UAAC,IAAa;IAC9B,OAAA,IAAI;QACA,CAAC,CAAC;YAAC,qBAA0B;iBAA1B,UAA0B,EAA1B,qBAA0B,EAA1B,IAA0B;gBAA1B,gCAA0B;;YAAK,OAAA,OAAO,CAAC,WAAW,CAAC;QAApB,CAAoB,CAAE,+FAA+F;QACvJ,CAAC,CAAC,UAAC,CAAC,IAAK,OAAA,EAAE,EAAF,CAAE;AAFf,CAEe,CAAA;AAGnB;;GAEG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAI,YAAgC;IACnE,OAAA,UAAC,CAAI,IAAK,OAAA,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAArB,CAAqB;AAA/B,CAA+B,CAAA"}
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export { Template, NestedString } from "./types.js";
|
2
2
|
export { asString, indentWith, when, withNewlineAppended } from "./functions.js";
|
3
|
-
export { commaSeparated } from "./
|
3
|
+
export { commaSeparated, repeat } from "./strings.js";
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,YAAY,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,YAAY,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAC,cAAc,EAAE,MAAM,EAAC,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAC,cAAc,EAAE,MAAM,EAAC,MAAM,cAAc,CAAA"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export declare const eolStyles: {
|
2
|
+
readonly lf: "\n";
|
3
|
+
readonly crlf: "\r\n";
|
4
|
+
};
|
5
|
+
/**
|
6
|
+
* The value of the EOL string: typically, either "\n" (=LF-style, compatible with POSIX/Linux/macOS), or "\r\n" (=CRLF-style, compatible with Windows).
|
7
|
+
*/
|
8
|
+
export declare let eol: string;
|
9
|
+
/**
|
10
|
+
* Sets the EOL to the OS-dependent value.
|
11
|
+
*/
|
12
|
+
export declare const setEOLFromOS: () => Promise<void>;
|
13
|
+
/**
|
14
|
+
* Sets the EOL explicitly to the given value.
|
15
|
+
* (This is especially useful for testing.)
|
16
|
+
*/
|
17
|
+
export declare const setEOLExplicitly: (newEol: string) => void;
|
18
|
+
/**
|
19
|
+
* Ensures that the given string ends with an EOL, adding one if necessary.
|
20
|
+
*/
|
21
|
+
export declare const withEOLEnsured: (str: string) => string;
|
22
|
+
export declare const splitOnEOL: (str: string) => string[];
|
23
|
+
//# sourceMappingURL=internals.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internals.d.ts","sourceRoot":"","sources":["../src/internals.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;CAGZ,CAAA;AAEV;;GAEG;AACH,eAAO,IAAI,GAAG,EAAE,MAAqB,CAAA;AAGrC;;GAEG;AACH,eAAO,MAAM,YAAY,QAAa,QAAQ,IAAI,CAG5C,CAAA;AAGN;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,SAE9C,CAAA;AAKD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,MAK5C,CAAA;AAKD,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAAM,EACtB,CAAA"}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/*
|
2
|
+
* Note: don't export internals from {@see index.ts}!
|
3
|
+
*/
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
11
|
+
});
|
12
|
+
};
|
13
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
14
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
15
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
16
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
17
|
+
function step(op) {
|
18
|
+
if (f) throw new TypeError("Generator is already executing.");
|
19
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
20
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
21
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
22
|
+
switch (op[0]) {
|
23
|
+
case 0: case 1: t = op; break;
|
24
|
+
case 4: _.label++; return { value: op[1], done: false };
|
25
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
26
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
27
|
+
default:
|
28
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
29
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
30
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
31
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
32
|
+
if (t[2]) _.ops.pop();
|
33
|
+
_.trys.pop(); continue;
|
34
|
+
}
|
35
|
+
op = body.call(thisArg, _);
|
36
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
37
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
38
|
+
}
|
39
|
+
};
|
40
|
+
export var eolStyles = {
|
41
|
+
lf: "\n",
|
42
|
+
crlf: "\r\n"
|
43
|
+
};
|
44
|
+
/**
|
45
|
+
* The value of the EOL string: typically, either "\n" (=LF-style, compatible with POSIX/Linux/macOS), or "\r\n" (=CRLF-style, compatible with Windows).
|
46
|
+
*/
|
47
|
+
export var eol = eolStyles.lf;
|
48
|
+
/**
|
49
|
+
* Sets the EOL to the OS-dependent value.
|
50
|
+
*/
|
51
|
+
export var setEOLFromOS = function () { return __awaiter(void 0, void 0, void 0, function () {
|
52
|
+
return __generator(this, function (_a) {
|
53
|
+
return [2 /*return*/, import("os").then(function (os) {
|
54
|
+
eol = os.EOL;
|
55
|
+
})
|
56
|
+
/**
|
57
|
+
* Sets the EOL explicitly to the given value.
|
58
|
+
* (This is especially useful for testing.)
|
59
|
+
*/
|
60
|
+
];
|
61
|
+
});
|
62
|
+
}); };
|
63
|
+
/**
|
64
|
+
* Sets the EOL explicitly to the given value.
|
65
|
+
* (This is especially useful for testing.)
|
66
|
+
*/
|
67
|
+
export var setEOLExplicitly = function (newEol) {
|
68
|
+
eol = newEol;
|
69
|
+
};
|
70
|
+
var normalizeRegex = new RegExp(/\r*\n?$/);
|
71
|
+
/**
|
72
|
+
* Ensures that the given string ends with an EOL, adding one if necessary.
|
73
|
+
*/
|
74
|
+
export var withEOLEnsured = function (str) {
|
75
|
+
var match = str.match(normalizeRegex);
|
76
|
+
return match === null
|
77
|
+
? str // (should not happen, but OK...)
|
78
|
+
: (str.substring(0, match.index) + eol);
|
79
|
+
};
|
80
|
+
var splitRegex = new RegExp(/\r*\n/);
|
81
|
+
export var splitOnEOL = function (str) {
|
82
|
+
return str.split(splitRegex);
|
83
|
+
};
|
84
|
+
//# sourceMappingURL=internals.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internals.js","sourceRoot":"","sources":["../src/internals.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,MAAM,CAAC,IAAM,SAAS,GAAG;IACrB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;CACN,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,IAAI,GAAG,GAAW,SAAS,CAAC,EAAE,CAAA;AAGrC;;GAEG;AACH,MAAM,CAAC,IAAM,YAAY,GAAG;;QACxB,sBAAA,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAC,EAAE;gBACjB,GAAG,GAAG,EAAE,CAAC,GAAG,CAAA;YAChB,CAAC,CAAC;YAGN;;;eAGG;UANG;;KAAA,CAAA;AAGN;;;GAGG;AACH,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,MAAc;IAC3C,GAAG,GAAG,MAAM,CAAA;AAChB,CAAC,CAAA;AAGD,IAAM,cAAc,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,GAAW;IACtC,IAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IACvC,OAAO,KAAK,KAAK,IAAI;QACjB,CAAC,CAAC,GAAG,CAAG,iCAAiC;QACzC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAA;AAC/C,CAAC,CAAA;AAGD,IAAM,UAAU,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAA;AAEtC,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,GAAW;IAClC,OAAA,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC;AAArB,CAAqB,CAAA"}
|
@@ -4,10 +4,7 @@
|
|
4
4
|
export declare const commaSeparated: (strings: string[]) => string[];
|
5
5
|
/**
|
6
6
|
* Polyfill/shim for ES2015's String.prototype.repeat which doesn't work for some reason in the test...
|
7
|
+
* (Implementation uses the binary representation of n.)
|
7
8
|
*/
|
8
9
|
export declare const repeat: (str: string, n: number) => string;
|
9
|
-
|
10
|
-
* Ensures that the given string ends with a newline (`\n`), adding one if necessary.
|
11
|
-
*/
|
12
|
-
export declare const withNewlineEnsured: (str: string) => string;
|
13
|
-
//# sourceMappingURL=string-utils.d.ts.map
|
10
|
+
//# sourceMappingURL=strings.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,EAAE,aACiC,CAAA;AAEjF;;;GAGG;AACH,eAAO,MAAM,MAAM,QAAS,MAAM,KAAK,MAAM,KAAG,MAY/C,CAAA"}
|
@@ -6,6 +6,7 @@ export var commaSeparated = function (strings) {
|
|
6
6
|
};
|
7
7
|
/**
|
8
8
|
* Polyfill/shim for ES2015's String.prototype.repeat which doesn't work for some reason in the test...
|
9
|
+
* (Implementation uses the binary representation of n.)
|
9
10
|
*/
|
10
11
|
export var repeat = function (str, n) {
|
11
12
|
var result = "";
|
@@ -20,12 +21,5 @@ export var repeat = function (str, n) {
|
|
20
21
|
}
|
21
22
|
return result;
|
22
23
|
};
|
23
|
-
|
24
|
-
|
25
|
-
*/
|
26
|
-
export var withNewlineEnsured = function (str) {
|
27
|
-
return str.charAt(str.length - 1) === '\n'
|
28
|
-
? str
|
29
|
-
: (str + "\n");
|
30
|
-
};
|
31
|
-
//# sourceMappingURL=string-utils.js.map
|
24
|
+
// TODO more common string utils, e.g. withFirst{Upper|Lower}, etc.
|
25
|
+
//# sourceMappingURL=strings.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,OAAiB;IAC5C,OAAA,OAAO,CAAC,GAAG,CAAC,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,UAAG,GAAG,SAAG,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,EAAhD,CAAgD,CAAC;AAA7E,CAA6E,CAAA;AAEjF;;;GAGG;AACH,MAAM,CAAC,IAAM,MAAM,GAAG,UAAC,GAAW,EAAE,CAAS;IACzC,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACd,MAAM,IAAI,GAAG,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACR,GAAG,IAAI,GAAG,CAAA;QACd,CAAC;QACD,CAAC,KAAK,CAAC,CAAA;IACX,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAGD,oEAAoE"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "littoral-templates",
|
3
|
-
"version": "0.4.0-rc.
|
3
|
+
"version": "0.4.0-rc.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
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
@@ -13,10 +13,12 @@
|
|
13
13
|
"test": "mocha dist/test/*.js",
|
14
14
|
"watch-test": "mocha --watch dist/test/*.js",
|
15
15
|
"lint": "eslint src",
|
16
|
-
"pre-release
|
17
|
-
"prerelease": "npm run pre-release
|
16
|
+
"prep:pre-release": "npm run clean && npm install && npm test",
|
17
|
+
"prerelease": "npm run prep:pre-release",
|
18
18
|
"release": "npm publish",
|
19
|
-
"prerelease-
|
19
|
+
"prerelease-alpha": "npm run prep:pre-release",
|
20
|
+
"release-alpha": "npm publish --tag beta",
|
21
|
+
"prerelease-beta": "npm run prep:pre-release",
|
20
22
|
"release-beta": "npm publish --tag beta"
|
21
23
|
},
|
22
24
|
"repository": {
|
@@ -34,12 +36,12 @@
|
|
34
36
|
},
|
35
37
|
"homepage": "https://github.com/dslmeinte/littoral-templates#readme",
|
36
38
|
"devDependencies": {
|
37
|
-
"@types/chai": "5.
|
39
|
+
"@types/chai": "5.2.2",
|
38
40
|
"@types/mocha": "10.0.10",
|
39
|
-
"@types/node": "18.19.
|
41
|
+
"@types/node": "18.19.112",
|
40
42
|
"@typescript-eslint/eslint-plugin": "6.21.0",
|
41
43
|
"@typescript-eslint/parser": "6.21.0",
|
42
|
-
"chai": "5.
|
44
|
+
"chai": "5.2.0",
|
43
45
|
"mocha": "10.8.2",
|
44
46
|
"typescript": "5.3.3"
|
45
47
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../src/string-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,EAAE,aACiC,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,MAAM,QAAS,MAAM,KAAK,MAAM,KAAG,MAY/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,MAG1B,CAAA"}
|
package/dist/string-utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../src/string-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,OAAiB;IAC5C,OAAA,OAAO,CAAC,GAAG,CAAC,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,UAAG,GAAG,SAAG,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,EAAhD,CAAgD,CAAC;AAA7E,CAA6E,CAAA;AAEjF;;GAEG;AACH,MAAM,CAAC,IAAM,MAAM,GAAG,UAAC,GAAW,EAAE,CAAS;IACzC,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACd,MAAM,IAAI,GAAG,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACR,GAAG,IAAI,GAAG,CAAA;QACd,CAAC;QACD,CAAC,KAAK,CAAC,CAAA;IACX,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAAC,GAAW;IAC1C,OAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI;QAC/B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,CAAE,GAAG,GAAG,IAAI,CAAC;AAFnB,CAEmB,CAAA"}
|