Commit Graph

15 Commits

Author SHA1 Message Date
Marc-Andre Lafortune
0be15bdf3f EJSON: Provide default implementation of clone for custom types 2014-02-12 15:26:50 -08:00
Marc-Andre Lafortune
f8886744a1 EJSON: Fix asymmetry in equals 2014-02-12 15:26:50 -08:00
Marc-Andre Lafortune
18ea49a8c2 EJSON: Add tests for custom types 2014-02-12 15:26:50 -08:00
Naomi Seyfer
c3fb7741f6 Infinity and NaN in EJSON 2013-10-02 12:01:24 -07:00
Naomi Seyfer
0d8bfbae8a fix tests, rename option, more style fixes 2013-10-02 12:01:21 -07:00
Andrew Wilcox
da6bc1d835 EJSON.stringify objects in sorted key order.
Thus if two objects are EJSON.equals, their serialization strings will
be equal also.

(This should mean that reactive-dict could now allow objects to be
used as the key for `equal`).

Note this change does not affect livedata because livedata uses the
EJSON adjust functions to convert between JSON and EJSON (not
stringify).

Adds a couple options to EJSON.stringify:

* keyOrderSensitive: in parallel with EJSON.equals, outputs objects in
  native key order (the old behavior).

* indent: pretty-prints the output.

The serialization code is based json2, which makes it easy to preserve
the indentation functionality provided by JSON.stringify.  Only enough
code is included to serialize arrays and objects; serializing
primitive values such as strings is delegated to the native
JSON.stringify to reduce code and in case the native implementation is
more efficient.

Include underscore as an explicit dependency in package.js.

Document options to EJSON.equals and EJSON.stringify.
2013-10-02 11:43:44 -07:00
Andrew Wilcox
4714f892f5 Check that the argument to EJSON.parse is a string.
Some Android browser versions of JSON.parse can crash when passed null
(https://code.google.com/p/android/issues/detail?id=11973), so it's
better not to pass on a non-string argument to JSON.parse.

Thanks to @raix for raising the issue in #1401.
2013-09-12 12:13:15 -07:00
David Glasser
1fc2dabf6d Oops, didn't mean to revert test! 2013-05-14 11:44:22 -07:00
David Glasser
4c2e1ef1b6 Fix Opera test failures by reverting unnecessary part of 583508e.
Opera seems to have some consistent but difficult to diagnose bugs related to
using _.map in this context. (As in, minifying the test was difficult because
there seemed to be some odd action at a distance, but a given test failure was
fully reproducible.) This appears to work while still preserving the feature
added in 583508e.

Also fix a missing var (which does not appear to be the original problem).
2013-05-14 11:32:53 -07:00
David Glasser
583508e10d Support EJSON.clone(arguments).
This enables (eg) Meteor.apply('foo', arguments). Fixes #946.
2013-04-15 17:49:12 -07:00
Naomi Seyfer
0da938955c Fix EJSON.equals and EJSON.clone to use better loops; be more correct 2013-03-06 20:04:45 -08:00
Naomi Seyfer
e5a0734fa4 Fix for EJSON equality and falsiness 2013-03-01 08:42:57 -08:00
Naomi Seyfer
bf81b0a1de test for EJSON equality of falsy things 2013-03-01 08:42:57 -08:00
Naomi Seyfer
a866689c6a Escaping in EJSON only goes one level 2013-02-04 16:12:49 -08:00
David Glasser
86e4f9b00f EJSON: fix error in recursive EJSON.equals with keyOrderSensitive. 2013-01-17 15:56:14 -05:00