Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-genius

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-genius - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

4

dist/index.interfaces.d.ts

@@ -56,6 +56,2 @@ export interface ValueTypeConfiguration {

/**
* Return the string that would get rendered to a file. Enabling this prevents the file from being written.
*/
returnFileString?: boolean;
/**
* Whether to write the file or not.

@@ -62,0 +58,0 @@ */

29

dist/index.js

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildTypes = void 0;
exports.buildTypesFileString = exports.buildTypes = void 0;
var fs_1 = require("fs");

@@ -210,11 +210,2 @@ var path_1 = require("path");

var fileString = typesStore.map(function (t) { return t.string; }).join("\n\n") + "\n";
if (options === null || options === void 0 ? void 0 : options.returnFileString) {
var specialStringInterfaceConfigReturn = {
string: fileString,
typesConfig: {},
interfaceName: "Full File String",
};
// Return type will always be an array of InterfaceConfigs
return [specialStringInterfaceConfigReturn];
}
// Write the file using that string

@@ -236,1 +227,19 @@ var outputPath = (options === null || options === void 0 ? void 0 : options.outputPath) || "../dist/";

exports.buildTypes = buildTypes;
/**
* This function is very similar to buildTypes above, but instead we explicitly return a string
* This is so Typescript knows this one definitely returns a string, and the other definitely returns
* a TypeStore
*/
function buildTypesFileString(data, options) {
// Convert our object into our type configurations object
var types = generateTypeConfigFromObject(data, options || {});
// Types store will be our saved types for a file
// We can reuse these so future objects can reuse types or start from nothing to generate new ones
var typesStore = (options === null || options === void 0 ? void 0 : options.useStore) || [];
// Populate our store so we can write the interfaces to a file
createInterface(types, typesStore, options);
// Flatten to interface configurations to a single string
var fileString = typesStore.map(function (t) { return t.string; }).join("\n\n") + "\n";
return fileString;
}
exports.buildTypesFileString = buildTypesFileString;
{
"name": "type-genius",
"version": "0.0.7",
"version": "0.0.8",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -41,3 +41,2 @@ # Type Genius

| renderSemis | Boolean? | false | Render semicolons in the outputted file. |
| returnFileString | Boolean? | false | Return the string that would get rendered to a file. Enabling this prevents the file from being written. |
| skipFileWrite | Boolean? | false | Whether to write the file or not. |

@@ -44,0 +43,0 @@ | useStore | TypeStore? | [] | Store of existing InterfaceConfiguration objects to use for this generation. |

@@ -61,6 +61,2 @@ export interface ValueTypeConfiguration {

/**
* Return the string that would get rendered to a file. Enabling this prevents the file from being written.
*/
returnFileString?: boolean;
/**
* Whether to write the file or not.

@@ -67,0 +63,0 @@ */

import { test, expect, describe } from "@jest/globals";
import { buildTypes } from ".";
import { buildTypes, buildTypesFileString } from ".";

@@ -84,1 +84,10 @@ const testObj = {

});
describe("buildTypesFileString function", () => {
const str = buildTypesFileString(testObj);
test("ensures function returns a string", () => {
const val = typeof str;
expect(val).toBe("string");
});
});

@@ -269,12 +269,2 @@ import { writeFile } from "fs";

if (options?.returnFileString) {
const specialStringInterfaceConfigReturn: InterfaceConfig = {
string: fileString,
typesConfig: {},
interfaceName: "Full File String",
};
// Return type will always be an array of InterfaceConfigs
return [specialStringInterfaceConfigReturn];
}
// Write the file using that string

@@ -299,2 +289,27 @@ const outputPath = options?.outputPath || "../dist/";

/**
* This function is very similar to buildTypes above, but instead we explicitly return a string
* This is so Typescript knows this one definitely returns a string, and the other definitely returns
* a TypeStore
*/
export function buildTypesFileString(
data: { [key: string]: unknown },
options?: BuildOptions
) {
// Convert our object into our type configurations object
const types = generateTypeConfigFromObject(data, options || {});
// Types store will be our saved types for a file
// We can reuse these so future objects can reuse types or start from nothing to generate new ones
const typesStore: TypeStore = options?.useStore || [];
// Populate our store so we can write the interfaces to a file
createInterface(types, typesStore, options);
// Flatten to interface configurations to a single string
const fileString = typesStore.map((t) => t.string).join("\n\n") + "\n";
return fileString;
}
export {

@@ -301,0 +316,0 @@ type BuildOptions,

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc