<commit_before>'use strict';

// MODULES //

var getKeys = require( 'object-keys' ).shim();
var copy = require( '@stdlib/utils/copy' );
var typeName = require( './type.js' );


// MAIN //

/**
* Returns a JSON representation of an error object.
*
* @param {(Error|TypeError|SyntaxError|URIError|ReferenceError|RangeError|EvalError)} err - error to serialize
* @throws first argument must be an error object
* @returns {Object} JSON representation
*
* @example
* var err = new Error( 'beep' );
* var json = err2json( err );
* // returns <Object>
*/
function err2json( err ) {
	var keys;
	var out;
	var i;
	if ( !( err instanceof Error ) ) {
		throw new TypeError( 'invalid input argument. Must provide an error object. Value: `' + err + '`.' );
	}
	out = {};<commit_msg>Support cross-realm errors<commit_after>'use strict';

// MODULES //

var getKeys = require( 'object-keys' ).shim();
var copy = require( '@stdlib/utils/copy' );
var isError = require( '@stdlib/utils/is-error' );
var typeName = require( './type.js' );


// MAIN //

/**
* Returns a JSON representation of an error object.
*
* @param {(Error|TypeError|SyntaxError|URIError|ReferenceError|RangeError|EvalError)} err - error to serialize
* @throws first argument must be an error object
* @returns {Object} JSON representation
*
* @example
* var err = new Error( 'beep' );
* var json = err2json( err );
* // returns <Object>
*/
function err2json( err ) {
	var keys;
	var out;
	var i;
	if ( !isError( err ) ) {
		throw new TypeError( 'invalid input argument. Must provide an error object. Value: `' + err + '`.' );
	}
	out = {};
{'fraction_non_alphanumeric': 0.15891959798994976, 'fraction_numerical': 0.002512562814070352, 'mean_word_length': 3.812688821752266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5831473', 'n_tokens_mistral': 523, 'n_tokens_neox': 516, 'n_words': 169}