https://github.com/131/sfdisk-parser
https://github.com/131/sfdisk-parser
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/131/sfdisk-parser
- Owner: 131
- License: mit
- Created: 2023-11-17T23:08:04.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-18T21:53:52.000Z (over 2 years ago)
- Last Synced: 2025-04-25T09:07:41.493Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/131/sfdisk-parser/actions/workflows/test.yml)
[](https://coveralls.io/github/131/sfdisk-parser?branch=master)
[](https://www.npmjs.com/package/sfdisk-parser)
[](http://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/eslint-plugin-ivs)
# Motivation
This package provide a simple parser/serializer of sfdisk dumps.
# API
## {metas, parts, toString} new SfdiskParser(sfdisk_dump_body);
## parts[2][name]= "System reserved somthing";
# Example usage
I was in need of the following API
```
const SfdiskParser = require('sfdisk-parser');
const somesfdiskdump_path = 'mysda.sf';
let sfstruct = new SfdiskParser(fs.readFileSync(somesfdiskdump_path, 'utf-8'));
let reserved = parsed.parts.pop(); //shift last part out of 4
parsed.parts.splice(2, 0, reserved); //put it back as 3rd
delete parsed.metas['last-lba']; //allow write on shorter disk
fs.writeFileSync(somesfdiskdump_path + "_reordered", sfstruct.toString());
```
# Credits
* [131](https://github.com/131)