Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 3 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.