Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Latest commit

 

History

History
38 lines (28 loc) · 1.08 KB

README.md

File metadata and controls

38 lines (28 loc) · 1.08 KB

Code Climate

Test Coverage

Issue Count

Bushido

Very simple and laconic path helper

Usage

// paths.js
import Bushido, { addResource } from 'bushido';

let bushido = new Bushido();

export default bushido.createPaths([
  addResource('books', [
    addResource('pages', [
      addResource('paragraphs')
    ]),
    addResource('content')
  ]),
  addResource('pages')
]);
import paths from './paths'

paths.pages.path // => '/pages'
paths.pages(4).path // => '/pages/4'

paths.books.pages.paragraphs.path // => '/books/pages/paragraphs'
paths.books(3).pages(5).paragraphs(7).path // => '/books/3/pages/5/paragraphs/7'
paths.books(6).pages.paragraphs.path // => '/books/6/pages/paragraphs'