Socket
Socket
Sign inDemoInstall

can-route-mock

Package Overview
Dependencies
16
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 1.0.0

57

can-route-mock.md

@@ -1,5 +0,56 @@

@page can-route-mock
@module {RouteMock} can-route-mock
@parent can-routing
@collection can-ecosystem
# can-route-mock
@description Simulate routing without having to change the URL.
a fake url for routing
@type {RouteMock}
The `can-route-mock` package exports a `RouteMock` constructor function that
simulates the same behavior as the [can-route-hash RouteHash] constructor function.
```js
import { RouteMock } from "can";
var routeMock = new RouteMock();
routeMock.value //-> ""
routeMock.value = "#foo/bar";
routeMock.value //-> "foo/bar";
```
As shown above, instances of `RouteMock` support `.value` to get and set values. Also,
instances of `RouteMock` implement the common `ValueObservable` symbols:
- [can-reflect.getValue] - `canReflect.getValue( routeMock )`
- [can-reflect.setValue] - `canReflect.setValue( routeMock, "foo=bar" )`
- [can-reflect/observe.onValue] - `canReflect.onValue( routeMock, handler(newValue, oldValue) )`
- [can-reflect/observe.offValue] - `canReflect.offValue( routeMock, handler )`
@body
## Use
The following sets up a `RouteMock` as [can-route.urlData]. Notice that as the
`routeMock` value changes, so does the `routeData`.
```js
import {route, RouteMock, DefineMap} from "can";
// route.data will update routeMock and be updated by changes in
// routeMock.
var routeMock = route.urlData = new RouteMock();
var routeData = route.data = new DefineMap({},false);
// begin binding
route.start();
// simulate setting the URL
routeMock.value = "foo=bar";
console.log( routeData.foo ) //-> "bar";
```
@codepen

2

package.json
{
"name": "can-route-mock",
"version": "0.1.0",
"version": "1.0.0",
"description": "a fake url for routing",

@@ -5,0 +5,0 @@ "homepage": "http://canjs.com",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc