lib/index.js
function koifyRouter(Router) {
	// router factory function is the prototype
	let routerPrototype = Router;

	// original router methods
	let routerPrototype_ = {};

	// router duck testing
	let routerMethods = Object.keys(routerPrototype).sort();

	function isRouter(someRouter) {
		let someRouterPrototype = Object.getPrototypeOf(someRouter);
		let someRouterMethods = Object.keys(someRouterPrototype).sort();

		return arrayEqual(someRouterMethods, routerMethods) && (typeof someRouterPrototype === 'function');
	}

	routerPrototype_.use = routerPrototype.use;
	routerPrototype.use = function () {
		let args = slice.call(arguments);

		for (let i = 0; i < args.length; i++) {
			let handler = args[i];

			// don't wrap router instances
			if (isFunction(handler) && !isRouter(handler)) {
				args[i] = ko.ko(handler);
			}
		}

		return routerPrototype_.use.apply(this, args);
	};

	routerPrototype_.param = routerPrototype.param;
	routerPrototype.param = function () {
		let args = slice.call(arguments);

		let handler = args[1];

		if (isFunction(handler)) {
			// additional argument to indicate param handler
			args[1] = ko.ko(handler, true);
		}

		return routerPrototype_.param.apply(this, args);
	};

	// safeguard
	Object.defineProperty(routerPrototype, '$$koified', {
		configurable: true,
		writable: true,
		value: false
	});

	return Router;
}
function koifyRouter(Router) {
	// router factory function is the prototype
	let routerPrototype = Router;

	// original router methods
	let routerPrototype_ = {};

	// router duck testing
	let routerMethods = Object.keys(routerPrototype).sort();

	function isRouter(someRouter) {
		let someRouterPrototype = Object.getPrototypeOf(someRouter);
		let someRouterMethods = Object.keys(someRouterPrototype).sort();

		return arrayEqual(someRouterMethods, routerMethods) && (typeof someRouterPrototype === 'function');
	}

	routerPrototype_.use = routerPrototype.use;
	routerPrototype.use = function () {
		let args = slice.call(arguments);

		for (let i = 0; i < args.length; i++) {
			let handler = args[i];

			// don't wrap router instances
			if (isFunction(handler) && !isRouter(handler)) {
				args[i] = ko.ko(handler);
			}
		}

		return routerPrototype_.use.apply(this, args);
	};

	routerPrototype_.param = routerPrototype.param;
	routerPrototype.param = function () {
		let args = slice.call(arguments);

		let handler = args[1];

		if (isFunction(handler)) {
			// additional argument to indicate param handler
			args[1] = ko.ko(handler, true);
		}

		return routerPrototype_.param.apply(this, args);
	};

	// safeguard
	Object.defineProperty(routerPrototype, '$$koified', {
		configurable: true,
		writable: true,
		value: false
	});

	return Router;
}
function koifyRouter ( Router ) { // router factory function is the prototype
 let routerPrototype = Router ; // original router methods
 let routerPrototype_ = { } ; // router duck testing
 let routerMethods = Object . keys ( routerPrototype ) . sort ( ) ; function isRouter ( someRouter ) { let someRouterPrototype = Object . getPrototypeOf ( someRouter ) ; let someRouterMethods = Object . keys ( someRouterPrototype ) . sort ( ) ; return arrayEqual ( someRouterMethods , routerMethods ) && ( typeof someRouterPrototype === 'function' ) ; } routerPrototype_ . use = routerPrototype . use ; routerPrototype . use = function ( ) { let args = slice . call ( arguments ) ; for ( let i = 0 ; i < args . length ; i ++ ) { let handler = args [ i ] ; // don't wrap router instances
 if ( isFunction ( handler ) && ! isRouter ( handler ) ) { args [ i ] = ko . ko ( handler ) ; } } return routerPrototype_ . use . apply ( this , args ) ; } ; routerPrototype_ . param = routerPrototype . param ; routerPrototype . param = function ( ) { let args = slice . call ( arguments ) ; let handler = args [ 1 ] ; if ( isFunction ( handler ) ) { // additional argument to indicate param handler
 args [ 1 ] = ko . ko ( handler , true ) ; } return routerPrototype_ . param . apply ( this , args ) ; } ; // safeguard
 Object . defineProperty ( routerPrototype , '$$koified' , { configurable : true , writable : true , value : false } ) ; return Router ; }
Patches router methods
Patches router methods