Skip to content

haroldo-ok/bitsy-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to bitsy-parser 👋

Version Documentation Maintenance License: MIT Twitter: Haroldo0k

A parser for turning Bitsy scripts into JS objects, and vice versa.

Install

npm install

Usage

In order to convert a bitsy script into a JS object, you can use parseWorld():

const {parseWorld} = require('../');
const {readFileSync} = require('fs');

const source = readFileSync('example.bitsy', 'utf8');
const parsedObject = parseWorld(source);
const json = JSON.stringify(parsedObject);

console.log(json);

In order to convert a properly structured JS object back into a bitsy script, you can use serializeWorld() (please, do keep in mind that, as of the current version, this routine is unreliable):

const {serializeWorld} = require('../');
const {readFileSync} = require('fs');

const source = readFileSync('example.json', 'utf8');
const parsedObject = JSON.parse(source);
const bitsyScript = serializeWorld(parsedObject);

console.log(bitsyScript);

If you prefer to have the dialogs/endings parsed as ASTs, you can add the parseScripts options to parseWorld(); please, do keep in mind, though, that, as of the current version, serializeWorld() cannot convert those back into bitsy scripts:

const {parseWorld} = require('../');
const {readFileSync} = require('fs');

const source = readFileSync('example.bitsy', 'utf8');
const parsedObject = parseWorld(source, {parseScripts: true});
const json = JSON.stringify(parsedObject);

console.log(json);

Run tests

npm run test:watch

Author

👤 Haroldo de Oliveira Pinheiro

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2019 Haroldo de Oliveira Pinheiro.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

About

A small JS package for parsing Bitsy projects into JS objects. Work in progress.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%