X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=build%2Fjs%2Fbase2.js;h=87eb37b6590f1eec35e3e947b9c0ca9db38e10f2;hb=003af8e383be2bf6f60338aa6135332ad33ba990;hp=ee57e5d643861ed6bd85ecfb48042485f57d8df2;hpb=ed1e3f7e0501be92411bb7d9fd6c25ab1e81cc73;p=jquery.git diff --git a/build/js/base2.js b/build/js/base2.js index ee57e5d..87eb37b 100644 --- a/build/js/base2.js +++ b/build/js/base2.js @@ -1,4 +1,4 @@ -// timestamp: Tue, 24 Apr 2007 09:57:15 +// timestamp: Tue, 01 May 2007 19:13:00 /* base2.js - copyright 2007, Dean Edwards http://www.opensource.org/licenses/mit-license @@ -141,6 +141,12 @@ var assertType = function(object, type, message) { } }; +var copy = function(object) { + var fn = new Function; + fn.prototype = object; + return new fn; +}; + var format = function(string) { // replace %n with arguments[n] // e.g. format("%1 %2%3 %2a %1%3", "she", "se", "lls"); @@ -416,12 +422,12 @@ var Enumerable = Module.extend({ }, filter: function(object, test, context) { - return this.reduce(object, new Array2, function(result, value, key) { + return this.reduce(object, function(result, value, key) { if (test.call(context, value, key, object)) { result[result.length] = value; } return result; - }); + }, new Array2); }, invoke: function(object, method) { @@ -448,7 +454,7 @@ var Enumerable = Module.extend({ }); }, - reduce: function(object, result, block, context) { + reduce: function(object, block, result, context) { this.forEach (object, function(value, key) { result = block.call(context, result, value, key, object); }); @@ -475,10 +481,10 @@ var IArray = Module.extend({ combine: function(keys, values) { // combine two arrays to make a hash if (!values) values = keys; - return this.reduce(keys, {}, function(object, key, index) { + return this.reduce(keys, function(object, key, index) { object[key] = values[index]; return object; - }); + }, {}); }, copy: function(array) { @@ -904,20 +910,20 @@ var Namespace = Base.extend({ var namespace = "var base=" + base + ";"; var imports = ("base2,lang," + this.imports).split(","); - _private.imports = Enumerable.reduce(imports, namespace, function(namespace, name) { + _private.imports = Enumerable.reduce(imports, function(namespace, name) { if (base2[name]) namespace += base2[name].namespace; return namespace; - }); + }, namespace); var namespace = format("base2.%1=%1;", this.name); var exports = this.exports.split(","); - _private.exports = Enumerable.reduce(exports, namespace, function(namespace, name) { + _private.exports = Enumerable.reduce(exports, function(namespace, name) { if (name) { this.namespace += format("var %2=%1.%2;", this.name, name); namespace += format("if(!%1.%2)%1.%2=%2;base2.%2=%1.%2;", this.name, name); } return namespace; - }, this); + }, namespace, this); if (this.name != "base2") { base2.namespace += format("var %1=base2.%1;", this.name); @@ -949,7 +955,7 @@ eval(this.exports); var lang = new Namespace(this, { name: "lang", version: base2.version, - exports: "K,assert,assertType,assignID,instanceOf,extend,format,forEach,match,rescape,slice,trim", + exports: "K,assert,assertType,assignID,copy,instanceOf,extend,format,forEach,match,rescape,slice,trim", init: function() { this.extend = extend;