Code Monkey home page Code Monkey logo

node-ck2's Introduction

Hi there ๐Ÿ‘‹

stats
lang

node-ck2's People

Contributors

bluelovers avatar hati- avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

node-ck2's Issues

npm install fails: invalid dependency package "bluelovers/string-width"

$ npm install --save ck2
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "bluelovers/string-width": name can only contain URL-friendly characters

I can't seem to find the package anywhere either, so I have no idea what it does. Perhaps https://www.npmjs.com/package/string-width does the same and can replace it?

I also noticed that every dependencies is set to use any version ("fast-csv": "*"), which would break this package if any dependency have breaking changes. This should be fixed too.

ck2.parse(...): Comments after values causes the next property's name to be errornous

I had to manually download and extracted this repository because of broken dependencies (#1).

Scenario of issue

input.txt: (extracted from Stellaris\common\technology\00_soc_tech.txt, line 3443)

ai_weight = {
	factor = 5 #very rare tech
	modifier = {
		factor = 1.5
		OR = {
			has_ethic = ethic_spiritualist
			has_ethic = ethic_fanatic_spiritualist
		}
	}
	modifier = {
		factor = 1.25
		research_leader = {
			area = society
			has_trait = "leader_trait_expertise_psionics"
		}
	}
}

test.js:

'use strict'
const fs = require('fs')
const ck2 = require('./node-ck2-master/src/parse.js')

var input  = fs.readFileSync('./input.txt', { encoding: 'utf8' })
var data   = ck2.parse(input)

var output = JSON.stringify(data, null, '\t')
fs.writeFileSync('./output.json', output)
node ./test.js

output.json:

{
	"ai_weight": {
		"5": {
			"factor": "1.5",
			"OR": {
				"has_ethic": "ethic_spiritualist",
				"has_ethic#0": "ethic_fanatic_spiritualist"
			}
		},
		"factor": "5",
		"modifier": {
			"factor": "1.25",
			"research_leader": {
				"area": "society",
				"has_trait": "\"leader_trait_expertise_psionics\""
			}
		}
	}
}

As you can see, the first modifier property gets its name replaced by the value of the previous line. The issue only occurs when the comment is present, except when the value is surrounded with double quotation marks (factor = "5").

There's also some other issues with the output, but they're not as worrisome as those are hot-fixable when processing the output. They should still be addressed and fixed though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.