style($function): replace $function with 'function'

This commit is contained in:
Igor Minar 2011-08-05 16:24:12 -07:00
parent 142cffcf64
commit 06835a462a
9 changed files with 18 additions and 19 deletions

View file

@ -64,7 +64,6 @@ var _undefined = undefined,
$console = 'console',
$date = 'date',
$display = 'display',
$function = 'function',
$length = 'length',
$name = 'name',
$noop = 'noop',
@ -420,7 +419,7 @@ function isArray(value) { return value instanceof Array; }
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Function`.
*/
function isFunction(value){ return typeof value == $function;}
function isFunction(value){ return typeof value == 'function';}
/**
@ -819,7 +818,7 @@ function sliceArgs(args, startIndex) {
*/
function bind(self, fn) {
var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];
if (typeof fn == $function && !(fn instanceof RegExp)) {
if (isFunction(fn) && !(fn instanceof RegExp)) {
return curryArgs.length
? function() {
return arguments.length

View file

@ -136,7 +136,7 @@ function toJsonArray(buf, obj, pretty, stack) {
for ( var keyIndex = 0; keyIndex < keys.length; keyIndex++) {
var key = keys[keyIndex];
var value = obj[key];
if (typeof value != $function) {
if (!isFunction(value)) {
if (comma) {
buf.push(",");
if (pretty) buf.push(pretty);

View file

@ -394,7 +394,7 @@ var angularArray = {
}
}
break;
case $function:
case 'function':
predicates.push(expression);
break;
default:

View file

@ -515,7 +515,7 @@ function parser(text, json){
if (instance)
instance = instance[key];
}
if (typeof instance != $function) {
if (!isFunction(instance)) {
throwError("should be a function", token);
}
return instance;
@ -765,7 +765,7 @@ function compileExpr(expr) {
// TODO(misko): Deprecate? Remove!
// I think that compilation should be a service.
function expressionCompile(exp) {
if (typeof exp === $function) return exp;
if (isFunction(exp)) return exp;
var fn = compileCache[exp];
if (!fn) {
fn = compileCache[exp] = parser(exp).statements();

View file

@ -28,7 +28,7 @@ describe('api', function(){
assertEquals("string", angular.Object.typeOf(""));
assertEquals("date", angular.Object.typeOf(new Date()));
assertEquals("element", angular.Object.typeOf(document.body));
assertEquals($function, angular.Object.typeOf(function(){}));
assertEquals('function', angular.Object.typeOf(function(){}));
});
it('should extend object', function(){

View file

@ -111,7 +111,7 @@ describe('browser', function(){
var script = scripts[0];
var url = script.src.split('?cb=');
expect(url[0]).toEqual('http://example.org/path');
expect(typeof fakeWindow[url[1]]).toEqual($function);
expect(typeof fakeWindow[url[1]]).toEqual('function');
fakeWindow[url[1]]('data');
script.onload();
@ -125,8 +125,8 @@ describe('browser', function(){
it('should call callback when script fails to load', function() {
browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
var script = scripts[0];
expect(typeof script.onload).toBe($function);
expect(typeof script.onerror).toBe($function);
expect(typeof script.onload).toBe('function');
expect(typeof script.onerror).toBe('function');
script.onerror();
expect(log).toEqual('undefined:undefined;');

View file

@ -17,12 +17,12 @@ describe("resource", function() {
});
it("should build resource", function(){
expect(typeof CreditCard).toBe($function);
expect(typeof CreditCard.get).toBe($function);
expect(typeof CreditCard.save).toBe($function);
expect(typeof CreditCard.remove).toBe($function);
expect(typeof CreditCard['delete']).toBe($function);
expect(typeof CreditCard.query).toBe($function);
expect(typeof CreditCard).toBe('function');
expect(typeof CreditCard.get).toBe('function');
expect(typeof CreditCard.save).toBe('function');
expect(typeof CreditCard.remove).toBe('function');
expect(typeof CreditCard['delete']).toBe('function');
expect(typeof CreditCard.query).toBe('function');
});
it('should default to empty parameters', function(){

View file

@ -62,7 +62,7 @@ describe('$xhr.bulk', function() {
expect($xhrError).toHaveBeenCalled();
var cb = $xhrError.mostRecentCall.args[0].success;
expect(typeof cb).toEqual($function);
expect(typeof cb).toEqual('function');
expect($xhrError).toHaveBeenCalledWith(
{url: '/req1', method: 'GET', data: null, success: cb},
{status: 404, response: 'NotFound'});

View file

@ -30,7 +30,7 @@ describe('$xhr.error', function() {
$xhr('POST', '/req', 'MyData', callback);
$browserXhr.flush();
var cb = $xhrError.mostRecentCall.args[0].success;
expect(typeof cb).toEqual($function);
expect(typeof cb).toEqual('function');
expect($xhrError).toHaveBeenCalledWith(
{url: '/req', method: 'POST', data: 'MyData', success: cb},
{status: 500, body: 'MyError'});