Skip to content

Commit 206f511

Browse files
committed
refactor: use properties 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 572f199 commit 206f511

File tree

36 files changed

+546
-160
lines changed

36 files changed

+546
-160
lines changed
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': 'scale',
34+
'property': property
35+
};
36+
}
37+
38+
39+
// EXPORTS //
40+
41+
module.exports = event;

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-max/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 {(void|number)} maximum value
3035
*/
3136
function get() {
32-
return this._domainMax;
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( 'domainMax' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-max/set.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ var logger = require( 'debug' );
2626
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2727
var isUndefined = require( '@stdlib/assert/is-undefined' );
2828
var format = require( '@stdlib/string/format' );
29+
var changeEvent = require( './../change_event.js' );
30+
var prop = require( './properties.js' );
2931

3032

3133
// VARIABLES //
3234

33-
var debug = logger( 'vega:scale:set:domainMax' );
35+
var debug = logger( 'vega:scale:set:'+prop.name );
3436

3537

3638
// MAIN //
@@ -49,12 +51,12 @@ var debug = logger( 'vega:scale:set:domainMax' );
4951
*/
5052
function set( value ) {
5153
if ( !isNumber( value ) && !isUndefined( value ) ) {
52-
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'domainMax', value ) );
54+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', prop.name, value ) );
5355
}
54-
if ( value !== this._domainMax ) {
55-
debug( 'Current value: %s. New value: %s.', this._domainMax, value );
56-
this._domainMax = value;
57-
this.emit( 'change' );
56+
if ( value !== this[ prop.private ] ) {
57+
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
58+
this[ prop.private ] = value;
59+
this.emit( 'change', changeEvent( prop.name ) );
5860
}
5961
}
6062

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-mid/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 {(void|number)} mid-point value
3035
*/
3136
function get() {
32-
return this._domainMid;
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( 'domainMid' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-mid/set.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ var logger = require( 'debug' );
2626
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2727
var isUndefined = require( '@stdlib/assert/is-undefined' );
2828
var format = require( '@stdlib/string/format' );
29+
var changeEvent = require( './../change_event.js' );
30+
var prop = require( './properties.js' );
2931

3032

3133
// VARIABLES //
3234

33-
var debug = logger( 'vega:scale:set:domainMid' );
35+
var debug = logger( 'vega:scale:set:'+prop.name );
3436

3537

3638
// MAIN //
@@ -49,12 +51,12 @@ var debug = logger( 'vega:scale:set:domainMid' );
4951
*/
5052
function set( value ) {
5153
if ( !isNumber( value ) && !isUndefined( value ) ) {
52-
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'domainMid', value ) );
54+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', prop.name, value ) );
5355
}
54-
if ( value !== this._domainMid ) {
55-
debug( 'Current value: %s. New value: %s.', this._domainMid, value );
56-
this._domainMid = value;
57-
this.emit( 'change' );
56+
if ( value !== this[ prop.private ] ) {
57+
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
58+
this[ prop.private ] = value;
59+
this.emit( 'change', changeEvent( prop.name ) );
5860
}
5961
}
6062

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-min/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 {(void|number)} minimum value
3035
*/
3136
function get() {
32-
return this._domainMin;
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( 'domainMin' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/scale/lib/domain-min/set.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ var logger = require( 'debug' );
2626
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2727
var isUndefined = require( '@stdlib/assert/is-undefined' );
2828
var format = require( '@stdlib/string/format' );
29+
var changeEvent = require( './../change_event.js' );
30+
var prop = require( './properties.js' );
2931

3032

3133
// VARIABLES //
3234

33-
var debug = logger( 'vega:scale:set:domainMin' );
35+
var debug = logger( 'vega:scale:set:'+prop.name );
3436

3537

3638
// MAIN //
@@ -49,12 +51,12 @@ var debug = logger( 'vega:scale:set:domainMin' );
4951
*/
5052
function set( value ) {
5153
if ( !isNumber( value ) && !isUndefined( value ) ) {
52-
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'domainMin', value ) );
54+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', prop.name, value ) );
5355
}
54-
if ( value !== this._domainMin ) {
55-
debug( 'Current value: %s. New value: %s.', this._domainMin, value );
56-
this._domainMin = value;
57-
this.emit( 'change' );
56+
if ( value !== this[ prop.private ] ) {
57+
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
58+
this[ prop.private ] = value;
59+
this.emit( 'change', changeEvent( prop.name ) );
5860
}
5961
}
6062

0 commit comments

Comments
 (0)