Update stack.js

allow penultimate to take fn argument which returns "previous" Stack.