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
/* ***** BEGIN LICENSE BLOCK ***** | |
* Version: MPL 1.1 | |
* | |
* The contents of this file are subject to the Mozilla Public License | |
* Version 1.1 (the "License"); you may not use this file except in | |
* compliance with the License. You may obtain a copy of the License at | |
* http://www.mozilla.org/MPL/ | |
* | |
* Software distributed under the License is distributed on an "AS IS" | |
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
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
var File = { | |
open: function (path, mode) { | |
var fd, queue, enc; | |
enc = 'utf8'; | |
queue = []; | |
// This is called after each step in the queue finishes, when the queue is empty, then we close the file descriptor. | |
function run_next() { | |
if (queue.length > 0) { |
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
include("/utils.js"); | |
// "this" scope is the object, closures work like normal. Basically this is a nowmal "call" use for functions | |
Object.prototype.instance_eval = function (input) { | |
// Convert the function to a string so that we can rebind it | |
if (typeof input === 'function') { | |
return input.call(this); | |
} | |
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
// Add some ruby-like methods to some of the builtins | |
Object.prototype.instance_eval = function (block) { | |
// Convert the function to a string so that we can rebind it | |
if (typeof block === 'function') { | |
block = "(" + block + ").call(this)"; | |
} | |
// Eval using "this" as the "with" scope | |
return eval("with(this) { " + block + "}"); | |
}; |
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
From 55b1a5207aec66e68745bac6675b7ceed618fd21 Mon Sep 17 00:00:00 2001 | |
From: Tim Caswell <[email protected]> | |
Date: Tue, 13 Oct 2009 13:08:53 -0500 | |
Subject: [PATCH] Fix the link to the new Contribute section | |
--- | |
doc/index.html | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/doc/index.html b/doc/index.html |
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
From 57e3be04890597d1757d629c7c2e63a9ae5b3ead Mon Sep 17 00:00:00 2001 | |
From: Tim Caswell <[email protected]> | |
Date: Wed, 28 Oct 2009 11:49:22 -0500 | |
Subject: [PATCH] DRY up the open, write, read, and close methods on the File prototype. | |
--- | |
lib/file.js | 28 ++++++++-------------------- | |
1 files changed, 8 insertions(+), 20 deletions(-) | |
diff --git a/lib/file.js b/lib/file.js |
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
Array.prototype.shuffle = function () { | |
var i, j, tempi, tempj; | |
i = this.length; | |
if ( i === 0 ) { | |
return false; | |
} | |
while ( --i ) { | |
j = Math.floor( Math.random() * ( i + 1 ) ); | |
tempi = this[i]; |
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 Deferred() { | |
this.chain = []; | |
} | |
Deferred.prototype.addBoth = function (cb) { | |
this.chain.push([cb, cb]); | |
return this; | |
} | |
Deferred.prototype.addCallback = function (cb) { | |
this.chain.push([cb, null]); | |
return this; |
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
// Add ruby-like JSON ability to the standard JSON code. | |
(function () { | |
// A recursive function that traverses the raw object looking for special | |
// serialized objects to be de-serialized. Used by `JSON.load` | |
var json_object_load = function (obj) { | |
var key; | |
if (typeof obj.json_class === 'string') { | |
return (eval(obj.json_class)).jsonCreate(obj); | |
} |
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
// Add ruby-like JSON ability to the standard JSON code. | |
(function () { | |
// A recursive function that traverses the raw object looking for special | |
// serialized objects to be de-serialized. Used by `JSON.load` | |
var json_object_load = function (obj) { | |
var key; | |
if (typeof obj.json_class === 'string') { | |
return (eval(obj.json_class)).jsonCreate(obj); | |
} |
OlderNewer