Skip to content

Commit e12300c

Browse files
committed
feat: add initial support for from property
--- 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 5cef2e1 commit e12300c

File tree

5 files changed

+171
-1
lines changed

5 files changed

+171
-1
lines changed

lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/encode/set.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
var logger = require( 'debug' );
2626
var isObject = require( '@stdlib/assert/is-object' );
2727
var isUndefined = require( '@stdlib/assert/is-undefined' );
28+
var copy = require( '@stdlib/utils/copy' );
2829
var format = require( '@stdlib/string/format' );
2930
var changeEvent = require( './../change_event.js' );
3031
var prop = require( './properties.js' );
@@ -54,9 +55,10 @@ function set( value ) {
5455
if ( !isObject( value ) && !isUndefined( value ) ) {
5556
throw new TypeError( format( 'invalid assignment. `%s` must be an object. Value: `%s`.', prop.name, value ) );
5657
}
58+
// TODO: consider deep equality check
5759
if ( value !== this[ prop.private ] ) {
5860
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
59-
this[ prop.private ] = value;
61+
this[ prop.private ] = copy( value );
6062
this.emit( 'change', changeEvent( prop.name ) );
6163
}
6264
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var copy = require( '@stdlib/utils/copy' );
26+
var prop = require( './properties.js' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Returns the mark data source.
33+
*
34+
* @private
35+
* @returns {(Object|void)} mark data source
36+
*/
37+
function get() {
38+
return copy( this[ prop.private ] ); // TODO: can we avoid using `copy` and use a more performant alternative?
39+
}
40+
41+
42+
// EXPORTS //
43+
44+
module.exports = get;
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( 'from' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var logger = require( 'debug' );
26+
var isObject = require( '@stdlib/assert/is-object' );
27+
var isUndefined = require( '@stdlib/assert/is-undefined' );
28+
var copy = require( '@stdlib/utils/copy' );
29+
var format = require( '@stdlib/string/format' );
30+
var changeEvent = require( './../change_event.js' );
31+
var prop = require( './properties.js' );
32+
33+
34+
// VARIABLES //
35+
36+
var debug = logger( 'vega:mark:set:'+prop.name );
37+
38+
39+
// MAIN //
40+
41+
/**
42+
* Sets the mark data source.
43+
*
44+
* ## Notes
45+
*
46+
* - Providing `undefined` "unsets" the configured value.
47+
*
48+
* @private
49+
* @param {string} value - input value
50+
* @throws {TypeError} must be an object
51+
* @returns {void}
52+
*/
53+
function set( value ) {
54+
if ( !isObject( value ) && !isUndefined( value ) ) {
55+
throw new TypeError( format( 'invalid assignment. `%s` must be an object. Value: `%s`.', prop.name, value ) );
56+
}
57+
// TODO: consider deep equality check
58+
if ( value !== this[ prop.private ] ) {
59+
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
60+
this[ prop.private ] = copy( value );
61+
this.emit( 'change', changeEvent( prop.name ) );
62+
}
63+
}
64+
65+
66+
// EXPORTS //
67+
68+
module.exports = set;

lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/main.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ var setARIA = require( './aria/set.js' );
4444
var getEncode = require( './encode/get.js' );
4545
var setEncode = require( './encode/set.js' );
4646

47+
var getFrom = require( './from/get.js' );
48+
var setFrom = require( './from/set.js' );
49+
4750
var getProperties = require( './properties/get.js' );
4851

4952
var getTriggers = require( './triggers/get.js' );
@@ -206,6 +209,26 @@ setReadWriteAccessor( Mark.prototype, 'aria', getARIA, setARIA );
206209
*/
207210
setReadWriteAccessor( Mark.prototype, 'encode', getEncode, setEncode );
208211

212+
/**
213+
* Mark data source.
214+
*
215+
* @name from
216+
* @memberof Mark.prototype
217+
* @type {(Object|void)}
218+
*
219+
* @example
220+
* var mark = new Mark({
221+
* 'type': 'line',
222+
* 'from': {
223+
* 'data': 'foo'
224+
* }
225+
* });
226+
*
227+
* var v = mark.from;
228+
* // returns { 'data': 'foo' }
229+
*/
230+
setReadWriteAccessor( Mark.prototype, 'from', getFrom, setFrom );
231+
209232
/**
210233
* Mark properties.
211234
*

0 commit comments

Comments
 (0)