lib/conduit.js
function(node) {
         var newNode = function(data, next) {
             var that = {};
             that.getData = function() {
                 return data;
             };
             that.getNext = function() {
                 return next;
             };
             return that;
         };
         var top = node || null;
         var that = {};

         that.__push_internal__ = function(data) {
             return newStack(newNode(data, top));
         };

         that.__peek__ = function() {
             return top && top.getData();
         };

         that.__pop_internal__ = function() {
             return top && newStack(top.getNext());
         };

         that.__forEach__ = function(f) {
             var i = top;
             var s = 0;
             while (i !== null) {
                 f(i.getData(), s);
                 s = s +1;
                 i = i.getNext();
             }
         };
         that.__map__ = function(f) {
             var i = top;
             var result = [];
             while (i !== null) {
                 result.push(f(i.getData()));
                 i = i.getNext();
             }
             return result;
         };

         that.__length__ = function() {
             var count = 0;
             that.__forEach__(function() { count = count + 1;});
             return count;
         };

         return that;
     }
function(node) {
         var newNode = function(data, next) {
             var that = {};
             that.getData = function() {
                 return data;
             };
             that.getNext = function() {
                 return next;
             };
             return that;
         };
         var top = node || null;
         var that = {};

         that.__push_internal__ = function(data) {
             return newStack(newNode(data, top));
         };

         that.__peek__ = function() {
             return top && top.getData();
         };

         that.__pop_internal__ = function() {
             return top && newStack(top.getNext());
         };

         that.__forEach__ = function(f) {
             var i = top;
             var s = 0;
             while (i !== null) {
                 f(i.getData(), s);
                 s = s +1;
                 i = i.getNext();
             }
         };
         that.__map__ = function(f) {
             var i = top;
             var result = [];
             while (i !== null) {
                 result.push(f(i.getData()));
                 i = i.getNext();
             }
             return result;
         };

         that.__length__ = function() {
             var count = 0;
             that.__forEach__(function() { count = count + 1;});
             return count;
         };

         return that;
     }
function ( node ) { var newNode = function ( data , next ) { var that = { } ; that . getData = function ( ) { return data ; } ; that . getNext = function ( ) { return next ; } ; return that ; } ; var top = node || null ; var that = { } ; that . __push_internal__ = function ( data ) { return newStack ( newNode ( data , top ) ) ; } ; that . __peek__ = function ( ) { return top && top . getData ( ) ; } ; that . __pop_internal__ = function ( ) { return top && newStack ( top . getNext ( ) ) ; } ; that . __forEach__ = function ( f ) { var i = top ; var s = 0 ; while ( i !== null ) { f ( i . getData ( ) , s ) ; s = s + 1 ; i = i . getNext ( ) ; } } ; that . __map__ = function ( f ) { var i = top ; var result = [ ] ; while ( i !== null ) { result . push ( f ( i . getData ( ) ) ) ; i = i . getNext ( ) ; } return result ; } ; that . __length__ = function ( ) { var count = 0 ; that . __forEach__ ( function ( ) { count = count + 1 ; } ) ; return count ; } ; return that ; }
An immutable stack as base class.
An immutable stack as base class .