mattriley / node-pathstruct

Parse and stringify data structures embedded in file paths.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pathstruct

99.18% cov 223 sloc 22 files 4 deps 13 dev deps

Parse and stringify data structures embedded in file paths.


Table of Contents

Install

npm install pathstruct

Example Usage

parse

Parse key-value pairs from a file path:

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:

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

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

Can't see the diagram? View it on GitHub

graph TD;
    api-->parser;
    api-->stringifier;

This diagram was generated with Module Composer


About

Parse and stringify data structures embedded in file paths.


Languages

Language:JavaScript 99.0%Language:Shell 1.0%