New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simutrans-dat-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simutrans-dat-parser

Simutrans dat file parser

latest
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Simutrans dat file parser

A dat file parser for Simutrans.

Install

npm i simutrans-dat-parser

Usecase

Parse from dat text

import { Dat } from 'simutrans-dat-parser';

const text = `obj=way
name=example1
waytype=road
---
obj=way
name=example2
waytype=track`;

const dat = new Dat(text);

dat.objs[0].findParam('waytype').value;
// 'road'

Parse from single obj text

import { Obj } from 'simutrans-dat-parser';

const text = `obj=way
name=example1
waytype=road`;

const obj = new Obj(text);

obj.findParam('waytype').value;
// 'road'

Manipulate values

import { Obj } from 'simutrans-dat-parser';

const text = `obj=way
name=example1
waytype=road
image[0][1]=example.3.4,5,6`;

const obj = new Obj(text);

const param = obj.findParam('image');

param.key
// 'image[0][1]'
param.keyVal
// 'image'
param.keyParams
// [0, 1]

param.value
// 'example.3.4,5,6'
param.valueVal
// 'example'
param.valueParams
// ['3','4','5','6']

param.isEmpty
// false
param.isComment
// false
param.isSplit
// false

param.toString()
// 'image[0][1]=example.3.4,5,6';

Modify parameters

import { Obj } from 'simutrans-dat-parser';

const text = `obj=way
name=example1
waytype=road`;

const obj = new Obj(text);

obj.updateOrCreate('copyright', 'example')

Keywords

simutrans

FAQs

Package last updated on 07 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts