GithubHelp home page GithubHelp logo

tseijp / parsed-path Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 4.9 MB

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

Home Page: https://tseijp.github.io/parsed-path/

License: MIT License

JavaScript 5.66% TypeScript 94.34%
path nodejs typescript filepath directory reactjs stat file dir filesystem

parsed-path's Introduction

πŸ‘‹parsed-path

< πŸ‘‹ >
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!

parsed-path's People

Contributors

dependabot[bot] avatar mergify[bot] avatar tseijp avatar

Stargazers

 avatar  avatar

Watchers

 avatar

parsed-path's Issues

Fix 4 Style issues in multiple files

CodeFactor found multiple issues:

These overloads can be combined into one signature taking PathSet | [ParsedPath, ...any[]].

This overload and the one on line 26 can be combined into one signature taking Rule | TemplateStringsArray.

This overload and the one on line 24 can be combined into one signature taking URL | TemplateStringsArray.

This overload and the one on line 24 can be combined into one signature taking URL | Rule.

Fix 4 Maintainability issues in multiple files

CodeFactor found multiple issues:

These overloads can be combined into one signature taking PathSet | [ParsedPath, ...any[]].

This overload and the one on line 26 can be combined into one signature taking Rule | TemplateStringsArray.

This overload and the one on line 24 can be combined into one signature taking URL | TemplateStringsArray.

This overload and the one on line 24 can be combined into one signature taking URL | Rule.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.