Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-state-router

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-state-router - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

14

index.js

@@ -237,8 +237,7 @@ var StateState = require('./state-state')

stateProviderEmitter.makePath = function makePathAndPrependHash(stateName, parameters) {
try {
return '#' + makePath(stateName, parameters)
} catch (err) {
console.error(err)
}
return '#' + makePath(stateName, parameters)
}
stateProviderEmitter.stateIsActive = function stateIsActive(stateName) {
return current.get().name.indexOf(stateName) === 0
}

@@ -248,2 +247,5 @@ if (renderer.setUpMakePathFunction) {

}
if (renderer.setUpStateIsActiveFunction) {
renderer.setUpStateIsActiveFunction(stateProviderEmitter.stateIsActive)
}

@@ -288,3 +290,3 @@ return stateProviderEmitter

if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') {
resolve(res)
resolve(res)
}

@@ -291,0 +293,0 @@ })

{
"name": "abstract-state-router",
"version": "3.3.0",
"version": "3.4.0",
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -247,1 +247,69 @@ var test = require('tape')

})
test('makePath', function(t) {
var stateRouter = getTestState(t).stateRouter
t.plan(2)
stateRouter.addState({
name: 'parent',
template: '',
route: '/parent',
})
stateRouter.addState({
name: 'parent.child1',
template: '',
route: '/child1',
})
stateRouter.addState({
name: 'parent.child2',
template: '',
route: '/child2',
})
t.equal('#/parent/child1?param=value', stateRouter.makePath('parent.child1', { param: 'value' }))
t.throws(function() {
stateRouter.makePath('parent.doesnotexist')
}, /doesnotexist/)
t.end()
})
test('stateIsActive', function(t) {
var stateRouter = getTestState(t).stateRouter
t.plan(4)
stateRouter.addState({
name: 'parent',
template: '',
route: '/parent',
})
stateRouter.addState({
name: 'parent.child1',
template: '',
route: '/child1'
})
stateRouter.addState({
name: 'parent.child2',
template: '',
route: '/child2',
})
stateRouter.on('stateChangeEnd', function() {
t.ok(stateRouter.stateIsActive('parent'), 'parent is active')
t.ok(stateRouter.stateIsActive('parent.child1'), 'parent.child1 is active')
t.notOk(stateRouter.stateIsActive('parent.child2'), 'parent.child2 is not active')
t.notOk(stateRouter.stateIsActive('not a real state'), 'non-existant state is not active')
t.end()
})
stateRouter.go('parent.child1')
})
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc