diff --git a/lib/node_modules/@stdlib/repl/lib/drain.js b/lib/node_modules/@stdlib/repl/lib/drain.js index 48553b1ac0d3..0336f883d10f 100644 --- a/lib/node_modules/@stdlib/repl/lib/drain.js +++ b/lib/node_modules/@stdlib/repl/lib/drain.js @@ -30,6 +30,9 @@ var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); +var isInt64 = require( '@stdlib/assert/is-int64' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isComplex = require( '@stdlib/assert/is-complex' ); var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); var join = require( '@stdlib/array/base/join' ); var constructorName = require( '@stdlib/utils/constructor-name' ); @@ -118,6 +121,46 @@ function array2string( ctor, values ) { return format( '%s(%d) [%s]', ctor, values.length, str ); } +/** +* Converts an integer instance to an annotated string. +* +* @private +* @param {(Uint64|Int64)} value - input value +* @returns {string} output string +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var x = new Uint64( 1 ); +* // returns +* +* var str = integer2string( x ); +* // returns '[Uint64: 1n]' +*/ +function integer2string( value ) { + return format( '[%s: %sn]', constructorName( value ), value.toString() ); +} + +/** +* Converts a complex number instance to an annotated string. +* +* @private +* @param {(Complex64|Complex128)} value - input value +* @returns {string} output string +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 1.0, 2.0 ); +* // returns +* +* var str = complex2string( z ); +* // returns '[Complex128: 1 + 2i]' +*/ +function complex2string( value ) { + return format( '[%s: %s]', constructorName( value ), value.toString() ); +} + // MAIN // @@ -221,6 +264,12 @@ function drain( repl ) { ) { // FIXME: this is a hack in order to avoid things like `BooleanArray {}` which doesn't allow easy inspection of array contents. Ideally, we'd roll our own inspector to accommodate stdlib's specialized array classes. tmp = array2string( constructorName( res ), copy2primitives( res ) ); // eslint-disable-line max-len + } else if ( isInt64( res ) || isUint64( res ) ) { + // FIXME: this is a hack in order to avoid things like `Uint64 {}` which doesn't allow easy inspection of contents. Ideally, we'd roll our own inspector to accommodate stdlib's specialized scalar classes. + tmp = integer2string( res ); + } else if ( isComplex( res ) ) { + // FIXME: this is a hack in order to avoid things like `Complex128 {}` which doesn't allow easy inspection of contents. Ideally, we'd roll our own inspector to accommodate stdlib's specialized scalar classes. + tmp = complex2string( res ); } else { tmp = inspect( repl._ans ); }