@basketry/sorbet
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -90,7 +90,3 @@ "use strict"; | ||
yield ''; | ||
yield* new sig_factory_1.SigFactory(method, self.service, self.options, { | ||
block: utils_1.block, | ||
comment: utils_1.comment, | ||
indent: utils_1.indent, | ||
}).build(); | ||
yield* new sig_factory_1.SigFactory(method, self.service, self.options, utils_1.formatter).build(); | ||
} | ||
@@ -97,0 +93,0 @@ })); |
import { Method, Service } from 'basketry'; | ||
import { NamespacedSorbetOptions } from './types'; | ||
import { BlockFunction, CommentFunction, Contents, IndentFunction } from './utils'; | ||
import { Contents, Formatter } from './utils'; | ||
export declare class SigFactory { | ||
@@ -9,7 +9,3 @@ private readonly method; | ||
private readonly contents?; | ||
constructor(method: Method, service: Service, options: NamespacedSorbetOptions | undefined, formatter: { | ||
block: BlockFunction; | ||
comment: CommentFunction; | ||
indent: IndentFunction; | ||
}, contents?: Contents | undefined); | ||
constructor(method: Method, service: Service, options: NamespacedSorbetOptions | undefined, formatter: Formatter, contents?: Contents | undefined); | ||
private readonly comment; | ||
@@ -16,0 +12,0 @@ private readonly block; |
@@ -13,4 +13,14 @@ export declare function from(lines: Iterable<string>): string; | ||
export declare type IndentFunction = typeof indent; | ||
/** Unindents the supplied contents if the current indentation is > 0. Indentation is preserved between calls. */ | ||
export declare function unindent(contents: Contents): Iterable<string>; | ||
export declare type UnindentFunction = typeof unindent; | ||
/** Comments the supplied contents. Empty lines are preserved. */ | ||
export declare function comment(contents?: Contents): Iterable<string>; | ||
export declare type CommentFunction = typeof comment; | ||
export declare type Formatter = { | ||
block: BlockFunction; | ||
comment: CommentFunction; | ||
indent: IndentFunction; | ||
unindent: UnindentFunction; | ||
}; | ||
export declare const formatter: Formatter; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.comment = exports.indent = exports.block = exports.from = void 0; | ||
exports.formatter = exports.comment = exports.unindent = exports.indent = exports.block = exports.from = void 0; | ||
function from(lines) { | ||
@@ -36,2 +36,20 @@ return Array.from(lines).join('\n'); | ||
exports.indent = indent; | ||
/** Unindents the supplied contents if the current indentation is > 0. Indentation is preserved between calls. */ | ||
function* unindent(contents) { | ||
const changeIndent = indentCount > 0; | ||
try { | ||
if (changeIndent) | ||
indentCount--; | ||
for (const line of iter(contents)) { | ||
yield line.trim().length | ||
? `${indentation.repeat(indentCount)}${line.trim()}` | ||
: ''; | ||
} | ||
} | ||
finally { | ||
if (changeIndent) | ||
indentCount++; | ||
} | ||
} | ||
exports.unindent = unindent; | ||
/** Comments the supplied contents. Empty lines are preserved. */ | ||
@@ -56,2 +74,8 @@ function* comment(contents) { | ||
} | ||
exports.formatter = { | ||
block, | ||
comment, | ||
indent, | ||
unindent, | ||
}; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@basketry/sorbet", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "Basketry generator for generating Sorbet types and interfaces", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63217
742