Comparing version 4.2.0 to 4.3.0
@@ -5,2 +5,3 @@ import { Node } from './Node'; | ||
private placeholders; | ||
trim: boolean; | ||
constructor(literals: TemplateStringsArray, placeholders: any[]); | ||
@@ -7,0 +8,0 @@ /** |
@@ -24,2 +24,4 @@ "use strict"; | ||
this.placeholders = placeholders; | ||
// Used by joinCode | ||
this.trim = false; | ||
} | ||
@@ -61,3 +63,4 @@ /** | ||
toCodeString() { | ||
return this.generateCode(); | ||
const code = this.generateCode(); | ||
return this.trim ? code.trim() : code; | ||
} | ||
@@ -64,0 +67,0 @@ deepFindImports() { |
@@ -10,3 +10,6 @@ import { Import } from './Import'; | ||
export declare function arrayOf(...elements: unknown[]): Node; | ||
export declare function joinCode(chunks: Code[], separator?: string): Code; | ||
export declare function joinCode(chunks: Code[], opts?: { | ||
on?: string; | ||
trim?: boolean; | ||
}): Code; | ||
/** Creates an import that will be auto-imported at the top of the output file. */ | ||
@@ -13,0 +16,0 @@ export declare function imp(spec: string, opts?: { |
@@ -27,7 +27,11 @@ "use strict"; | ||
exports.arrayOf = arrayOf; | ||
function joinCode(chunks, separator = '') { | ||
function joinCode(chunks, opts = {}) { | ||
const { on = '', trim = true } = opts; | ||
const literals = ['']; | ||
for (let i = 0; i < chunks.length - 1; i++) { | ||
literals.push(separator); | ||
literals.push(on); | ||
} | ||
if (trim) { | ||
chunks.forEach((c) => (c.trim = true)); | ||
} | ||
return new Code_1.Code(literals, chunks); | ||
@@ -34,0 +38,0 @@ } |
{ | ||
"name": "ts-poet", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "code generation DSL for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100354
1853