# python-struct

> Packs/Unpacks/Measures structs according to Python's `struct` format

Latest version **1.1.3** (published 2020-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install python-struct
pnpm add python-struct
yarn add python-struct
bun add python-struct
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-05-20 |
| First published | 2016-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/python-struct) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 28.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Daniel Cohen Gindi |
| Maintainers | danielgindi |
| Keywords | pack, unpack, struct, cstruct, python |

## Links

- npm: https://www.npmjs.com/package/python-struct
- Repository: https://github.com/danielgindi/node-python-struct
- Issues: https://github.com/danielgindi/node-python-struct/issues
- npm.io page: https://npm.io/package/python-struct

## Dependencies (1)

- [long](https://npm.io/package/long.md) ^4.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2020-05-20
- 1.1.2 — 2019-09-29
- 1.1.1 — 2019-09-08
- 1.1.0 — 2019-08-28
- 1.0.8 — 2019-07-11
- 1.0.7 — 2019-07-06
- 1.0.6 — 2017-06-17
- 1.0.5 — 2017-06-16
- 1.0.4 — 2016-07-18
- 1.0.3 — 2016-07-14
- 1.0.2 — 2016-06-28
- 1.0.1 — 2016-06-28
- 1.0.0 — 2016-06-27

## README

# python-struct

[![npm Version](https://badge.fury.io/js/python-struct.png)](https://npmjs.org/package/python-struct)

Packs/Unpacks/Measures structs according to Python's `struct` format

## Installation:

```
npm install --save python-struct
```
  
## Usage example:

```javascript

const struct = require('python-struct');

struct.sizeOf('>iixxQ10sb'); // --> 29

struct.pack('>iixxQ10sb', [1234, 5678, require('long').fromString('12345678901234567890'), 'abcdefg', true]); // --> <Buffer 00 00 04 d2 00 00 16 2e 00 00 ab 54 a9 8c eb 1f 0a d2 61 62 63 64 65 66 67 00 00 00 01>

struct.unpack('>iixxQ10sb', Buffer.from('000004d20000162e0000ab54a98ceb1f0ad26162636465666700000001', 'hex')); // --> [ 1234, 5678, 12345678901234567890, 'abcdefg', 1 ]

```

## Usage in the browser

The `"browser"` entry in `package.json` will automatically redirect to the browser adapter for the package.  
*But* you'll have to `npm i buffer` in your project.

## Notes

When using "native" size & alignment, we do not really have a way to find the native size of alignment of types.  
But it's almost always safe to assume that `node_adapter.js` is compiled for the standard architectures, so `native` behaves like `standard`.

If anyone stumbles across a different case, I'll be happy to review it on that specific instance, and figure out what to do.

## Contributing

If you have anything to contribute, or functionality that you lack - you are more than welcome to participate in this!
If anyone wishes to contribute unit tests - that also would be great :-)

## Me
* Hi! I am Daniel Cohen Gindi. Or in short- Daniel.
* danielgindi@gmail.com is my email address.
* That's all you need to know.

## Help

If you want to buy me a beer, you are very welcome to
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G6CELS3E997ZE)
 Thanks :-)

## License

All the code here is under MIT license. Which means you could do virtually anything with the code.
I will appreciate it very much if you keep an attribution where appropriate.

    The MIT License (MIT)

    Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

---
_Source: https://npm.io/package/python-struct · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
