diff options
| author | Misko Hevery | 2010-08-18 16:23:12 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-08-18 17:26:33 -0700 | 
| commit | 5ddd8d958686c5075b6c58b700f19b4bdea90e1d (patch) | |
| tree | f43da0153fb41244425c00fc728a17028671ce03 /src/JSON.js | |
| parent | 1087270c95f6bbafd3715c9a5eecdafac79c9daa (diff) | |
| download | angular.js-5ddd8d958686c5075b6c58b700f19b4bdea90e1d.tar.bz2 | |
stringify names for better compression, remove dead functions, removed underscore.js compatibility
Diffstat (limited to 'src/JSON.js')
| -rw-r--r-- | src/JSON.js | 28 | 
1 files changed, 14 insertions, 14 deletions
| diff --git a/src/JSON.js b/src/JSON.js index 0311c317..6fb43f0f 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -2,7 +2,7 @@ var array = [].constructor;  function toJson(obj, pretty){    var buf = []; -  toJsonArray(buf, obj, pretty ? "\n  " : null, []); +  toJsonArray(buf, obj, pretty ? "\n  " : _null, []);    return buf.join('');  } @@ -31,21 +31,21 @@ function toJsonArray(buf, obj, pretty, stack){      stack.push(obj);    }    var type = typeof obj; -  if (obj === null) { -    buf.push("null"); -  } else if (type === 'function') { +  if (obj === _null) { +    buf.push($null); +  } else if (type === $function) {      return; -  } else if (type === 'boolean') { +  } else if (type === $boolean) {      buf.push('' + obj); -  } else if (type === 'number') { +  } else if (type === $number) {      if (isNaN(obj)) { -      buf.push('null'); +      buf.push($null);      } else {        buf.push('' + obj);      } -  } else if (type === 'string') { +  } else if (type === $string) {      return buf.push(angular['String']['quoteUnicode'](obj)); -  } else if (type === 'object') { +  } else if (type === $object) {      if (obj instanceof Array) {        buf.push("[");        var len = obj.length; @@ -53,8 +53,8 @@ function toJsonArray(buf, obj, pretty, stack){        for(var i=0; i<len; i++) {          var item = obj[i];          if (sep) buf.push(","); -        if (typeof item == 'function' || typeof item == 'undefined') { -          buf.push("null"); +        if (typeof item == $function || typeof item == $undefined) { +          buf.push($null);          } else {            toJsonArray(buf, item, pretty, stack);          } @@ -70,7 +70,7 @@ function toJsonArray(buf, obj, pretty, stack){        var childPretty = pretty ? pretty + "  " : false;        var keys = [];        for(var k in obj) { -        if (!obj.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === undefined) +        if (!obj.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === _undefined)            continue;          keys.push(k);        } @@ -79,7 +79,7 @@ function toJsonArray(buf, obj, pretty, stack){          var key = keys[keyIndex];          try {            var value = obj[key]; -          if (typeof value != 'function') { +          if (typeof value != $function) {              if (comma) {                buf.push(",");                if (pretty) buf.push(pretty); @@ -95,7 +95,7 @@ function toJsonArray(buf, obj, pretty, stack){        buf.push("}");      }    } -  if (typeof obj == "object") { +  if (typeof obj == $object) {      stack.pop();    }  } | 
