@readme/httpsnippet 10.1.1 → 11.1.0
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/README.md +2 -2
- package/dist/{chunk-Y7NI4MMY.js → chunk-6B3J3CUI.js} +2 -2
- package/dist/chunk-6B3J3CUI.js.map +1 -0
- package/dist/{chunk-532RKFLR.js → chunk-EFUQ6POB.js} +77 -276
- package/dist/chunk-EFUQ6POB.js.map +1 -0
- package/dist/{chunk-KT7MO6Z4.js → chunk-LCVMSGCB.js} +2 -2
- package/dist/chunk-LCVMSGCB.js.map +1 -0
- package/dist/helpers/code-builder.cjs.map +1 -1
- package/dist/helpers/code-builder.js +1 -1
- package/dist/helpers/reducer.cjs.map +1 -1
- package/dist/helpers/reducer.js +1 -1
- package/dist/index.cjs +141 -325
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +27 -12
- package/dist/index.js.map +1 -1
- package/dist/targets/index.cjs +75 -274
- package/dist/targets/index.cjs.map +1 -1
- package/dist/targets/index.d.cts +160 -6
- package/dist/targets/index.d.ts +160 -6
- package/dist/targets/index.js +2 -2
- package/package.json +16 -17
- package/dist/chunk-532RKFLR.js.map +0 -1
- package/dist/chunk-KT7MO6Z4.js.map +0 -1
- package/dist/chunk-Y7NI4MMY.js.map +0 -1
- package/dist/index-Bi-oJSCB.d.ts +0 -164
- package/dist/index-CM3ebXTM.d.cts +0 -164
package/README.md
CHANGED
|
@@ -109,8 +109,8 @@ console.log(
|
|
|
109
109
|
}),
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
// generate Node.js:
|
|
113
|
-
console.log(snippet.convert('node', '
|
|
112
|
+
// generate Node.js: Axios output
|
|
113
|
+
console.log(snippet.convert('node', 'axios'));
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
### addTarget(target)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/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AA,KACnB;AAKA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,IAAA,GAAO,MAAc;AACnB,MAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,KAAK,QAAQ,CAAA;AACnD,MAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,cAAA,CAAe,MAAA,CAAO,CAAC,aAAa,QAAA,KAAa,QAAA,CAAS,WAAW,CAAA,EAAG,cAAc,CAAA;AAClH,MAAA,OAAO,cAAA;AAAA,KACT;AAMA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,gBAAA,GAAmB,CAAC,aAAA,KAAuC;AACzD,MAAA,IAAA,CAAK,cAAA,GAAiB,CAAC,GAAG,IAAA,CAAK,gBAAgB,aAAa,CAAA;AAAA,KAC9D;AAlDE,IAAA,IAAA,CAAK,uBAAuB,MAAA,IAAU,6BAAA;AACtC,IAAA,IAAA,CAAK,WAAW,IAAA,IAAQ,iBAAA;AAAA;AAkD5B","file":"chunk-6B3J3CUI.js","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: string = 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): void => {\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): void => {\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 = (): void => {\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 = (): string => {\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): void => {\n this.postProcessors = [...this.postProcessors, postProcessor];\n };\n}\n"]}
|