1.0.2 • Published 4 years ago

loopsailor-sort v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

loopsailor-sort

Build Status License npm Coverage Status

Installation

You can download loopsailor-sort from NPM

$ npm install loopsailor-sort --save

then in your project require loopsailor-sort

const sortAddress = require('loopsailor-sort');

or GitHub

$ git clone https://github.com/leonardofurnielis/loopsailor-sort.git

Guide

const sortAddress = require('loopsailor-sort');

// The addresses to be sorted
const addresses = ['/foo/bar', 'GET /foo', '/foo/bar/baz', 'foo'];

sortAddress(addresses);
// ⇨ ['GET /foo', 'foo', '/foo/bar', '/foo/bar/baz'];

Definition of a "route address"

This algorithm, a route address is a string containing:

  • An optional HTTP verb prefix, followed by a space, followed by:
  • 1 or more path components, where each path component is:
    • A forward slash /, followed by:
    • A colon : followed by any combination of letters and numbers (a "param"), OR
    • A star * (a "wildcard"), OR
    • Any combination of letters and numbers authenticate
1.0.2

5 years ago

1.0.1

5 years ago