Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9f912eb82e
Fetching contributors…

Cannot retrieve contributors at this time

119 lines (87 sloc) 3.416 kb
Buster core 0.2.0 documentation
===============================
:Author: Christian Johansen
:Email: christian@cjohansen.no
A collection of utilities commonly used across Buster.JS projects.
Table of contents
-----------------
* <<buster-core,The buster-core module>>
[[buster-core]]
The buster-core module
----------------------
The buster-core module is stable and can be freely used when extending Buster,
or for any other projects should you wish to do so.
+buster.isNode(object)+
~~~~~~~~~~~~~~~~~~~~~~~
Returns +true+ if the object is a DOM node. The check is made by attempting to
call +appendChild+ on it, passing in an element.
+buster.isElement(object)+
~~~~~~~~~~~~~~~~~~~~~~~~~~
Returns +true+ if the object is a DOM element. The check is made by calling
+isNode+ and asserting that the element's +nodeType+ is 1 (i.e. element).
+buster.bind(object, methodOrString)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Binds a function to an object, such that its +this+ value is fixed regardless of
how it's called. The function works much like +Function.prototype.bind+ - it is
provided here to work in environments that do not support
+Function.prototype.bind+.
[source,javascript]
----
var homer = {
name: "Homer",
burp: function () {
return this.name + " goes buuuuuurp";
}
};
var func = buster.bind(homer, homer.burp);
func(); // "Homer goes buuuuuurp"
var func2 = buster.bind(home, "burp");
func2(); // "Homer goes buuuuuurp"
----
+buster.isArguments(object)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Returns true if the argument is an +arguments+ object. Buster checks this by
making sure the object is array-like, but not actually an array.
[source,javascript]
----
function check() {
buster.isArguments(arguments); // true
}
buster.isArguments([]); // false
----
+buster.keys(object)+
~~~~~~~~~~~~~~~~~~~~~
Cross-browser implementation of
<a
href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys">Object.keys</a>.
From MDC: "returns an array whose elements are strings corresponding to the
enumerable properties found directly upon object. The ordering of the properties
is the same as that given by looping over the properties of the object
manually".
+buster.create(object)+
~~~~~~~~~~~~~~~~~~~~~~~
Cross-browser implementation of
<a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create">Object.create</a>
+buster.create+ only supports creating a new object with the specified
object as its prototype. It does not support property descriptors.
+buster.extend(target, source1, source2, ...)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Extends the target object by copying all the properties of all the sources onto
it. Sources as processed in order. The method also returns the target object.
[source,javascript]
----
var target = { id: 42, num: 0 };
target = buster.create(target,
{ id: 13, name: "One" },
{ name: "Two", prop: "erty" });
//=> { id: 13, num: 0, name: "Two", prop: "erty" }
----
+buster.nextTick(callback)+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Calls the callback on the next tick of the event loop. On Node.js this method
simply delegates to +process.nextTick+. In the browser, +nextTick+ is emulated
by passing the callback to +setTimeout(callback, 0)+
[[license]]
buster-core license
-------------------
include::../LICENSE[]
Jump to Line
Something went wrong with that request. Please try again.