Permalink
Browse files

v0.2.3

* Updated define to be more performant
* Rewrote Promise#chain
  • Loading branch information...
1 parent f0a65e6 commit fcab02116eb2625f31bbbed5a55af4600d7839bf @doug-martin doug-martin committed Aug 26, 2013
View
@@ -1,4 +1,5 @@
.DS_Store
+atlassian-ide-plugin.xml
node_modules
lib-cov
*.iml
View
@@ -1,3 +1,8 @@
+# 0.2.3
+
+* Updated define to be more performant
+* Rewrote Promise#chain
+
#0.2.1
* Added check for `getgid` when logging on non posix systems
@@ -0,0 +1,37 @@
+function runComb() {
+ var Promise = require("../lib/promise").Promise;
+ var start = new Date();
+ var i = -1,
+ p = new Promise().callback(1);
+
+ while (++i < 100000) {
+ p = p.chain(function () {
+ return i;
+ }, console.log);
+ }
+ return p.chain(function () {
+ console.log("%d MB", (process.memoryUsage().rss / 1024 / 1024));
+ console.log("%d ms", new Date() - start);
+ });
+}
+
+function runQ() {
+ var Q = require("q");
+ var start = new Date();
+ var i = -1,
+ p = Q(1);
+
+ while (++i < 100000) {
+ p = p.then(function () {
+ return i;
+ }, console.log);
+ }
+ p.then(function () {
+ console.log("%d MB", (process.memoryUsage().rss / 1024 / 1024));
+ console.log("%d ms", new Date() - start);
+ });
+}
+
+runComb();
+//runQ();
+
View
@@ -280,6 +280,11 @@
+<h1>0.2.3</h1>
+<ul>
+<li>Updated define to be more performant</li>
+<li>Rewrote Promise#chain</li>
+</ul>
<h1>0.2.1</h1>
<ul>
<li>Added check for <code>getgid</code> when logging on non posix systems</li>
View
@@ -555,6 +555,21 @@
hitch
</a></li>
+ <li><a href="./comb.html#.hitchAll">
+
+ <span class="label label-info">S</span>
+
+
+ <span class="label label-label">F</span>
+
+
+
+ <span class="label label-success">P</span>
+
+
+ hitchAll
+ </a></li>
+
<li><a href="./comb.html#.hitchIgnore">
<span class="label label-info">S</span>
@@ -1149,7 +1164,8 @@
- <table class='table table-bordered table-striped'><tr><td>Property</td><td>Type</td><td>Default Value</td><td>Description</td></tr><tr><td><em>define</em></td><td>property</td><td><code>define</code></td><td><p>Defines a new class to be used</p>
+ <table class='table table-bordered table-striped'><tr><td>Property</td><td>Type</td><td>Default Value</td><td>Description</td></tr><tr><td><em>bindAll</em></td><td>property</td><td><code>hitchAll</code></td><td><p>Binds all methods or a specified array of function to the scope of the object</p>
+</td><tr><tr><td><em>define</em></td><td>property</td><td><code>define</code></td><td><p>Defines a new class to be used</p>
<p>
Class methods
<ul>
@@ -1238,7 +1254,7 @@
var func = scope[method];
if (isFunction(func)) {
scopeArgs = args.concat(scopeArgs);
- return func.apply(scope, scopeArgs);
+ return spreadArgs(func, scopeArgs, scope);
} else {
return func;
}
@@ -1247,7 +1263,7 @@
return function () {
var scopeArgs = Array.prototype.slice.call(arguments), scope = scopeArgs.shift();
scopeArgs = args.concat(scopeArgs);
- return method.apply(scope, scopeArgs);
+ return spreadArgs(method, scopeArgs, scope);
};
}
}
@@ -2340,15 +2356,15 @@
var func = scope[method];
if (isFunction(func)) {
var scopeArgs = args.concat(Array.prototype.slice.call(arguments));
- return func.apply(scope, scopeArgs);
+ return spreadArgs(func, scopeArgs, scope);
} else {
return func;
}
};
} else {
return function () {
var scopeArgs = args.concat(Array.prototype.slice.call(arguments));
- return method.apply(scope, scopeArgs);
+ return spreadArgs(method, scopeArgs, scope);
};
}
}
@@ -2357,6 +2373,98 @@
+ <a name=".hitchAll"></a>
+ <h3>
+ hitchAll
+
+ <span class="label label-info">Static</span>
+
+
+ <span class="label label-label">Function</span>
+
+
+
+ <span class="label label-success">Public</span>
+
+
+ </h3>
+
+<hr/>
+<em>Defined base/functions.js</em>
+
+<p><p>Binds all methods or a specified array of function to the scope of the object</p>
+</p>
+
+ <em>Example</em>
+ <pre class="prettyprint linenums lang-js">
+var f = {
+ a: function(){
+ return &quot;a&quot;;
+ },
+ b: function(){
+ return &quot;b&quot;;
+ }
+}
+
+comb.hitchAll(f, &quot;a&quot;, &quot;b&quot;);
+
+//or
+
+comb.hitchAll(f);
+ </pre>
+
+
+ <em>Arguments</em>
+ <ul>
+
+ <li> <em>scope</em> : <p>the object to bind methods on</p>
+</li>
+
+ <li> <em>funcs</em> <code>...</code> : <p>varargs of methods to bind</p>
+</li>
+
+ </ul>
+
+
+ <em>Returns</em>
+ <ul>
+
+ <li> <code>Object</code> <p>the originally scoped object.</p>
+</li>
+
+ </ul>
+
+
+
+
+ <em>Source</em>
+ <pre class="prettyprint linenums lang-js">
+function (scope){
+ var funcs = Array.prototype.slice.call(arguments, 1);
+ if (!isObject(scope) &amp;&amp; !isFunction(scope)) {
+ throw new TypeError(&quot;scope must be an object&quot;);
+ }
+ if (funcs.length === 1 &amp;&amp; isArray(funcs[0])) {
+ funcs = funcs[0];
+ }
+ if (!funcs.length) {
+ funcs = [];
+ for (var k in scope) {
+ if (scope.hasOwnProperty(k) &amp;&amp; isFunction(scope[k])) {
+ funcs.push(k);
+ }
+ }
+ }
+ for (var i = 0, l = funcs.length; i &amp;lt; l; i++) {
+ scope[funcs[i]] = hitch(scope, scope[funcs[i]]);
+ }
+ return scope;
+}
+ </pre>
+
+
+
+
<a name=".hitchIgnore"></a>
<h3>
hitchIgnore
@@ -2421,14 +2529,14 @@
return function () {
var func = scope[method];
if (isFunction(func)) {
- return func.apply(scope, args);
+ return spreadArgs(func, args, scope);
} else {
return func;
}
};
} else {
return function () {
- return method.apply(scope, args);
+ return spreadArgs(method, args, scope);
};
}
}
@@ -3201,8 +3309,7 @@
<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (obj){
- return !isUndefinedOrNull(obj) &amp;&amp; (isInstanceOf(obj, Promise) || (isFunction(obj.then)
- &amp;&amp; isFunction(obj.addCallback) &amp;&amp; isFunction(obj.addErrback)));
+ return isObject(obj, Promise) &amp;&amp; typeof obj.then === &quot;function&quot;;
}
</pre>
@@ -3912,15 +4019,15 @@
var func = this[method];
if (isFunction(func)) {
var scopeArgs = args.concat(Array.prototype.slice.call(arguments));
- return func.apply(this, scopeArgs);
+ return spreadArgs(func, scopeArgs, this)
} else {
return func;
}
};
} else {
return function () {
var scopeArgs = args.concat(Array.prototype.slice.call(arguments));
- return method.apply(this, scopeArgs);
+ return spreadArgs(method, scopeArgs, this)
};
}
}
@@ -4542,7 +4649,7 @@
}
} else {
p = new PromiseList(args.map(function (a) {
- return exports.isPromiseLike(a) ? a : new Promise().callback(a);
+ return isPromiseLike(a) ? a : new Promise().callback(a);
}), true);
}
if (cb) {
Oops, something went wrong.

0 comments on commit fcab021

Please sign in to comment.