@readme/httpsnippet 7.0.0 → 7.0.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.
@@ -0,0 +1,18 @@
1
+ // src/helpers/reducer.ts
2
+ var reducer = (accumulator, pair) => {
3
+ const currentValue = accumulator[pair.name];
4
+ if (currentValue === void 0) {
5
+ accumulator[pair.name] = pair.value;
6
+ return accumulator;
7
+ }
8
+ if (Array.isArray(currentValue)) {
9
+ currentValue.push(pair.value);
10
+ return accumulator;
11
+ }
12
+ accumulator[pair.name] = [currentValue, pair.value];
13
+ return accumulator;
14
+ };
15
+
16
+ export { reducer };
17
+ //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=chunk-BCCGHMCJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/reducer.ts"],"names":[],"mappings":";AAEO,IAAM,UAAU,CAA4C,aAAkC,SAAY;AAC/G,QAAM,eAAe,YAAY,KAAK,IAAI;AAC1C,MAAI,iBAAiB,QAAW;AAC9B,gBAAY,KAAK,IAAI,IAAI,KAAK;AAC9B,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,YAAY,GAAG;AAC/B,iBAAa,KAAK,KAAK,KAAK;AAC5B,WAAO;AAAA,EACT;AAGA,cAAY,KAAK,IAAI,IAAI,CAAC,cAAc,KAAK,KAAK;AAClD,SAAO;AACT","sourcesContent":["export type ReducedHelperObject = Record<string, string[] | string>;\n\nexport const reducer = <T extends { name: string; value: string }>(accumulator: ReducedHelperObject, pair: T) => {\n const currentValue = accumulator[pair.name];\n if (currentValue === undefined) {\n accumulator[pair.name] = pair.value;\n return accumulator;\n }\n\n // If we already have it as array just push the value\n if (Array.isArray(currentValue)) {\n currentValue.push(pair.value);\n return accumulator;\n }\n\n // convert to array since now we have more than one value for this key\n accumulator[pair.name] = [currentValue, pair.value];\n return accumulator;\n};\n"]}
@@ -0,0 +1,63 @@
1
+ // src/helpers/code-builder.ts
2
+ var DEFAULT_INDENTATION_CHARACTER = "";
3
+ var DEFAULT_LINE_JOIN = "\n";
4
+ var CodeBuilder = class {
5
+ /**
6
+ * Helper object to format and aggragate lines of code.
7
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
8
+ */
9
+ constructor({ indent, join } = {}) {
10
+ this.postProcessors = [];
11
+ this.code = [];
12
+ this.indentationCharacter = DEFAULT_INDENTATION_CHARACTER;
13
+ this.lineJoin = DEFAULT_LINE_JOIN;
14
+ /**
15
+ * Add given indentation level to given line of code
16
+ */
17
+ this.indentLine = (line, indentationLevel = 0) => {
18
+ const indent = this.indentationCharacter.repeat(indentationLevel);
19
+ return `${indent}${line}`;
20
+ };
21
+ /**
22
+ * Add the line at the beginning of the current lines
23
+ */
24
+ this.unshift = (line, indentationLevel) => {
25
+ const newLine = this.indentLine(line, indentationLevel);
26
+ this.code.unshift(newLine);
27
+ };
28
+ /**
29
+ * Add the line at the end of the current lines
30
+ */
31
+ this.push = (line, indentationLevel) => {
32
+ const newLine = this.indentLine(line, indentationLevel);
33
+ this.code.push(newLine);
34
+ };
35
+ /**
36
+ * Add an empty line at the end of current lines
37
+ */
38
+ this.blank = () => {
39
+ this.code.push("");
40
+ };
41
+ /**
42
+ * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
43
+ */
44
+ this.join = () => {
45
+ const unreplacedCode = this.code.join(this.lineJoin);
46
+ const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);
47
+ return replacedOutput;
48
+ };
49
+ /**
50
+ * Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.
51
+ * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
52
+ */
53
+ this.addPostProcessor = (postProcessor) => {
54
+ this.postProcessors = [...this.postProcessors, postProcessor];
55
+ };
56
+ this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
57
+ this.lineJoin = join ?? DEFAULT_LINE_JOIN;
58
+ }
59
+ };
60
+
61
+ export { CodeBuilder };
62
+ //# sourceMappingURL=out.js.map
63
+ //# sourceMappingURL=chunk-UEOS42PC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/code-builder.ts"],"names":[],"mappings":";AAAA,IAAM,gCAAgC;AACtC,IAAM,oBAAoB;AAkBnB,IAAM,cAAN,MAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAavB,YAAY,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAG;AAZvD,0BAAkC,CAAC;AAEnC,gBAAiB,CAAC;AAElB,gCAA+B;AAE/B,oBAAW;AAcX;AAAA;AAAA;AAAA,sBAAa,CAAC,MAAc,mBAAmB,MAAM;AACnD,YAAM,SAAS,KAAK,qBAAqB,OAAO,gBAAgB;AAChE,aAAO,GAAG,MAAM,GAAG,IAAI;AAAA,IACzB;AAKA;AAAA;AAAA;AAAA,mBAAU,CAAC,MAAc,qBAA8B;AACrD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,QAAQ,OAAO;AAAA,IAC3B;AAKA;AAAA;AAAA;AAAA,gBAAO,CAAC,MAAc,qBAA8B;AAClD,YAAM,UAAU,KAAK,WAAW,MAAM,gBAAgB;AACtD,WAAK,KAAK,KAAK,OAAO;AAAA,IACxB;AAKA;AAAA;AAAA;AAAA,iBAAQ,MAAM;AACZ,WAAK,KAAK,KAAK,EAAE;AAAA,IACnB;AAKA;AAAA;AAAA;AAAA,gBAAO,MAAM;AACX,YAAM,iBAAiB,KAAK,KAAK,KAAK,KAAK,QAAQ;AACnD,YAAM,iBAAiB,KAAK,eAAe,OAAO,CAAC,aAAa,aAAa,SAAS,WAAW,GAAG,cAAc;AAClH,aAAO;AAAA,IACT;AAMA;AAAA;AAAA;AAAA;AAAA,4BAAmB,CAAC,kBAAiC;AACnD,WAAK,iBAAiB,CAAC,GAAG,KAAK,gBAAgB,aAAa;AAAA,IAC9D;AAlDE,SAAK,uBAAuB,UAAU;AACtC,SAAK,WAAW,QAAQ;AAAA,EAC1B;AAiDF","sourcesContent":["const DEFAULT_INDENTATION_CHARACTER = '';\nconst DEFAULT_LINE_JOIN = '\\n';\n\nexport type PostProcessor = (unreplacedCode: string) => string;\n\nexport interface CodeBuilderOptions {\n /**\n * Desired indentation character for aggregated lines of code\n * @default ''\n */\n indent?: string;\n\n /**\n * Desired character to join each line of code\n * @default \\n\n */\n join?: string;\n}\n\nexport class CodeBuilder {\n postProcessors: PostProcessor[] = [];\n\n code: string[] = [];\n\n indentationCharacter: string = DEFAULT_INDENTATION_CHARACTER;\n\n lineJoin = DEFAULT_LINE_JOIN;\n\n /**\n * Helper object to format and aggragate lines of code.\n * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.\n */\n constructor({ indent, join }: CodeBuilderOptions = {}) {\n this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;\n this.lineJoin = join ?? DEFAULT_LINE_JOIN;\n }\n\n /**\n * Add given indentation level to given line of code\n */\n indentLine = (line: string, indentationLevel = 0) => {\n const indent = this.indentationCharacter.repeat(indentationLevel);\n return `${indent}${line}`;\n };\n\n /**\n * Add the line at the beginning of the current lines\n */\n unshift = (line: string, indentationLevel?: number) => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.unshift(newLine);\n };\n\n /**\n * Add the line at the end of the current lines\n */\n push = (line: string, indentationLevel?: number) => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.push(newLine);\n };\n\n /**\n * Add an empty line at the end of current lines\n */\n blank = () => {\n this.code.push('');\n };\n\n /**\n * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added\n */\n join = () => {\n const unreplacedCode = this.code.join(this.lineJoin);\n const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);\n return replacedOutput;\n };\n\n /**\n * Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.\n * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.\n */\n addPostProcessor = (postProcessor: PostProcessor) => {\n this.postProcessors = [...this.postProcessors, postProcessor];\n };\n}\n"]}
@@ -1,65 +1,6 @@
1
+ import { CodeBuilder } from './chunk-UEOS42PC.mjs';
1
2
  import stringifyObject9 from 'stringify-object';
2
3
 
3
- // src/helpers/code-builder.ts
4
- var DEFAULT_INDENTATION_CHARACTER = "";
5
- var DEFAULT_LINE_JOIN = "\n";
6
- var CodeBuilder = class {
7
- /**
8
- * Helper object to format and aggragate lines of code.
9
- * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
10
- */
11
- constructor({ indent, join } = {}) {
12
- this.postProcessors = [];
13
- this.code = [];
14
- this.indentationCharacter = DEFAULT_INDENTATION_CHARACTER;
15
- this.lineJoin = DEFAULT_LINE_JOIN;
16
- /**
17
- * Add given indentation level to given line of code
18
- */
19
- this.indentLine = (line, indentationLevel = 0) => {
20
- const indent = this.indentationCharacter.repeat(indentationLevel);
21
- return `${indent}${line}`;
22
- };
23
- /**
24
- * Add the line at the beginning of the current lines
25
- */
26
- this.unshift = (line, indentationLevel) => {
27
- const newLine = this.indentLine(line, indentationLevel);
28
- this.code.unshift(newLine);
29
- };
30
- /**
31
- * Add the line at the end of the current lines
32
- */
33
- this.push = (line, indentationLevel) => {
34
- const newLine = this.indentLine(line, indentationLevel);
35
- this.code.push(newLine);
36
- };
37
- /**
38
- * Add an empty line at the end of current lines
39
- */
40
- this.blank = () => {
41
- this.code.push("");
42
- };
43
- /**
44
- * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
45
- */
46
- this.join = () => {
47
- const unreplacedCode = this.code.join(this.lineJoin);
48
- const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);
49
- return replacedOutput;
50
- };
51
- /**
52
- * Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.
53
- * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
54
- */
55
- this.addPostProcessor = (postProcessor) => {
56
- this.postProcessors = [...this.postProcessors, postProcessor];
57
- };
58
- this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
59
- this.lineJoin = join ?? DEFAULT_LINE_JOIN;
60
- }
61
- };
62
-
63
4
  // src/helpers/escape.ts
64
5
  function escapeString(rawValue, options = {}) {
65
6
  const { delimiter = '"', escapeChar = "\\", escapeNewlines = true } = options;
@@ -3482,4 +3423,4 @@ var addTargetClient = (targetId, client) => {
3482
3423
 
3483
3424
  export { addTarget, addTargetClient, getHeaderName, isClient, isTarget, targets };
3484
3425
  //# sourceMappingURL=out.js.map
3485
- //# sourceMappingURL=chunk-XPUGYZ4Y.mjs.map
3426
+ //# sourceMappingURL=chunk-WJGIOTIP.mjs.map