Skip to content

Commit 30c6108

Browse files
committed
refactor: emit change object and use utilities
--- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c969262 commit 30c6108

File tree

6 files changed

+55
-89
lines changed

6 files changed

+55
-89
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* Returns a new change event object.
25+
*
26+
* @private
27+
* @param {string} property - property name
28+
* @returns {Object} event object
29+
*/
30+
function event( property ) { // eslint-disable-line stdlib/no-redeclare
31+
return {
32+
'type': 'update',
33+
'source': 'autosize',
34+
'instance': 'Autosize',
35+
'property': property
36+
};
37+
}
38+
39+
40+
// EXPORTS //
41+
42+
module.exports = event;

lib/node_modules/@stdlib/plot/vega/autosize/lib/contains/set.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var logger = require( 'debug' );
2626
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2727
var join = require( '@stdlib/array/base/join' );
2828
var format = require( '@stdlib/string/format' );
29+
var changeEvent = require( './../change_event.js' );
2930
var METHODS = require( './methods.json' );
3031

3132

@@ -52,7 +53,7 @@ function set( value ) {
5253
if ( value !== this._contains ) {
5354
debug( 'Current value: %s. New value: %s.', this._contains, value );
5455
this._contains = value;
55-
this.emit( 'change' );
56+
this.emit( 'change', changeEvent( 'contains' ) );
5657
}
5758
}
5859

lib/node_modules/@stdlib/plot/vega/autosize/lib/main.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
/* eslint-disable no-restricted-syntax, no-invalid-this */
20+
1921
'use strict';
2022

2123
// MODULES //
@@ -28,11 +30,11 @@ var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' )
2830
var hasProp = require( '@stdlib/assert/has-property' );
2931
var inherit = require( '@stdlib/utils/inherit' );
3032
var objectKeys = require( '@stdlib/utils/keys' );
31-
var replace = require( '@stdlib/string/base/replace' );
33+
var instance2json = require( '@stdlib/plot/vega/base/to-json' );
34+
var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' );
3235
var format = require( '@stdlib/string/format' );
3336
var properties = require( './properties.json' );
3437
var defaults = require( './defaults.js' );
35-
var toJSON = require( './to_json.js' );
3638

3739
// Note: keep the following in alphabetical order according to the `require` path...
3840
var getContains = require( './contains/get.js' );
@@ -50,21 +52,6 @@ var setType = require( './type/set.js' );
5052
var debug = logger( 'vega:autosize:main' );
5153

5254

53-
// FUNCTIONS //
54-
55-
/**
56-
* Transforms an "assignment" error message to an "option validation" error message.
57-
*
58-
* @private
59-
* @param {string} msg - error message
60-
* @returns {string} transformed message
61-
*/
62-
function transformErrorMessage( msg ) {
63-
var m = replace( msg, /invalid assignment\. `([^ ]+)`/, 'invalid option. `$1` option' );
64-
return replace( m, /\. Value:/, '. Option:' );
65-
}
66-
67-
6855
// MAIN //
6956

7057
/**
@@ -221,7 +208,9 @@ setReadWriteAccessor( Autosize.prototype, 'type', getType, setType );
221208
* var v = autosize.toJSON();
222209
* // returns {...}
223210
*/
224-
setReadOnly( Autosize.prototype, 'toJSON', toJSON );
211+
setReadOnly( Autosize.prototype, 'toJSON', function toJSON() {
212+
return instance2json( this, properties );
213+
});
225214

226215

227216
// EXPORTS //

lib/node_modules/@stdlib/plot/vega/autosize/lib/resize/set.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
var logger = require( 'debug' );
2626
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2727
var format = require( '@stdlib/string/format' );
28+
var changeEvent = require( './../change_event.js' );
2829

2930

3031
// VARIABLES //
@@ -49,7 +50,7 @@ function set( value ) {
4950
if ( value !== this._resize ) {
5051
debug( 'Current value: %s. New value: %s.', this._resize, value );
5152
this._resize = value;
52-
this.emit( 'change' );
53+
this.emit( 'change', changeEvent( 'resize' ) );
5354
}
5455
}
5556

lib/node_modules/@stdlib/plot/vega/autosize/lib/to_json.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

lib/node_modules/@stdlib/plot/vega/autosize/lib/type/set.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var isAutosizeType = require( '@stdlib/plot/vega/base/assert/is-autosize-type' )
2727
var join = require( '@stdlib/array/base/join' );
2828
var autosizeTypes = require( '@stdlib/plot/vega/base/autosize-types' );
2929
var format = require( '@stdlib/string/format' );
30+
var changeEvent = require( './../change_event.js' );
3031

3132

3233
// VARIABLES //
@@ -51,7 +52,7 @@ function set( value ) {
5152
if ( value !== this._type ) {
5253
debug( 'Current value: %s. New value: %s.', this._type, value );
5354
this._type = value;
54-
this.emit( 'change' );
55+
this.emit( 'change', changeEvent( 'type' ) );
5556
}
5657
}
5758

0 commit comments

Comments
 (0)