Socket
Socket
Sign inDemoInstall

@basketry/sorbet

Package Overview
Dependencies
71
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.16 to 0.0.17

77

lib/interface-factory.js

@@ -89,4 +89,4 @@ "use strict";

yield '';
yield* self.comment(method.description);
yield* self.buildSignature(method);
yield* self.buildYardDoc(method);
yield* self.buildDefinition(method);

@@ -145,2 +145,77 @@ }

}
*buildYardDoc(method) {
if (method.description || method.parameters.length || method.returnType) {
yield* (0, utils_1.comment)();
}
if (method.description) {
if (Array.isArray(method.description)) {
let first = false;
for (const line of method.description) {
if (first)
first = false;
else
yield* (0, utils_1.comment)();
yield* (0, utils_1.comment)(line.value);
}
}
else {
yield* (0, utils_1.comment)(method.description.value);
}
}
if (method.parameters.length) {
if (method.description)
yield* (0, utils_1.comment)();
for (const param of method.parameters) {
yield* (0, utils_1.comment)(`@param [${this.buildParameterType(param)}] ${(0, name_factory_1.buildParameterName)(param)}${this.buildParameterDescription(param)}`);
}
}
if (method.returnType) {
if (method.description || method.parameters.length)
yield* (0, utils_1.comment)();
yield* (0, utils_1.comment)(`@return [${this.buildReturnType(method.returnType)}]`);
}
if (method.description || method.parameters.length || method.returnType) {
yield* (0, utils_1.comment)();
}
}
buildParameterType(param) {
const baseType = (0, name_factory_1.buildTypeName)({
type: param,
options: this.options,
service: this.service,
skipArrayify: true,
});
const arrayified = param.isArray ? `Array<${baseType}>` : baseType;
return (0, basketry_1.isRequired)(param) ? arrayified : `${arrayified}, nil`;
}
buildReturnType(param) {
const baseType = (0, name_factory_1.buildTypeName)({
type: param,
options: this.options,
service: this.service,
skipArrayify: true,
});
return param.isArray ? `Array<${baseType}>` : baseType;
}
buildParameterDescription(param) {
if (!param.description) {
return '';
}
else if (Array.isArray(param.description)) {
if (param.description.length) {
return ` ${param.description.map((d) => d.value).join(' ')}`;
}
else {
return '';
}
}
else {
if (param.description.value.length) {
return ` ${param.description.value}`;
}
else {
return '';
}
}
}
*buildDefinition(method) {

@@ -147,0 +222,0 @@ const parameters = method.parameters.length

2

lib/utils.d.ts

@@ -12,2 +12,2 @@ export declare function from(lines: Iterable<string>): string;

/** Comments the supplied contents. Empty lines are preserved. */
export declare function comment(contents: Contents): Iterable<string>;
export declare function comment(contents?: Contents): Iterable<string>;

@@ -38,5 +38,10 @@ "use strict";

function* comment(contents) {
for (const line of iter(contents)) {
yield line.length ? `# ${line}` : '#';
if (!contents) {
yield '#';
}
else {
for (const line of iter(contents)) {
yield line.length ? `# ${line}` : '#';
}
}
}

@@ -43,0 +48,0 @@ exports.comment = comment;

{
"name": "@basketry/sorbet",
"version": "0.0.16",
"version": "0.0.17",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc