This file contains hidden or 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
// AMD module wrapper. | |
define(function () { | |
function HttpError (msg, code) { | |
var ex; | |
msg = msg || 'Unknown HTTP error'; | |
ex = new Error(msg); // not all browsers let us inherit, so we do it this way | |
ex.code = code; | |
ex.name = 'HttpError'; // thx @cjno! (http://twitter.com/cjno/status/154959746582056960) |
This file contains hidden or 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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>issue 53</title> | |
<script src="../src/curl.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
curl({ |
This file contains hidden or 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 MethodSpy (method, context) { | |
var count, orig, spy; | |
count = 0; | |
orig = context[method]; | |
context[method] = function () { | |
count++; | |
return orig.apply(context, arguments); | |
}; |
This file contains hidden or 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
/** MIT License (c) copyright B Cavalier & J Hann */ | |
(function (define, globalEval) { | |
define(function () { | |
"use strict"; | |
/** | |
* Creates a function that can be used to evaluate arbitrary expressions | |
* on a data item. | |
* @param options {Object} |
This file contains hidden or 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 test module | |
define(['curl/tdd/createContext', 'require'], function (createContext, require) { | |
// supply a require (optional) if your module ids are relative | |
var context = createContext(require); | |
context.setup(function (require, define /*, complete*/) { | |
// define all of your mocks and stubs | |
define('mock1', function () {}); |
This file contains hidden or 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
define(function () { | |
var undef; | |
/** | |
* This strategy will disable a data item during REST operations. | |
* This strategy only makes sense in a pessimistic network. | |
* We need to integrate promises into the EventHub in order for this | |
* strategy to work. Alternatively, we could have item states of | |
* 'adding', 'removing', 'updating', but that feels brutish. | |
*/ |
This file contains hidden or 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
define({ | |
myFunc: { | |
expr: { | |
body: 'alert(e.target.textContent);', | |
params: ['e'] | |
} | |
}, | |
body: { |
This file contains hidden or 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
define(function (require, exports, module) { | |
return { | |
component: { module: './something' }, | |
$module: module // has absolute id of spec (as well as other future goodies) | |
}; | |
}); |
This file contains hidden or 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 (define) { | |
define(function (require, exports, module) { | |
return 'foo'; | |
}); | |
}( | |
typeof define == 'function' && define.amd | |
? define | |
: function (factory) { factory(require, exports, module); } |