forked from cuthbertLab/jsonpickleJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
49 lines (44 loc) · 1.4 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* jsonpickleJS -- interpretation of python jsonpickle in Javascript
* main.js -- main loader -- this should be the only file that most users care about.
*
* Copyright (c) 2014-15 Michael Scott Cuthbert and cuthbertLab
*/
if (typeof jsonpickle == 'undefined') {
jsonpickle = {}; // global for now...
}
define(['./unpickler', './pickler', './util', './tags', './handlers'],
function(unpickler, pickler, util, tags, handlers) {
jsonpickle.pickler = pickler;
jsonpickle.unpickler = unpickler;
jsonpickle.util = util;
jsonpickle.tags = tags;
jsonpickle.handlers = handlers;
jsonpickle.encode = function (value, unpicklable, make_refs,
keys, max_depth, backend) {
if (unpicklable === undefined) {
unpicklable = true;
}
if (make_refs === undefined) {
make_refs = true;
}
if (keys === undefined) {
keys = false;
}
var options = {
unpicklable: unpicklable,
make_refs: make_refs,
keys: keys,
max_depth: max_depth,
backend: backend,
};
return pickler.encode(value, options);
};
jsonpickle.decode = function (string, backend, keys) {
if (keys === undefined) {
keys = false;
}
return unpickler.decode(string, backend, keys);
};
return jsonpickle;
});