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

@sean_kenny/eu4-text-file-to-json-parser-js

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sean_kenny/eu4-text-file-to-json-parser-js - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

1

build/parse-eu4-text-file-to-json.d.ts

@@ -9,3 +9,4 @@ import { ValueOrNestedValue } from "./value-or-nested-value.js";

export type OutputJSONData = Record<string, ValueOrNestedValue<string>>;
export declare const seperator = "\u0416\u0416\u0416\u0416\u0416\u0416\u0416\u0416\u0416\u0416";
export declare const parseEu4TextFileToJson: (input: ParseEu4TextFileToJsonInput) => Promise<ParseEu4TextFileToJsonOutput>;
export {};

18

build/parse-eu4-text-file-to-json.js
import { readFile } from "fs/promises";
import { writeValueToOutputJSONData } from "./write-value-to-output-json-data.js";
// All that really matters is that this value isn't used anywhere in the text file, we're treating it as a special character
export const seperator = 'ЖЖЖЖЖЖЖЖЖЖ';
export const parseEu4TextFileToJson = async (input) => {

@@ -17,3 +19,3 @@ const rawFileData = await readFile(input.inputFilePath, { encoding: 'utf-8' });

}
else if (/^([a-zA-Z0-9_])+(\ )*=(\ )*{([a-zA-Z0-9_\ /".\-'])*}$/.test(cleanedRow)) {
else if (/^([a-zA-Z0-9_\.])+(\ )*=(\ )*{([a-zA-Z0-9_\ /".\-'])*}$/.test(cleanedRow)) {
// This is in the format "property_name = { ... }"

@@ -30,11 +32,11 @@ const splitCleanedRow = cleanedRow.split('=').map((element) => element.trim());

outputJSONData,
currentKeyToPushTo: `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? '.' : ''}${propertyName}`,
currentKeyToPushTo: `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? seperator : ''}${propertyName}`,
valueToPush: elements
});
}
else if (/^([a-zA-Z0-9_])+(\ )*=(\ )*{$/.test(cleanedRow)) {
else if (/^([a-zA-Z0-9_\.])+(\ )*=(\ )*{$/.test(cleanedRow)) {
// This is in the format "property_name = {"
const splitCleanedRow = cleanedRow.split('=').map((element) => element.trim());
const propertyName = splitCleanedRow[0];
currentKeyToPushTo = `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? '.' : ''}${propertyName}`;
currentKeyToPushTo = `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? seperator : ''}${propertyName}`;
outputJSONData = writeValueToOutputJSONData({

@@ -52,7 +54,7 @@ outputJSONData,

currentKeyToPushTo = currentKeyToPushTo
.split('.')
.split(seperator)
.slice(0, -1)
.join('.');
.join(seperator);
}
else if (/^([a-zA-Z0-9_])+(\ )*=(\ )*([a-zA-Z0-9 _./\-'"])+$/.test(cleanedRow)) {
else if (/^([a-zA-Z0-9_\.])+(\ )*=(\ )*([a-zA-Z0-9 _./\-'"])+$/.test(cleanedRow)) {
// This is in the format "property_name = value"

@@ -64,3 +66,3 @@ const splitCleanedRow = cleanedRow.split('=').map((element) => element.trim());

outputJSONData,
currentKeyToPushTo: `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? '.' : ''}${propertyName}`,
currentKeyToPushTo: `${currentKeyToPushTo}${currentKeyToPushTo.length > 0 ? seperator : ''}${propertyName}`,
valueToPush: value.at(0) === '"' && value.at(-1) === '"'

@@ -67,0 +69,0 @@ ? value.slice(1, -1)

@@ -0,5 +1,6 @@

import { seperator } from "./parse-eu4-text-file-to-json.js";
import { valueOrNestedValueIsNestedValue, valueOrNestedValueIsNestedValueArray, valueOrNestedValueIsString, valueOrNestedValueIsStringArray } from "./value-or-nested-value.js";
export const writeValueToOutputJSONData = (input) => {
const { valueToPush } = input;
const splitKey = input.currentKeyToPushTo.split('.');
const splitKey = input.currentKeyToPushTo.split(seperator);
if (splitKey.length === 1) {

@@ -6,0 +7,0 @@ const key = splitKey[0];

{
"name": "@sean_kenny/eu4-text-file-to-json-parser-js",
"version": "0.1.6",
"version": "0.1.7",
"description": "A library for reading text files in the format EU4 encodes it's game data in.",

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

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