From 5c99ca8054855b1eaf845e3ca5fa084fb0977076 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 5 May 2026 01:53:35 +0530 Subject: [PATCH 1/3] refactor: use isFontStyle,isFontWeight in title setters --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../vega/title/ctor/lib/font-style/set.js | 17 +++++++--------- .../vega/title/ctor/lib/font-weight/set.js | 20 +++++++++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js index 50b65947a854..bed6ad196a85 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js @@ -23,8 +23,9 @@ // MODULES // var logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isUndefined = require( '@stdlib/assert/is-undefined' ); +var isFontStyle = require( '@stdlib/plot/vega/base/assert/is-font-style' ); +var join = require( '@stdlib/array/base/join' ); +var fontStyles = require( '@stdlib/plot/vega/base/font-styles' ); var format = require( '@stdlib/string/format' ); var changeEvent = require( './../change_event.js' ); var prop = require( './properties.js' ); @@ -40,18 +41,14 @@ var debug = logger( 'vega:title:set:'+prop.name ); /** * Sets the font style of the title text. * -* ## Notes -* -* - Providing `undefined` "unsets" the configured value. -* * @private -* @param {(string|void)} value - input value -* @throws {TypeError} must be a string +* @param {string} value - input value +* @throws {TypeError} must be a valid font style * @returns {void} */ function set( value ) { - if ( !isString( value ) && !isUndefined( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) ); + if ( !isFontStyle( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( fontStyles(), '", "' ), value ) ); } if ( value !== this[ prop.private ] ) { debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js index 2d105394e6d8..decfbb82b7a3 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js @@ -23,9 +23,10 @@ // MODULES // var logger = require( 'debug' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var isFontWeight = require( '@stdlib/plot/vega/base/assert/is-font-weight' ); +var join = require( '@stdlib/array/base/join' ); +var fontWeights = require( '@stdlib/plot/vega/base/font-weights' ); var format = require( '@stdlib/string/format' ); var changeEvent = require( './../change_event.js' ); var prop = require( './properties.js' ); @@ -43,16 +44,19 @@ var debug = logger( 'vega:title:set:'+prop.name ); * * ## Notes * -* - Providing `undefined` "unsets" the configured value. +* - If provided a number, the value is converted to a string. * * @private -* @param {(number|string|void)} value - input value -* @throws {TypeError} must be a number or string +* @param {(number|string)} value - input value +* @throws {TypeError} must be a valid font weight * @returns {void} */ function set( value ) { - if ( !isNumber( value ) && !isString( value ) && !isUndefined( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a number or string. Value: `%s`.', prop.name, value ) ); + if ( isNonNegativeInteger( value ) ) { + value = String( value ); + } + if ( !isFontWeight( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( fontWeights(), '", "' ), value ) ); } if ( value !== this[ prop.private ] ) { debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); From 01c02999e3ebc9be396ad67c4489dc8b9faa34f2 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 5 May 2026 11:16:15 +0530 Subject: [PATCH 2/3] refactor: add support of undefined, update tests --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../vega/title/ctor/lib/font-style/set.js | 9 +++-- .../vega/title/ctor/lib/font-weight/set.js | 7 ++-- .../vega/title/ctor/test/test.font_style.js | 26 +++++++------- .../vega/title/ctor/test/test.font_weight.js | 34 ++++++++++--------- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js index bed6ad196a85..65345a6708dc 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-style/set.js @@ -23,6 +23,7 @@ // MODULES // var logger = require( 'debug' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); var isFontStyle = require( '@stdlib/plot/vega/base/assert/is-font-style' ); var join = require( '@stdlib/array/base/join' ); var fontStyles = require( '@stdlib/plot/vega/base/font-styles' ); @@ -41,13 +42,17 @@ var debug = logger( 'vega:title:set:'+prop.name ); /** * Sets the font style of the title text. * +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* * @private -* @param {string} value - input value +* @param {(string|void)} value - input value * @throws {TypeError} must be a valid font style * @returns {void} */ function set( value ) { - if ( !isFontStyle( value ) ) { + if ( !isUndefined( value ) && !isFontStyle( value ) ) { throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( fontStyles(), '", "' ), value ) ); } if ( value !== this[ prop.private ] ) { diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js index decfbb82b7a3..ac841716d904 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/font-weight/set.js @@ -23,6 +23,7 @@ // MODULES // var logger = require( 'debug' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var isFontWeight = require( '@stdlib/plot/vega/base/assert/is-font-weight' ); var join = require( '@stdlib/array/base/join' ); @@ -44,10 +45,10 @@ var debug = logger( 'vega:title:set:'+prop.name ); * * ## Notes * -* - If provided a number, the value is converted to a string. +* - Providing `undefined` "unsets" the configured value. * * @private -* @param {(number|string)} value - input value +* @param {(number|string|void)} value - input value * @throws {TypeError} must be a valid font weight * @returns {void} */ @@ -55,7 +56,7 @@ function set( value ) { if ( isNonNegativeInteger( value ) ) { value = String( value ); } - if ( !isFontWeight( value ) ) { + if ( !isUndefined( value ) && !isFontWeight( value ) ) { throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( fontWeights(), '", "' ), value ) ); } if ( value !== this[ prop.private ] ) { diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js index 937e9cb8bac9..f4c1d50fb9bc 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js @@ -43,7 +43,7 @@ tape( 'the constructor returns an instance which has a `fontStyle` property', fu t.strictEqual( isUndefined( v.fontStyle ), true, 'returns expected value' ); v = new Title({ - 'fontStyle': 'Arial' + 'fontStyle': 'italic' }); t.strictEqual( isString( v.fontStyle ), true, 'returns expected value' ); @@ -55,6 +55,8 @@ tape( 'the constructor returns an instance having a `fontStyle` property which t var i; values = [ + 'Arial', + 'foo', 5, NaN, null, @@ -82,14 +84,14 @@ tape( 'the constructor returns an instance having a `fontStyle` property', funct t.strictEqual( isUndefined( title.fontStyle ), true, 'returns expected value' ); title = new Title({ - 'fontStyle': 'Arial' + 'fontStyle': 'italic' }); - t.strictEqual( title.fontStyle, 'Arial', 'returns expected value' ); + t.strictEqual( title.fontStyle, 'italic', 'returns expected value' ); title = new Title({ - 'fontStyle': 'Sans' + 'fontStyle': 'oblique' }); - t.strictEqual( title.fontStyle, 'Sans', 'returns expected value' ); + t.strictEqual( title.fontStyle, 'oblique', 'returns expected value' ); t.end(); }); @@ -97,11 +99,11 @@ tape( 'the constructor returns an instance having a `fontStyle` property', funct tape( 'the constructor returns an instance having a `fontStyle` property which can be set to a valid value', function test( t ) { var title = new Title(); - title.fontStyle = 'Arial'; - t.strictEqual( title.fontStyle, 'Arial', 'returns expected value' ); + title.fontStyle = 'italic'; + t.strictEqual( title.fontStyle, 'italic', 'returns expected value' ); - title.fontStyle = 'Sans'; - t.strictEqual( title.fontStyle, 'Sans', 'returns expected value' ); + title.fontStyle = 'oblique'; + t.strictEqual( title.fontStyle, 'oblique', 'returns expected value' ); t.end(); }); @@ -115,14 +117,14 @@ tape( 'the constructor returns an instance which emits an event when the `fontSt title.on( 'change', onChange ); - title.fontStyle = 'Sans'; + title.fontStyle = 'italic'; t.strictEqual( count, 1, 'returns expected value' ); - title.fontStyle = 'Arial'; + title.fontStyle = 'oblique'; t.strictEqual( count, 2, 'returns expected value' ); // Setting to the same value should not emit an event: - title.fontStyle = 'Arial'; + title.fontStyle = 'oblique'; t.strictEqual( count, 2, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js index 9ef9cd6a4339..763531d226c5 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js @@ -25,7 +25,6 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isUndefined = require( '@stdlib/assert/is-undefined' ); var hasProp = require( '@stdlib/assert/has-property' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; var Title = require( './../lib' ); @@ -49,9 +48,9 @@ tape( 'the constructor returns an instance which has a `fontWeight` property', f t.strictEqual( isString( v.fontWeight ), true, 'returns expected value' ); v = new Title({ - 'fontWeight': 6 + 'fontWeight': 600 }); - t.strictEqual( isNumber( v.fontWeight ), true, 'returns expected value' ); + t.strictEqual( isString( v.fontWeight ), true, 'returns expected value' ); t.end(); }); @@ -61,6 +60,9 @@ tape( 'the constructor returns an instance having a `fontWeight` property which var i; values = [ + 'foo', + 6, + NaN, null, true, false, @@ -91,19 +93,19 @@ tape( 'the constructor returns an instance having a `fontWeight` property', func t.strictEqual( title.fontWeight, 'bold', 'returns expected value' ); title = new Title({ - 'fontWeight': 'light' + 'fontWeight': 'lighter' }); - t.strictEqual( title.fontWeight, 'light', 'returns expected value' ); + t.strictEqual( title.fontWeight, 'lighter', 'returns expected value' ); title = new Title({ - 'fontWeight': 6 + 'fontWeight': '600' }); - t.strictEqual( title.fontWeight, 6, 'returns expected value' ); + t.strictEqual( title.fontWeight, '600', 'returns expected value' ); title = new Title({ - 'fontWeight': 8 + 'fontWeight': 800 }); - t.strictEqual( title.fontWeight, 8, 'returns expected value' ); + t.strictEqual( title.fontWeight, '800', 'returns expected value' ); t.end(); }); @@ -114,14 +116,14 @@ tape( 'the constructor returns an instance having a `fontWeight` property which title.fontWeight = 'bold'; t.strictEqual( title.fontWeight, 'bold', 'returns expected value' ); - title.fontWeight = 'light'; - t.strictEqual( title.fontWeight, 'light', 'returns expected value' ); + title.fontWeight = 'lighter'; + t.strictEqual( title.fontWeight, 'lighter', 'returns expected value' ); - title.fontWeight = 6; - t.strictEqual( title.fontWeight, 6, 'returns expected value' ); + title.fontWeight = '600'; + t.strictEqual( title.fontWeight, '600', 'returns expected value' ); - title.fontWeight = 8; - t.strictEqual( title.fontWeight, 8, 'returns expected value' ); + title.fontWeight = 800; + t.strictEqual( title.fontWeight, '800', 'returns expected value' ); t.end(); }); @@ -135,7 +137,7 @@ tape( 'the constructor returns an instance which emits an event when the `fontWe title.on( 'change', onChange ); - title.fontWeight = 'light'; + title.fontWeight = 'lighter'; t.strictEqual( count, 1, 'returns expected value' ); title.fontWeight = 'bold'; From bdb46d51545ddd8af6b302e8d86cbc472343e7f1 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Tue, 5 May 2026 11:22:19 +0530 Subject: [PATCH 3/3] fix: test failure --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/plot/vega/title/ctor/test/test.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js index eeaba0114550..11cfcad05fde 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js @@ -380,6 +380,8 @@ tape( 'the constructor throws an error if provided an invalid `fontStyle` option var i; values = [ + 'Arial', + 'foo', 5, NaN, null, @@ -408,6 +410,9 @@ tape( 'the constructor throws an error if provided an invalid `fontWeight` optio var i; values = [ + 'foo', + 6, + NaN, null, true, false, @@ -903,7 +908,7 @@ tape( 'the constructor returns an instance having a `toJSON` method for serializ }, 'font': 'Arial', 'fontSize': 12, - 'fontStyle': 'Arial', + 'fontStyle': 'italic', 'fontWeight': 'bold', 'frame': 'group', 'limit': 100, @@ -942,7 +947,7 @@ tape( 'the constructor returns an instance having a `toJSON` method for serializ }, 'font': 'Arial', 'fontSize': 12, - 'fontStyle': 'Arial', + 'fontStyle': 'italic', 'fontWeight': 'bold', 'frame': 'group', 'limit': 100,