https://github.com/mattriley/node-pathstruct
Parse and stringify data structures embedded in file paths.
https://github.com/mattriley/node-pathstruct
javascript nodejs npm-package parser
Last synced: 5 months ago
JSON representation
Parse and stringify data structures embedded in file paths.
- Host: GitHub
- URL: https://github.com/mattriley/node-pathstruct
- Owner: mattriley
- Created: 2023-06-16T00:11:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T01:07:12.000Z (9 months ago)
- Last Synced: 2024-12-20T06:32:42.459Z (6 months ago)
- Topics: javascript, nodejs, npm-package, parser
- Language: JavaScript
- Homepage:
- Size: 2.07 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-TEMPLATE.md
Awesome Lists containing this project
README
<%- lib.renderOpening() %>
## Install
<%- await lib.renderCode('npm install pathstruct', 'sh', 'https://www.npmjs.com/package/pathstruct') %>
## Example Usage
### parse
Parse key-value pairs from a file path:
```js
const pathstruct = require('pathstruct');
const str = 'event="Birthday party"/IMG1234 caption="Blowing out candles".jpg';
const obj = pathstruct.parse(str);
// { event: 'Birthday party', caption: 'Blowing out candles' }
```Parse key-value pairs including arrays and nested object structures:
```js
const pathstruct = require('pathstruct');
const str = 'val=foobar arr=[foo,bar] x.val=foobar x.arr=[foo,bar]';
const obj = pathstruct.parse(str);
// { val: 'foobar', arr: ['foo', 'bar'], x: { val: 'foobar', arr: ['foo', 'bar']} }
```### stringify
```js
const pathstruct = require('pathstruct');
const obj = { val: 'foobar', arr: ['foo', 'bar'], x: { val: 'foobar', arr: ['foo', 'bar']} };
const str = pathstruct.stringify(obj);
// val=foobar arr=[foo,bar] x.val=foobar x.arr=[foo,bar]
```## Architecture
<%- await lib.renderModuleDiagram() %>