DefinitelyTyped/types/circular-json/circular-json-tests.ts
Alessandro Vergani 09b08e4b7d Fix circular-json declarations to match JSON object (#20755)
* Fix circular-json declarations

* Simplify definitions of circular-json
2017-10-20 09:10:45 -07:00

27 lines
711 B
TypeScript

import CircularJSON = require('circular-json');
const replacer = (key: any, val: any) => {
return val;
};
const replacerArray = ['a', 'x'];
CircularJSON.parse('{"a":"b"}');
CircularJSON.parse('{"a":"b"}', replacer);
// just stringify a value
CircularJSON.stringify({a: 'b'});
// do replacements for part of the object
CircularJSON.stringify({a: 'b'}, replacer);
CircularJSON.stringify({a: 'b'}, replacerArray);
// add whitespace to the output
CircularJSON.stringify({a: 'b'}, replacer, 5);
CircularJSON.stringify({a: 'b'}, replacerArray, 5);
// do not actually set up a re-parseable object
CircularJSON.stringify({a: 'b'}, replacer, 5, true);
CircularJSON.stringify({a: 'b'}, replacerArray, 5, true);