Skip to content

Commit aca2d21

Browse files
committed
refactor: use property 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 1d341c0 commit aca2d21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+845
-243
lines changed

lib/node_modules/@stdlib/plot/vega/visualization/lib/autosize/get.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
'use strict';
2222

23+
// MODULES //
24+
25+
var prop = require( './properties.js' );
26+
27+
2328
// MAIN //
2429

2530
/**
@@ -29,7 +34,7 @@
2934
* @returns {(Autosize|Signal)} autosize configuration
3035
*/
3136
function get() {
32-
return this._autosize;
37+
return this[ prop.private ];
3338
}
3439

3540

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// MODULES //
22+
23+
var property2object = require( '@stdlib/plot/vega/base/property2object' );
24+
25+
26+
// MAIN //
27+
28+
var obj = property2object( 'autosize' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ var isString = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive;
2828
var isObject = require( '@stdlib/assert/is-object' );
2929
var Autosize = require( '@stdlib/plot/vega/autosize' );
3030
var format = require( '@stdlib/string/format' );
31+
var changeEvent = require( './../change_event.js' );
32+
var prop = require( './properties.js' );
3133

3234

3335
// VARIABLES //
3436

35-
var debug = logger( 'vega:visualization:set:autosize' );
37+
var debug = logger( 'vega:visualization:set:'+prop.name );
3638

3739

3840
// MAIN //
@@ -53,14 +55,14 @@ function set( value ) {
5355
} else if ( isObject( value ) ) {
5456
// TODO: add signal support
5557
} else if ( !isAutosize( value ) ) {
56-
throw new TypeError( format( 'invalid assignment. `%s` must be either a string, an autosize instance, or a signal. Value: `%s`.', 'autosize', value ) );
58+
throw new TypeError( format( 'invalid assignment. `%s` must be either a string, an autosize instance, or a signal. Value: `%s`.', prop.name, value ) );
5759
}
58-
if ( value !== this._autosize ) {
59-
this._removeChangeListener( this._autosize );
60-
debug( 'Current value: %s. New value: %s.', JSON.stringify( this._autosize ), JSON.stringify( value ) );
61-
this._autosize = value;
62-
this.emit( 'change' );
63-
this._addChangeListener( this._autosize );
60+
if ( value !== this[ prop.private ] ) {
61+
this._removeChangeListener( this[ prop.private ] );
62+
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
63+
this[ prop.private ] = value;
64+
this.emit( 'change', changeEvent( prop.name ) );
65+
this._addChangeListener( this[ prop.private ] );
6466
}
6567
}
6668

lib/node_modules/@stdlib/plot/vega/visualization/lib/axes/get.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// MODULES //
2424

2525
var copy = require( '@stdlib/array/base/copy-indexed' );
26+
var prop = require( './properties.js' );
2627

2728

2829
// MAIN //
@@ -34,7 +35,7 @@ var copy = require( '@stdlib/array/base/copy-indexed' );
3435
* @returns {Array<Scale>} axes
3536
*/
3637
function get() {
37-
return copy( this._axes );
38+
return copy( this[ prop.private ] );
3839
}
3940

4041

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// MODULES //
22+
23+
var property2object = require( '@stdlib/plot/vega/base/property2object' );
24+
25+
26+
// MAIN //
27+
28+
var obj = property2object( 'axes' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/visualization/lib/axes/set.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' );
2828
var isAxisArray = require( '@stdlib/plot/vega/base/assert/is-axis-array' );
2929
var copy = require( '@stdlib/array/base/copy' );
3030
var format = require( '@stdlib/string/format' );
31+
var changeEvent = require( './../change_event.js' );
32+
var prop = require( './properties.js' );
3133

3234

3335
// VARIABLES //
3436

35-
var debug = logger( 'vega:visualization:set:axes' );
37+
var debug = logger( 'vega:visualization:set:'+prop.name );
3638

3739

3840
// MAIN //
@@ -47,15 +49,15 @@ var debug = logger( 'vega:visualization:set:axes' );
4749
*/
4850
function set( value ) {
4951
if ( !isAxisArray( value ) && !isEmptyArrayLikeObject( value ) ) {
50-
throw new TypeError( format( 'invalid assignment. `%s` must be an array of axis instances. Value: `%s`.', 'axes', value ) );
52+
throw new TypeError( format( 'invalid assignment. `%s` must be an array of axis instances. Value: `%s`.', prop.name, value ) );
5153
}
5254
value = copy( value );
53-
if ( !hasEqualValues( value, this._axes ) ) {
54-
this._removeChangeListeners( this._axes );
55-
debug( 'Current value: %s. New value: %s.', JSON.stringify( this._axes ), JSON.stringify( value ) );
56-
this._axes = value;
57-
this.emit( 'change' );
58-
this._addChangeListeners( this._axes );
55+
if ( !hasEqualValues( value, this[ prop.private ] ) ) {
56+
this._removeChangeListeners( this[ prop.private ] );
57+
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
58+
this[ prop.private ] = value;
59+
this.emit( 'change', changeEvent( prop.name ) );
60+
this._addChangeListeners( this[ prop.private ] );
5961
}
6062
}
6163

lib/node_modules/@stdlib/plot/vega/visualization/lib/background/get.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@
2020

2121
'use strict';
2222

23+
// MODULES //
24+
25+
var prop = require( './properties.js' );
26+
27+
2328
// MAIN //
2429

2530
/**
2631
* Returns the visualization background color.
2732
*
2833
* @private
29-
* @returns {string} background color
34+
* @returns {string} color
3035
*/
3136
function get() {
32-
return this._background;
37+
return this[ prop.private ];
3338
}
3439

3540

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// MODULES //
22+
23+
var property2object = require( '@stdlib/plot/vega/base/property2object' );
24+
25+
26+
// MAIN //
27+
28+
var obj = property2object( 'background' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/visualization/lib/background/set.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
var logger = require( 'debug' );
2626
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2727
var format = require( '@stdlib/string/format' );
28+
var changeEvent = require( './../change_event.js' );
29+
var prop = require( './properties.js' );
2830

2931

3032
// VARIABLES //
3133

32-
var debug = logger( 'vega:visualization:set:background' );
34+
var debug = logger( 'vega:visualization:set:'+prop.name );
3335

3436

3537
// MAIN //
@@ -44,12 +46,12 @@ var debug = logger( 'vega:visualization:set:background' );
4446
*/
4547
function set( value ) {
4648
if ( !isString( value ) ) {
47-
throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'background', value ) );
49+
throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) );
4850
}
49-
if ( value !== this._background ) {
50-
debug( 'Current value: %s. New value: %s.', this._background, value );
51-
this._background = value;
52-
this.emit( 'change' );
51+
if ( value !== this[ prop.private ] ) {
52+
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
53+
this[ prop.private ] = value;
54+
this.emit( 'change', changeEvent( prop.name ) );
5355
}
5456
}
5557

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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': 'visualization',
34+
'property': property
35+
};
36+
}
37+
38+
39+
// EXPORTS //
40+
41+
module.exports = event;

0 commit comments

Comments
 (0)