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

ck2parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ck2parser - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0

53

lib/index.js

@@ -1,7 +0,22 @@

var fs = require('q-io/fs');
var moment = require('moment');
'use strict';
var fs = require('q-io/fs'),
moment = require('moment'),
R = require('ramda');
module.exports = function (file) {
var extractChars = /(?:\t\bcharacter=\n\t\{\n)([\S\s]+?\n\t\})/gm;
var extractIndividualChars = /(?:\t{2}\d+?=[^]+?)(?=\n\t{2}\})/gm;
var getCharBlock = R.compose(R.head, R.match(/(?:\t\bcharacter=\n\t\{\n)([\S\s]+?\n\t\})/gm));
// Get individual chars from a char block;
var getIndividualChars = R.match(/(?:\t{2}\d+?=[^]+?)(?=\n\t{2}\})/gm);
var getLivingChars = R.forEach(function (char) {
if (!char.match(/\bdeath_date/gm)) return char;
});
var getChars = R.compose(getLivingChars,
getIndividualChars,
getCharBlock);
var extractCurrentDate = /(\n\tdate=")(.+)(?=")/g;

@@ -17,13 +32,8 @@

.then(function (data) {
var currentDate = moment(new Date(extractCurrentDate.exec(data)[2])); // Get current date and pass it to moment.js
var chars = data.match(extractChars)[0];
var charsArray = chars.match(extractIndividualChars);
var livingChars = [];
// Get current date and pass it to moment.js
var currentDate = moment(new Date(extractCurrentDate.exec(data)[2])),
chars = getChars(data);
charsArray.map(function (char) {
var charAlive = !char.match(/\bdeath_date/gm);
if (charAlive) livingChars.push(char);
});
livingChars = livingChars.map(function (char) {
return chars.map(function (char) {
char = char

@@ -41,16 +51,7 @@ .replace(/=/g, ': ') // Replace = with :

.map(function (line) { // Convert arrarys to objects
var value = line.split(': ');
var keyValue = {};
return line.split(': ');
});
keyValue[value[0]] = value[1];
char = R.fromPairs(char);
return keyValue;
})
.reduce(function (obj, key) { // Convert Objects to single object
var k = Object.keys(key)[0];
obj[k] = key[k];
return obj;
});
splitString(char, 'attributes');

@@ -62,4 +63,2 @@ splitString(char, 'traits');

});
return livingChars;
})

@@ -66,0 +65,0 @@ .catch(function (error) {

{
"name": "ck2parser",
"version": "0.0.6",
"version": "0.1.0",
"description": "Crusader Kings 2 Savegame Parser. Extracts all characters from a savefile and outputs it as json",

@@ -30,3 +30,4 @@ "author": "Chris Kjær Sørensen",

"moment": "^2.8.1",
"q-io": "^1.11.3"
"q-io": "^1.11.3",
"ramda": "^0.4.3"
},

@@ -33,0 +34,0 @@ "devDependencies": {

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