Socket
Book a DemoInstallSign in
Socket

earls

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

earls

Tiny library to create a url map

0.0.4
latest
Source
npmnpm
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

Earls

Tiny url library

var earls = require('earls')();

earls.map({
  'products': '/products',
  'products_show': '/products/show/:id'
});

earls.url('products_show', { id: 99 } ); //returns '/products/show/99'

Installation

npm install earls

There is also a earl library in npm so make sure you don't forget the s at the end.

Map

Map will just extend the internal url list (object) with the one you pass it.

earls.map({
  'products': '/products',
  'products_show': '/products/show/:id'
});

Note

You can use map multiple times. It will extend the internal list of urls and not overwrite it.

Register

Mostly map will be enough but incase you like fancy mappings you can register your own mapping method. The method just has to return the same structure as the the default mapping.

earls.register('custom', functionMapper);
earl.custom({}); //Use whatever custom mapping your mapper expects.

A custom mapper that uses functions and works well with Coffee-Script can be found on: earls-function-mapper.

Run tests

Tests use mocha and should.

make test

Keywords

url

FAQs

Package last updated on 15 Jun 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.