Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var Value = require( './../lib' );

var value = new Value({
'field': 'price'
});
console.log( value.toJSON() );
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MAIN //

/**
* Returns a new change event object.
*
* @private
* @param {string} property - property name
* @returns {Object} event object
*/
function event( property ) { // eslint-disable-line stdlib/no-redeclare
return {
'type': 'update',
'source': 'value',
'property': property
};
}


// EXPORTS //

module.exports = event;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable no-invalid-this */

'use strict';

// VARIABLES //

var prop = require( './properties.js' );


// MAIN //

/**
* Returns the color value.
*
* @private
* @returns {(Object|void)} color value
*/
function get() {
return this[ prop.private ];
}


// EXPORTS //

module.exports = get;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var property2object = require( '@stdlib/plot/vega/base/property2object' );


// MAIN //

var obj = property2object( 'color' );


// EXPORTS //

module.exports = obj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable no-invalid-this */

'use strict';

// MODULES //

var logger = require( 'debug' );
var isDeepEqual = require( '@stdlib/assert/deep-equal' );
var isObject = require( '@stdlib/assert/is-object' );
var copy = require( '@stdlib/utils/copy' );
var format = require( '@stdlib/string/format' );
var changeEvent = require( './../change_event.js' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'vega:value:set:'+prop.name );


// MAIN //

/**
* Sets the color value.
*
* @private
* @param {Object} value - input value
* @throws {TypeError} must be an object
* @returns {void}
*/
function set( value ) {
// TODO: Perform more robust validation to accurately check ColorValue.

Check warning on line 50 in lib/node_modules/@stdlib/plot/vega/value/base/ctor/lib/color/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: Perform more robust validation to...'
if ( !isObject( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be an object. Value: `%s`.', prop.name, value ) );
}
if ( !isDeepEqual( value, this[ prop.private ] ) ) {
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
this[ prop.private ] = copy( value );
this.emit( 'change', changeEvent( prop.name ) );
}
}


// EXPORTS //

module.exports = set;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable no-invalid-this */

'use strict';

// VARIABLES //

var prop = require( './properties.js' );


// MAIN //

/**
* Returns the data field name or descriptor.
*
* @private
* @returns {(string|Object|void)} field value
*/
function get() {
return this[ prop.private ];
}


// EXPORTS //

module.exports = get;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var property2object = require( '@stdlib/plot/vega/base/property2object' );


// MAIN //

var obj = property2object( 'field' );


// EXPORTS //

module.exports = obj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable no-invalid-this */

'use strict';

// MODULES //

var logger = require( 'debug' );
var isDeepEqual = require( '@stdlib/assert/deep-equal' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var isObject = require( '@stdlib/assert/is-object' );
var copy = require( '@stdlib/utils/copy' );
var format = require( '@stdlib/string/format' );
var changeEvent = require( './../change_event.js' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'vega:value:set:'+prop.name );


// MAIN //

/**
* Sets the data field name or descriptor.
*
* @private
* @param {(string|Object)} value - input value
* @throws {TypeError} must be a string or an object
* @returns {void}
*/
function set( value ) {
// TODO: Perform more robust validation to accurately check FieldValue.

Check warning on line 51 in lib/node_modules/@stdlib/plot/vega/value/base/ctor/lib/field/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: Perform more robust validation to...'
if ( !isString( value ) && !isObject( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be a string or an object. Value: `%s`.', prop.name, value ) );
}
if ( !isDeepEqual( value, this[ prop.private ] ) ) {
value = ( isString( value ) ) ? value : copy( value );
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
Comment thread
Sachinn-64 marked this conversation as resolved.
this[ prop.private ] = value;
this.emit( 'change', changeEvent( prop.name ) );
}
}


// EXPORTS //

module.exports = set;
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/value/base/ctor/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* Value constructor.
*
* @module @stdlib/plot/vega/value/base/ctor
*
* @example
* var Value = require( '@stdlib/plot/vega/value/base/ctor' );
*
* var value = new Value();
* // returns <Value>
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading
Loading