0.1.19 ā€¢ Published 2 years ago

parsed-path v0.1.19

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
< šŸ‘‹ >
parsed
path

Use the best bits of ES6 to parse your path without stress šŸ‘‹

 version  Downloads  jsDelivr  minified size  types includes  license  module formats  codecov  style: styled-components

Installation

npm install parsed-path or yarn add parsed-path

Documentation and Examples

See the documentation for more information about parsed-path.

More info about the project can be found here: Tutorial Intro

Quicklinks to some of the most-visited pages: Getting started

Examples and tutorials can be found here: API Reference

What does it look like?

Utilising tagged template literals (a recent addition to JavaScript), parsed-path allows you to write pathname. This two example creates simple pathname. a Root and a File, with some parsed form to it:

import parsed from 'parsed-path';

const Root = parsed`/`;

const Path = Root`home``user``dir`;

You can pass a function to a template literal to adapt it based on its props. When setting the back prop to true, we are moving to its parent dir.

const Back = Path`
  ${(props: any) => props.back && '..'}
`;

Parsed-path tagged pathform to parse your pathname. It also removes the mapping between pathname and pathform ā€“ using path as a low-level parsing construct could not be easier!

const File = Back`ignore.ts``
  name: file;
  ext: ${(props: any) => props.xml && '.tsx'};
`;
<File back /> to equal /home/user/file.ts
<File xml /> to equal /home/user/dir/file.tsx

Parsed-path uses node module for parsing the path rules. For additional information about the supported prefixes visit their docs.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚           dir        ā”‚    base    ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”¬               ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ root ā”‚               ā”‚ name ā”‚ ext ā”‚
parsed`    /``home``user``dir``file``.tsx `
parsed` C:\\``      path``dir``file``.tsx `
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”˜

This is a live editor, so play around with the code to get a feel for what it's like to work with parsed-path!

0.1.19

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.15

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago