New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ylenia

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ylenia - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

71

functions.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeFile = exports.getIdentifier = exports.createControllerSave = exports.createControllerRemove = exports.createControllerLoad = exports.createControllerImports = exports.createControllerGetAll = exports.createControllerGet = exports.createControllerExist = exports.createControllerConstructor = exports.createControllerAddProtected = exports.createControllerAdd = void 0;
exports.writeFile = exports.getIdentifier = exports.createObjectSetMethods = exports.createObjectGetMethods = exports.createObjectDeclarations = exports.createObjectConstructor = exports.createControllerSave = exports.createControllerRemove = exports.createControllerLoad = exports.createControllerImports = exports.createControllerGetAll = exports.createControllerGet = exports.createControllerExist = exports.createControllerConstructor = exports.createControllerAddProtected = exports.createControllerAdd = void 0;
//Imports

@@ -11,3 +11,3 @@ var samara_1 = require("samara");

sc.add("add(" + source.controller_object.toLowerCase() + ":" + source.object_name + "):void{", 1);
sc.add("this." + source.controller_array + ".push(" + source.controller_object.toLowerCase() + ");", 2);
sc.add("this." + source.array + ".push(" + source.controller_object.toLowerCase() + ");", 2);
sc.add("}", 1);

@@ -34,3 +34,3 @@ return sc.getString();

}
sc.add("this." + source.controller_array + " = [];", 2);
sc.add("this." + source.array + " = [];", 2);
sc.add("this.load();", 2);

@@ -54,3 +54,3 @@ sc.add("}", 1);

sc.add("get(" + identifier.name + ":" + identifier.type + "):" + source.object_name + "{", 1);
sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.controller_array + "){", 2);
sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.array + "){", 2);
sc.add("if(" + source.controller_object.toLowerCase() + "." + identifier.name + " === " + identifier.name + "){", 3);

@@ -95,3 +95,3 @@ sc.add("return " + source.controller_object.toLowerCase() + ";", 4);

sc.add("let object:" + source.object_name + " = new " + source.object_name + "(" + paras + ");", 3);
sc.add("this." + source.controller_array + ".push(object);", 3);
sc.add("this." + source.array + ".push(object);", 3);
sc.add("}", 2);

@@ -121,3 +121,3 @@ sc.add("}", 1);

//sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.controller_array + "){", 2);
sc.add("let json:string = JSON.stringify(this." + source.controller_array + ");", 2);
sc.add("let json:string = JSON.stringify(this." + source.array + ");", 2);
sc.add("func.writeFile(\"" + source.json + "\", json);", 2);

@@ -130,2 +130,61 @@ //TODO: All

exports.createControllerSave = createControllerSave;
function createObjectConstructor(source) {
var sc = new samara_1.SourceObject();
sc.add("//Constructor", 1);
var con = "constructor(";
var count = 0;
for (var _i = 0, _a = source.attributes; _i < _a.length; _i++) {
var att = _a[_i];
if (att.initialize) {
count > 0 ? con += ", " : undefined;
con += att.name + ":" + att.type;
count++;
}
}
con += "){";
sc.add(con, 1);
for (var _b = 0, _c = source.attributes; _b < _c.length; _b++) {
var att = _c[_b];
if (att.initialize) {
sc.add("this." + att.name + " = " + att.name + ";", 2);
}
}
sc.add("}", 1);
return sc.getString();
}
exports.createObjectConstructor = createObjectConstructor;
function createObjectDeclarations(source) {
var sc = new samara_1.SourceObject();
sc.add("//Declarations", 1);
for (var _i = 0, _a = source.attributes; _i < _a.length; _i++) {
var att = _a[_i];
sc.add("private _" + att.name + ":" + att.type + ";", 1);
}
return sc.getString();
}
exports.createObjectDeclarations = createObjectDeclarations;
function createObjectGetMethods(source) {
var sc = new samara_1.SourceObject();
sc.add("//Get-Methods", 1);
for (var i = 0; i < source.attributes.length; i++) {
sc.add("get " + source.attributes[i].name + "():" + source.attributes[i].type + "{", 1);
sc.add("return this._" + source.attributes[i].name + ";", 2);
sc.add("}", 1);
i < source.attributes.length - 1 ? sc.newLine() : undefined;
}
return sc.getString();
}
exports.createObjectGetMethods = createObjectGetMethods;
function createObjectSetMethods(source) {
var sc = new samara_1.SourceObject();
sc.add("//Set-Methods", 1);
for (var i = 0; i < source.attributes.length; i++) {
sc.add("set " + source.attributes[i].name + "(value:" + source.attributes[i].type + "){", 1);
sc.add("this._" + source.attributes[i].name + " = value;", 2);
sc.add("}", 1);
i < source.attributes.length - 1 ? sc.newLine() : undefined;
}
return sc.getString();
}
exports.createObjectSetMethods = createObjectSetMethods;
function getIdentifier(attributes) {

@@ -132,0 +191,0 @@ for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {

@@ -9,3 +9,3 @@ //Imports

sc.add("add(" + source.controller_object.toLowerCase() + ":" + source.object_name + "):void{", 1);
sc.add("this." + source.controller_array + ".push(" + source.controller_object.toLowerCase() + ");", 2);
sc.add("this." + source.array + ".push(" + source.controller_object.toLowerCase() + ");", 2);
sc.add("}", 1);

@@ -32,3 +32,3 @@ return sc.getString();

}
sc.add("this." + source.controller_array + " = [];", 2);
sc.add("this." + source.array + " = [];", 2);
sc.add("this.load();", 2);

@@ -52,3 +52,3 @@ sc.add("}", 1);

sc.add("get(" + identifier.name + ":" + identifier.type + "):" + source.object_name + "{", 1);
sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.controller_array + "){", 2);
sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.array + "){", 2);
sc.add("if(" + source.controller_object.toLowerCase() + "." + identifier.name + " === " + identifier.name + "){", 3);

@@ -93,3 +93,3 @@ sc.add("return " + source.controller_object.toLowerCase() + ";", 4);

sc.add("let object:" + source.object_name + " = new " + source.object_name + "(" + paras + ");", 3);
sc.add("this." + source.controller_array + ".push(object);", 3);
sc.add("this." + source.array + ".push(object);", 3);
sc.add("}", 2);

@@ -119,3 +119,3 @@ sc.add("}", 1);

//sc.add("for(let " + source.controller_object.toLowerCase() + " of this." + source.controller_array + "){", 2);
sc.add("let json:string = JSON.stringify(this." + source.controller_array + ");", 2);
sc.add("let json:string = JSON.stringify(this." + source.array + ");", 2);
sc.add("func.writeFile(\"" + source.json + "\", json);", 2);

@@ -130,2 +130,58 @@

export function createObjectConstructor(source):string{
let sc:SourceObject = new SourceObject();
sc.add("//Constructor", 1);
let con:string = "constructor(";
let count:number = 0;
for(let att of source.attributes){
if(att.initialize){
count > 0 ? con += ", " : undefined;
con += att.name + ":" + att.type;
count++;
}
}
con += "){";
sc.add(con, 1);
for(let att of source.attributes){
if(att.initialize){
sc.add("this." + att.name + " = " + att.name + ";", 2);
}
}
sc.add("}", 1);
return sc.getString();
}
export function createObjectDeclarations(source):string{
let sc:SourceObject = new SourceObject();
sc.add("//Declarations", 1);
for(let att of source.attributes){
sc.add("private _" + att.name + ":" + att.type + ";", 1);
}
return sc.getString();
}
export function createObjectGetMethods(source):string{
let sc:SourceObject = new SourceObject();
sc.add("//Get-Methods", 1);
for(let i = 0; i < source.attributes.length; i++){
sc.add("get " + source.attributes[i].name + "():" + source.attributes[i].type + "{", 1);
sc.add("return this._" + source.attributes[i].name + ";", 2);
sc.add("}", 1);
i < source.attributes.length - 1 ? sc.newLine() : undefined;
}
return sc.getString();
}
export function createObjectSetMethods(source):string{
let sc:SourceObject = new SourceObject();
sc.add("//Set-Methods", 1);
for(let i = 0; i < source.attributes.length; i++){
sc.add("set " + source.attributes[i].name + "(value:" + source.attributes[i].type + "){", 1);
sc.add("this._" + source.attributes[i].name + " = value;", 2);
sc.add("}", 1);
i < source.attributes.length - 1 ? sc.newLine() : undefined;
}
return sc.getString();
}
export function getIdentifier(attributes){

@@ -132,0 +188,0 @@ for(let att of attributes){

52

index.js

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

sc.add("//Declarations", 1);
sc.add("private readonly " + source.controller_array + ":" + source.object_name + "[];", 1);
sc.add("private readonly " + source.array + ":" + source.object_name + "[];", 1);
sc.newLine();

@@ -52,5 +52,2 @@ sc.add(func.createControllerConstructor(source), 0);

var sc = new samara_1.SourceObject();
//sc.add("//Imports", 0);
//sc.add(func.createImportData(source.json), 0);
//sc.newLine();
sc.add("//Class", 0);

@@ -62,45 +59,6 @@ var ext = "";

sc.add("export class " + source.object_name + ext + "{", 0);
sc.add("//Declarations", 1);
for (var _i = 0, _a = source.attributes; _i < _a.length; _i++) {
var att = _a[_i];
sc.add("private _" + att.name + ":" + att.type + ";", 1);
}
sc.newLine();
sc.add("//Constructor", 1);
var con = "constructor(";
var count = 0;
for (var _b = 0, _c = source.attributes; _b < _c.length; _b++) {
var att = _c[_b];
if (att.initialize) {
count > 0 ? con += ", " : undefined;
con += att.name + ":" + att.type;
count++;
}
}
con += "){";
sc.add(con, 1);
for (var _d = 0, _e = source.attributes; _d < _e.length; _d++) {
var att = _e[_d];
if (att.initialize) {
sc.add("this." + att.name + " = " + att.name + ";", 2);
}
}
sc.add("}", 1);
sc.newLine();
sc.add("//Get-Methods", 1);
for (var _f = 0, _g = source.attributes; _f < _g.length; _f++) {
var att = _g[_f];
sc.add("get " + att.name + "():" + att.type + "{", 1);
sc.add("return this._" + att.name + ";", 2);
sc.add("}", 1);
sc.newLine();
}
sc.add("//Set-Methods", 1);
for (var _h = 0, _j = source.attributes; _h < _j.length; _h++) {
var att = _j[_h];
sc.add("set " + att.name + "(value:" + att.type + "){", 1);
sc.add("this._" + att.name + " = value;", 2);
sc.add("}", 1);
sc.newLine();
}
sc.add(func.createObjectDeclarations(source), 0);
sc.add(func.createObjectConstructor(source), 0);
sc.add(func.createObjectGetMethods(source), 0);
sc.add(func.createObjectSetMethods(source), 0);
sc.add("}", 0);

@@ -107,0 +65,0 @@ sys.writeFile(source.object_file, sc.getString());

@@ -39,3 +39,3 @@ //Imports

sc.add("//Declarations", 1);
sc.add("private readonly " + source.controller_array + ":" + source.object_name + "[];", 1);
sc.add("private readonly " + source.array + ":" + source.object_name + "[];", 1);
sc.newLine();

@@ -59,5 +59,2 @@ sc.add(func.createControllerConstructor(source), 0);

let sc:SourceObject = new SourceObject();
//sc.add("//Imports", 0);
//sc.add(func.createImportData(source.json), 0);
//sc.newLine();
sc.add("//Class", 0);

@@ -69,40 +66,6 @@ let ext:string = "";

sc.add("export class " + source.object_name + ext + "{", 0);
sc.add("//Declarations", 1);
for(let att of source.attributes){
sc.add("private _" + att.name + ":" + att.type + ";", 1);
}
sc.newLine();
sc.add("//Constructor", 1);
let con:string = "constructor(";
let count:number = 0;
for(let att of source.attributes){
if(att.initialize){
count > 0 ? con += ", " : undefined;
con += att.name + ":" + att.type;
count++;
}
}
con += "){";
sc.add(con, 1);
for(let att of source.attributes){
if(att.initialize){
sc.add("this." + att.name + " = " + att.name + ";", 2);
}
}
sc.add("}", 1);
sc.newLine();
sc.add("//Get-Methods", 1);
for(let att of source.attributes){
sc.add("get " + att.name + "():" + att.type + "{", 1);
sc.add("return this._" + att.name + ";", 2);
sc.add("}", 1);
sc.newLine();
}
sc.add("//Set-Methods", 1);
for(let att of source.attributes){
sc.add("set " + att.name + "(value:" + att.type + "){", 1);
sc.add("this._" + att.name + " = value;", 2);
sc.add("}", 1);
sc.newLine();
}
sc.add(func.createObjectDeclarations(source), 0);
sc.add(func.createObjectConstructor(source), 0);
sc.add(func.createObjectGetMethods(source), 0);
sc.add(func.createObjectSetMethods(source), 0);
sc.add("}", 0);

@@ -109,0 +72,0 @@ sys.writeFile(source.object_file, sc.getString());

{
"name": "ylenia",
"version": "0.1.0",
"description": "TypeScript-DataSources for JSON. Generates dynamic TS-Files.",
"version": "0.1.1",
"description": "TypeScript-DataSources for JSON. Generates dynamic TypeScript-Classes and JSON-Files.",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {},

# Ylenia
TypeScript-Code-Generator in Development-Status.
TypeScript-Code- and JSON-Generator.
## Not finished yet!

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc