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

@krlwlfrt/tsg

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@krlwlfrt/tsg - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# [0.5.0](https://gitlab.com/krlwlfrt/tsg/compare/v0.4.0...v0.5.0) (2020-03-06)
### Features
* add enum type and make namespace optional ([47fce6c](https://gitlab.com/krlwlfrt/tsg/commit/47fce6c0a2f3395d39c8d7f5aa3b02fe7ffba9f5))
# [0.4.0](https://gitlab.com/krlwlfrt/tsg/compare/v0.3.1...v0.4.0) (2020-03-04)

@@ -2,0 +11,0 @@

5

lib/examples.js

@@ -27,2 +27,5 @@ "use strict";

}
if (typeof thing.namespace !== 'string' || thing.namespace.length === 0) {
return thing.name;
}
return `${thing.namespace}_${thing.name}`;

@@ -51,2 +54,2 @@ }

exports.generatePropertyType = generatePropertyType;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhhbXBsZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZXhhbXBsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7Ozs7Ozs7Ozs7OztHQWFHO0FBQ0gsbUNBQXlFO0FBRXpFOzs7O0dBSUc7QUFDSCxTQUFnQixZQUFZLENBQUMsS0FBZ0M7SUFDM0QsSUFBSSxtQkFBVyxDQUFDLEtBQUssQ0FBQyxFQUFFO1FBQ3RCLE9BQU8sS0FBSyxDQUFDLElBQUksQ0FBQztLQUNuQjtJQUVELE9BQU8sR0FBRyxLQUFLLENBQUMsU0FBUyxJQUFJLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQztBQUM1QyxDQUFDO0FBTkQsb0NBTUM7QUFFRD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xLQUFLLENBQUMsU0FBUyxLQUFLLFFBQVEsSUFBSSxLQUFLLENBQUMsU0FBUyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDdkUsT0FBTyxLQUFLLENBQUMsSUFBSSxDQUFDO0tBQ25CO0lBRUQsT0FBTyxHQUFHLEtBQUssQ0FBQyxTQUFTLElBQUksS0FBSyxDQUFDLElBQUksRUFBRSxDQUFDO0FBQzVDLENBQUM7QUFWRCxvQ0FVQztBQUVEOzs7O0dBSUc7QUFDSCxTQUFnQixvQkFBb0IsQ0FBQyxRQUFrQjtJQUNyRCxJQUFJLElBQUksR0FBRyxZQUFZLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRXZDLElBQUksUUFBUSxDQUFDLElBQUksQ0FBQyxTQUFTLEtBQUssS0FBSyxFQUFFO1FBQ3JDLElBQUksR0FBRyxRQUFRLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztLQUN6QztJQUVELElBQUksS0FBSyxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUFDLEVBQUU7UUFDdEMsS0FBSyxNQUFNLFNBQVMsSUFBSSxRQUFRLENBQUMsVUFBVSxFQUFFO1lBQzNDLElBQUksU0FBUyxDQUFDLElBQUksS0FBSyxVQUFVLElBQUksT0FBTyxTQUFTLENBQUMsS0FBSyxLQUFLLFNBQVMsSUFBSSxTQUFTLENBQUMsS0FBSyxFQUFFO2dCQUM1RixJQUFJLElBQUksU0FBUyxDQUFDO2FBQ25CO1NBQ0Y7S0FDRjtJQUVELE9BQU8sSUFBSSxDQUFDO0FBQ2QsQ0FBQztBQWhCRCxvREFnQkMifQ==

28

lib/index.d.ts

@@ -16,3 +16,3 @@ /**

*/
namespace: string;
namespace?: string;
/**

@@ -26,3 +26,3 @@ * Default value

*/
export declare type Type = Entity | Property | Union;
export declare type Type = Entity | Property | Union | Enum;
/**

@@ -81,2 +81,20 @@ * An entity

/**
* An enumeration of values
*/
export interface Enum extends ThingWithNameAndNamespace {
/**
* List of values
*/
items: {
/**
* Key of the item
*/
key: string;
/**
* Value of the item
*/
value: string | number | boolean;
}[];
}
/**
* Check if a Type is an Entity

@@ -94,2 +112,8 @@ *

/**
* Check if a Type is an Enum
*
* @param type Type to check
*/
export declare function isEnum(type: Type): type is Enum;
/**
* Check if a ThingWithNameAndNamespace is an Attribute

@@ -96,0 +120,0 @@ *

@@ -42,2 +42,14 @@ "use strict";

/**
* Check if a Type is an Enum
*
* @param type Type to check
*/
function isEnum(type) {
if (!('items' in type)) {
return false;
}
return Array.isArray(type.items);
}
exports.isEnum = isEnum;
/**
* Check if a ThingWithNameAndNamespace is an Attribute

@@ -165,2 +177,16 @@ *

}
else if (isEnum(type)) {
output += `export enum ${nameGenerator(type)} {
`;
for (const item of type.items) {
let value = item.value;
if (typeof value === 'string') {
value = `'${value}'`;
}
output += ` ${item.key} = ${value},
`;
}
output += `}
`;
}
else {

@@ -174,2 +200,2 @@ output += `export type ${nameGenerator(type)} = ${propertyTypeGenerator(type)};

exports.generateTypeScript = generateTypeScript;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7O0dBYUc7O0FBNEZIOzs7O0dBSUc7QUFDSCxTQUFnQixRQUFRLENBQUMsSUFBVTtJQUNqQyxJQUFJLENBQUMsQ0FBQyxZQUFZLElBQUksSUFBSSxDQUFDLEVBQUU7UUFDM0IsT0FBTyxLQUFLLENBQUM7S0FDZDtJQUVELE9BQU8sS0FBSyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDeEMsQ0FBQztBQU5ELDRCQU1DO0FBRUQ7Ozs7R0FJRztBQ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RjtJQUVELE9BQU8sTUFBTSxDQUFDO0FBQ2hCLENBQUM7QUEvR0QsZ0RBK0dDIn0=
{
"name": "@krlwlfrt/tsg",
"version": "0.4.0",
"version": "0.5.0",
"description": "TypeScript generator",

@@ -5,0 +5,0 @@ "repository": {

@@ -27,2 +27,6 @@ /*

if (typeof thing.namespace !== 'string' || thing.namespace.length === 0) {
return thing.name;
}
return `${thing.namespace}_${thing.name}`;

@@ -29,0 +33,0 @@ }

@@ -33,3 +33,3 @@ /*

*/
namespace: string;
namespace?: string;

@@ -45,3 +45,3 @@ /**

*/
export type Type = Entity | Property | Union;
export type Type = Entity | Property | Union | Enum;

@@ -109,2 +109,21 @@ /**

/**
* An enumeration of values
*/
export interface Enum extends ThingWithNameAndNamespace {
/**
* List of values
*/
items: {
/**
* Key of the item
*/
key: string;
/**
* Value of the item
*/
value: string | number | boolean;
}[];
}
/**
* Check if a Type is an Entity

@@ -136,2 +155,15 @@ *

/**
* Check if a Type is an Enum
*
* @param type Type to check
*/
export function isEnum(type: Type): type is Enum {
if (!('items' in type)) {
return false;
}
return Array.isArray(type.items);
}
/**
* Check if a ThingWithNameAndNamespace is an Attribute

@@ -284,2 +316,19 @@ *

`;
} else if (isEnum(type)) {
output += `export enum ${nameGenerator(type)} {
`;
for (const item of type.items) {
let value = item.value;
if (typeof value === 'string') {
value = `'${value}'`;
}
output += ` ${item.key} = ${value},
`;
}
output += `}
`;
} else {

@@ -286,0 +335,0 @@ output += `export type ${nameGenerator(type)} = ${propertyTypeGenerator(type)};

Sorry, the diff of this file is too big to display

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