Skip to content

Commit 58e419b

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 0a2a5b3 commit 58e419b

File tree

15 files changed

+236
-114
lines changed

15 files changed

+236
-114
lines changed

lib/node_modules/@stdlib/plot/vega/padding/lib/bottom/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 {number} padding
3035
*/
3136
function get() {
32-
return this._bottom;
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( 'bottom' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/padding/lib/bottom/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 isNumber = require( '@stdlib/assert/is-number' ).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:padding:set:bottom' );
34+
var debug = logger( 'vega:padding:set:'+prop.name );
3335

3436

3537
// MAIN //
@@ -44,12 +46,12 @@ var debug = logger( 'vega:padding:set:bottom' );
4446
*/
4547
function set( value ) {
4648
if ( !isNumber( value ) ) {
47-
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'bottom', value ) );
49+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', prop.name, value ) );
4850
}
49-
if ( value !== this._bottom ) {
50-
debug( 'Current value: %s. New value: %s.', this._bottom, value );
51-
this._bottom = 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': 'padding',
34+
'property': property
35+
};
36+
}
37+
38+
39+
// EXPORTS //
40+
41+
module.exports = event;

lib/node_modules/@stdlib/plot/vega/padding/lib/left/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 {number} padding
3035
*/
3136
function get() {
32-
return this._left;
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( 'left' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

lib/node_modules/@stdlib/plot/vega/padding/lib/left/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 isNumber = require( '@stdlib/assert/is-number' ).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:padding:set:left' );
34+
var debug = logger( 'vega:padding:set:'+prop.name );
3335

3436

3537
// MAIN //
@@ -44,12 +46,12 @@ var debug = logger( 'vega:padding:set:left' );
4446
*/
4547
function set( value ) {
4648
if ( !isNumber( value ) ) {
47-
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'left', value ) );
49+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', prop.name, value ) );
4850
}
49-
if ( value !== this._left ) {
50-
debug( 'Current value: %s. New value: %s.', this._left, value );
51-
this._left = 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

lib/node_modules/@stdlib/plot/vega/padding/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 transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' );
34+
var instance2json = require( '@stdlib/plot/vega/base/to-json' );
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 getBottom = require( './bottom/get.js' );
@@ -53,21 +55,6 @@ var setTop = require( './top/set.js' );
5355
var debug = logger( 'vega:padding:main' );
5456

5557

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

7360
/**
@@ -243,7 +230,9 @@ setReadWriteAccessor( Padding.prototype, 'top', getTop, setTop );
243230
* var v = padding.toJSON();
244231
* // returns {...}
245232
*/
246-
setReadOnly( Padding.prototype, 'toJSON', toJSON );
233+
setReadOnly( Padding.prototype, 'toJSON', function toJSON() {
234+
return instance2json( this, properties );
235+
});
247236

248237

249238
// EXPORTS //

lib/node_modules/@stdlib/plot/vega/padding/lib/right/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 {number} padding
3035
*/
3136
function get() {
32-
return this._right;
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( 'right' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

0 commit comments

Comments
 (0)