This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* e4x-dom.js | |
* Version 1.0.2 | |
* | |
* e4x-dom.js makes it easy to interact with the DOM with E4X XML objects. | |
* | |
* 2009-11-18 | |
* | |
* By Elijah Grey, http://eligrey.com | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e4x-dom.js usage examples | |
"use strict"; | |
var img = <img | |
src={prompt("Enter an image URI")} | |
longdesc={prompt("Describe the image")} | |
id="foobar" | |
/>; | |
img.@alt = img.@longdesc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* DontEnum.js | |
* 2009-10-11 | |
* | |
* By Elijah Grey, http://eligrey.com | |
* | |
* DontEnum.js allows you to set properties as non-enumerable. | |
* To set a property as non-enumerable, set someObject.DontEnum$property to true. | |
* Requires JavaScript 1.7 or higher. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Array.prototype.item = function (i) { | |
return this[(i < 0 ? this.length + i : i) >>> 0]; | |
}; | |
// example: [1,2,3,4,5].item(-2) === 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upperFirstChar({$self, 0: firstChar}) | |
firstChar.toUpperCase() + $self.substr(1); // no need to use arguments[0] | |
upperFirstChar("foobar") === "Foobar"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// lockTitle() returns a function that is allowed to change the title after it is locked | |
// This only works in browsers that support the DOMTitleChanged event (only Firefox) | |
var lockTitle = function () { | |
lockTitle = undefined; | |
var titleChanging = false, | |
title = document.title; | |
document.addEventListener("DOMTitleChanged", function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Function.prototype.applyCurry = function (thisp, args) { | |
var fn = this, | |
F = function () { | |
return fn.apply( | |
thisp !== null && typeof thisp !== "undefined" ? thisp : this, | |
args.concat(Array.prototype.slice.call(arguments)) | |
); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires ECMAScript 6 | |
"use strict"; | |
XPathResult.prototype[Symbol.iterator] = function* () { | |
let node; | |
switch (this.resultType) { | |
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: | |
case XPathResult.ORDERED_NODE_ITERATOR_TYPE: | |
while (node = this.iterateNext()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ECMAScript 3 | |
"use strict"; | |
if (typeof StopIteration !== "undefined") { | |
StopIteration.name = "StopIteration"; // the only exception class that doesn't have a name | |
StopIteration.message = "End of iteration"; // might as well give it a message too | |
} | |
Function.prototype.suppress = function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a usage example of using function.input to asynchronously get input for | |
// a synchronous function. All parameters of printName can be skipped by passing undefined | |
// in their place. Input will be requested from the user for every parameter skipped. | |
var reqName = { | |
message: "Enter name", | |
defaultValue: "John Doe" | |
}, | |
printName = function (name, lied) { | |
var [first, last] = (name || (yield [String, reqName])).split(" "); |