🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@amritk/helpers

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amritk/helpers - npm Package Compare versions

Comparing version
0.10.0
to
0.10.1
+28
-5
dist/generate-type-definition.js

@@ -71,2 +71,12 @@ import { getMjstBrand, getMjstInstanceOf, getMjstPrimitive } from './mjst-extension.js';

};
/**
* Renders a possibly multi-line description as JSDoc body lines, prefixing each
* line with `${indent}* `. Blank lines become a bare `${indent}*` so we never
* emit trailing whitespace. Without this, embedded newlines would leave
* continuation lines unprefixed and break the comment block.
*/
const renderJsDocBody = (description, indent) => description
.split('\n')
.map((line) => (line.length > 0 ? `${indent}* ${line}\n` : `${indent}*\n`))
.join('');
const buildJsDocBlock = (title, description, commentUrl) => {

@@ -76,3 +86,3 @@ let block = `/**\n`;

block += `*\n`;
block += `* ${description}\n`;
block += renderJsDocBody(description, '');
if (commentUrl?.startsWith('http')) {

@@ -86,2 +96,15 @@ block += `* \n`;

/**
* Builds the inline JSDoc comment that precedes a generated property. A
* single-line description stays compact (` /** text *\/`); a multi-line
* description expands into an asterisk-prefixed block so every line is
* commented. The returned string always ends with a newline, ready for the
* property declaration to follow.
*/
const buildInlinePropertyComment = (description) => {
if (!description.includes('\n')) {
return ` /** ${description} */\n`;
}
return ` /**\n${renderJsDocBody(description, ' ')} */\n`;
};
/**
* Converts a JSON Schema type to its TypeScript equivalent, applying any

@@ -305,5 +328,4 @@ * `x-mjst` brand. Branding is type-level only, so we compute the underlying

properties +=
' /** ' +
inlineDescription +
' */\n ' +
buildInlinePropertyComment(inlineDescription) +
' ' +
readonlyPrefix +

@@ -451,3 +473,4 @@ safeKey(key) +

if (inlineDescription) {
properties += ' /** ' + inlineDescription + ' */\n ' + quotedKey + optional + ': ' + propType + ';';
properties +=
buildInlinePropertyComment(inlineDescription) + ' ' + quotedKey + optional + ': ' + propType + ';';
}

@@ -454,0 +477,0 @@ else {

+1
-1
{
"name": "@amritk/helpers",
"version": "0.10.0",
"version": "0.10.1",
"description": "Shared utilities for the mjst code generation ecosystem.",

@@ -5,0 +5,0 @@ "type": "module",