From 50e927c584df24971330adfe1da5e7ce61a4f7a9 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 25 Jul 2026 08:20:16 +0000 Subject: [PATCH] refactor: use `format` to construct errors in `utils/library-manifest` Rewrite the two value-interpolating `TypeError` messages in the main implementation to build their message via `@stdlib/string/format` instead of string concatenation. `format` is the canonical error construction utility across the `utils` namespace: every other value-interpolating throw (~140 sibling packages) uses it, leaving this package as the sole outlier constructing error messages by concatenation. The message text is preserved byte-for-byte (`%s` coerces values identically to concatenation), so no observable behavior or test expectation changes; the package tests assert only the error type. `@stdlib/string/format` has no dependencies and thus introduces no circular dependency, consistent with the existing note in `main.js` regarding avoiding stdlib packages for the hot-path built-ins. Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/utils/library-manifest/lib/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/library-manifest/lib/main.js b/lib/node_modules/@stdlib/utils/library-manifest/lib/main.js index 3dd8ba4b91fb..68909f18606e 100644 --- a/lib/node_modules/@stdlib/utils/library-manifest/lib/main.js +++ b/lib/node_modules/@stdlib/utils/library-manifest/lib/main.js @@ -26,6 +26,7 @@ var logger = require( 'debug' ); var resolve = require( 'resolve' ).sync; var parentPath = require( '@stdlib/fs/resolve-parent-path' ).sync; var convertPath = require( '@stdlib/utils/convert-path' ); +var format = require( '@stdlib/string/format' ); var isObject = require( './is_object.js' ); var unique = require( './unique.js' ); var validate = require( './validate.js' ); @@ -79,7 +80,7 @@ function manifest( fpath, conditions, options ) { var k; if ( typeof fpath !== 'string' ) { - throw new TypeError( 'invalid argument. First argument must be a string. Value: `'+fpath+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', fpath ) ); } opts = defaults(); if ( arguments.length > 2 ) { @@ -107,7 +108,7 @@ function manifest( fpath, conditions, options ) { // Handle input conditions... if ( !isObject( conditions ) ) { - throw new TypeError( 'invalid argument. Second argument must be an object. Value: `' + conditions + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an object. Value: `%s`.', conditions ) ); } debug( 'Provided conditions: %s', JSON.stringify( conditions ) ); coptnames = objectKeys( conf.options );