npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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

v0.1.7

Published

A library for reading text files in the format EU4 encodes it's game data in.

Downloads

540

Readme

eu4-text-file-to-json-parser-js

This is a TypeScript library which contains a function which converts the types of text files used for modding the game Europa Universalis 4 to a JSON format for easier use.

Version Downloads/week

Installation and Usage

$ npm install --save-dev @sean_kenny/eu4-text-file-to-json-parser-js
# or
$ yarn add -D @sean_kenny/eu4-text-file-to-json-parser-js

An output can then be generated by calling the parseEu4TextFileToJson function, which is the only function in the library.

const { outputJSONData } = await parseEu4TextFileToJson({
  inputFilePath: '/path/to/your/file/your_file.txt'
})

Some sample inputs and outputs

The following are some examples of data that can be contained in your_file.txt and the JSON they will parse to.

#Cannor
damesneck_sea_area = {
	1293 1276 1275 1274 1269 1270 1272 1271
}

dameshead_sea_area = {
	1268 1928 1253 1266 1257 1267 1252 1926 1255 1258
}

bay_of_wines_sea_area = {
	1278 1297 1292 1471 1472 1291
}
{
  "damesneck_sea_area": [ "1293", "1276", "1275", "1274", "1269", "1270", "1272", "1271" ],
  "dameshead_sea_area": [ "1268", "1928", "1253", "1266", "1257", "1267", "1252", "1926", "1255", "1258" ],
  "bay_of_wines_sea_area": ["1278", "1297", "1292", "1471", "1472", "1291"]
}
# province id = rotation in degrees, 0 is pointing right, then ccw)
# can be reloaded ingame by cmd: reloadtradewinds

1473 = 180
1568 = 200
1565 = 180
1583 = 190

1480 = 170
1484 = 190
1571 = 175

1498 = 250
1585 = 220
1599 = 220
1590 = 250
1589 = 190
{
  "1473": "180",
  "1480": "170",
  "1484": "190",
  "1498": "250",
  "1565": "180",
  "1568": "200",
  "1571": "175",
  "1583": "190",
  "1585": "220",
  "1589": "190",
  "1590": "250",
  "1599": "220"
}
leechdens_region = {
	areas = {
		serpenthome_area
		spider_coast_area
		screaming_jungle_area
		middans_area
		edgewoods_area
		ungoths_trail_area
		red_isle_area
		leechdens_maw_area
	}
	monsoon = {
		00.12.01
		00.12.30
	}
	monsoon = {
		00.01.01
		00.04.30
	}
}
{
  "leechdens_region": {
    "areas": [
      "serpenthome_area",
      "spider_coast_area",
      "screaming_jungle_area",
      "middans_area",
      "edgewoods_area",
      "ungoths_trail_area",
      "red_isle_area",
      "leechdens_maw_area"
    ],
    "monsoon": ["00.12.01", "00.12.30", "00.01.01", "00.04.30"]
  }
}
tree = { 3 4 7 10 }
{
  "tree": ["3", "4", "7", "10"]
}
add_core = I43
culture = green_orc
add_core = I34
{
  "add_core": ["I43", "I34"],
  "culture": "green_orc"
}
is_city = yes
add_permanent_province_modifier = {
	name = harimari_minority_coexisting_small
	duration = -1
}
add_permanent_province_modifier = {
	name = temple_complex
	duration = -1
}
{
  "is_city": "yes",
  "add_permanent_province_modifier": [
    { "name": "harimari_minority_coexisting_small", "duration": "-1" },
    { "name": "temple_complex", "duration": "-1" }
  ]
}

More full examples are available by perusing the /test/sample-inputs and /test/expected-outputs folders in the repository.

Acknowledgements

All sample input files which are used for testing are pulled directly from the ab937cf899b75f74662a17574bd0d46072793beb version of Anbennar which was published to Bitbucket on August 23rd 2024. All credit for those files goes to their creator.

You're welcome to use this library for anything you'd like. I don't think there's a set spec for the files Paradox Interactive uses for their text files so I wouldn't be surprised if there's some files this doesn't parse correctly. Please reach out if you have a file in the EU4 game files or a particular mod which is not processed properly by this library and I'd be happy to work on something to make it work for you.