Alter prettyTrie to allow customised rendering of success-values
This commit is contained in:
parent
e806e91baa
commit
4aabe422fe
|
@ -797,16 +797,21 @@ function instantiateProjection(p, obj) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function prettyTrie(m, initialIndent) {
|
function prettyTrie(m, optionsOpt) {
|
||||||
var acc = [];
|
var acc = [];
|
||||||
walk(initialIndent || 0, m);
|
var options = optionsOpt || {};
|
||||||
|
walk(options.initialIndent || 0, m);
|
||||||
return acc.join('');
|
return acc.join('');
|
||||||
|
|
||||||
function walk(i, m) {
|
function walk(i, m) {
|
||||||
if (m instanceof $Success) {
|
if (m instanceof $Success) {
|
||||||
var v = m.value;
|
var v = m.value;
|
||||||
if (Immutable.Set.isSet(v)) { v = v.toArray(); }
|
if ('prettySuccess' in options) {
|
||||||
acc.push(" {" + JSON.stringify(v) + "}");
|
acc.push(" " + options.prettySuccess(v));
|
||||||
|
} else {
|
||||||
|
if (Immutable.Set.isSet(v)) { v = v.toArray(); }
|
||||||
|
acc.push(" {" + JSON.stringify(v) + "}");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue