Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
cycle-route
Advanced tools
A simple router factory that takes a static map of route => label and returns a function that maps a path to a route object.
It was created to be used with cycle-pushstate-driver
but is a generic URL mapper that can be as a helper in any routing engine.
npm install cycle-route
###makeRouter(routes)
Takes as input a map from route definition to route name and returns a router function. cycle-route
uses routington
so it accepts all route definitions that routington
accepts and adds a *
route to define the default route.
{
path: '/', // this is the input path
name: 'home', // this is the value from the routes map
params: {} // this are the matched params
}
Basics:
import makeRouter from 'cycle-route'
const router = makeRouter({
'/': 'home',
'/foo/:bar': 'foo',
'*': 'notfound' // default route
})
router('/')
Cycle.js use case:
import { makePushStateDriver } from 'cycle-pushstate-driver'
import makeRouter from 'cycle-route'
import routes from 'routes'
const router = makeRouter(routes)
function main({ DOM, Path }) {
const Route = Path
.map(router)
const homeRequests = home({ Route })
const fooRequests = foo({ Route })
const barRequests = bar({ Route })
const localLinkClick$ = DOM.select('a').events('click')
.filter(e => e.currentTarget.host === global.location.host)
const navigate$ = DOM.select('a').events('click')
.map(e => e.currentTarget.pathname)
const vtree$ = Rx.Observable.combineLatest(
Route, homeRequests.DOM, fooRequests.DOM, barRequests.DOM,
(route, homePage, fooPage, barPage) => {
const pages = {
'home': homePage,
'foo': fooPage,
'bar': barPage
}
return pages[route.name]
}
)
return {
DOM: vtree$,
Path: navigate$,
PreventDefault: localLinkClick$
};
}
FAQs
A Cycle.js helper for routing
The npm package cycle-route receives a total of 1 weekly downloads. As such, cycle-route popularity was classified as not popular.
We found that cycle-route demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.