@parischap/pretty-print
Version:
A functional library to pretty-print and treeify objects
44 lines • 1.31 kB
JavaScript
/**
* Alias for ASContextStyler.Type<PPValue.All> (see @parischap/ansi-style/ContextStyler.ts and
* Value.ts)
*/
import { ASContextStyler } from '@parischap/ansi-styles';
import * as PPValue from './Value.js';
/**
* Constructor of a depth-indexed ValueBasedStyler
*
* @category Constructors
*/
export const makeDepthIndexed = palette => ASContextStyler.fromPalette({
// Use named function so the name gets printed by the toString function
indexFromContext: function valueDepth(value) {
return PPValue.depth(value);
},
palette
});
/**
* Constructor of a type-indexed ValueBasedStyler
*
* @category Constructors
*/
export const makeTypeIndexed = palette => ASContextStyler.fromPalette({
// Use named function so the name gets printed by the toString function
indexFromContext: function valueType(value) {
return value.contentType;
},
palette
});
/**
* Constructor of a key-type-indexed ValueBasedStyler
*
* @category Constructors
*/
export const makeKeyTypeIndexed = palette => ASContextStyler.fromPalette({
// Use named function so the name gets printed by the toString function
indexFromContext: function keyType(value) {
// `1` for symbolic key, `0` for string key
return +value.hasSymbolicKey;
},
palette
});
//# sourceMappingURL=ValueBasedStyler.js.map