JS设计模式源代码

源代码在线查看: 5.06 - comparing the two techniques.js

软件大小: 80 K
上传用户: BEIJINGHUANYING
关键词: 设计模式 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* DataParser singleton, converts character delimited strings into arrays. */ 				/*   Now using true private methods. */								GiantCorp.DataParser = (function() {				  // Private attributes.				  var whitespaceRegex = /\s+/;				  				  // Private methods.				  function stripWhitespace(str) {				    return str.replace(whitespaceRegex, '');				  }				  function stringSplit(str, delimiter) {				    return str.split(delimiter);				  }				  				  // Everything returned in the object literal is public, but can access the				  // members in the closure created above.				  return { 				    // Public method.				    stringToArray: function(str, delimiter, stripWS) {				      if(stripWS) {				        str = stripWhitespace(str);				      }				      var outputArray = stringSplit(str, delimiter);				      return outputArray;				    }				  };				})(); // Invoke the function and assign the returned object literal to 				     // GiantCorp.DataParser.							

相关资源