diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/examples/index.js new file mode 100644 index 000000000000..af523fbf38b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/examples/index.js @@ -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. +*/ + +'use strict'; + +var SignalReference = require( '@stdlib/plot/vega/signal/reference' ); +var Compare = require( './../lib' ); + +// Single field comparator: +var compare = new Compare({ + 'field': 'amount', + 'order': 'ascending' +}); +console.log( compare.toJSON() ); + +// Multi-field comparator: +compare = new Compare({ + 'field': [ 'amount', 'date' ], + 'order': [ 'descending', 'ascending' ] +}); +console.log( compare.toJSON() ); + +// Signal reference comparator: +compare = new Compare({ + 'field': new SignalReference( 'sortField' ), + 'order': new SignalReference( 'sortOrder' ) +}); +console.log( compare.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/change_event.js new file mode 100644 index 000000000000..4ae853bb4693 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/change_event.js @@ -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': 'compare', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/defaults.js new file mode 100644 index 000000000000..dac17c37011c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/defaults.js @@ -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. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // Desired sort order for each field: + 'order': [ 'ascending' ] + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/get.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/get.js new file mode 100644 index 000000000000..48371be24021 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/get.js @@ -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'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the data fields to sort. +* +* @private +* @returns {(Array|SignalReference|void)} data fields +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/properties.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/properties.js new file mode 100644 index 000000000000..639ddb612903 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/properties.js @@ -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; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/set.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/set.js new file mode 100644 index 000000000000..730231fa9353 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/field/set.js @@ -0,0 +1,103 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './../defaults.js' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:compare:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the data fields to sort. +* +* @private +* @param {(string|Array|SignalReference)} value - input value +* @throws {TypeError} must be a string, an array of strings, or a SignalReference +* @returns {void} +*/ +function set( value ) { + var nfields; + var order; + var isStr; + var opts; + var i; + + if ( isSignalReference( value ) ) { + if ( this[ prop.private ] !== value ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } + return; + } + isStr = isString( value ); + if ( !isStr && !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string, an array of strings, or a signal reference. Value: `%s`.', prop.name, value ) ); + } + if ( isStr ) { + value = [ value ]; + } else { + value = copy( value ); + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: ["%s"]. New value: ["%s"].', join( this[ prop.private ], '", "' ), join( value, '", "' ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + + // Adjust the order array to match the new number of fields... + nfields = value.length; + order = this._order; + if ( order ) { + if ( order.length < nfields ) { + // Pad with default 'ascending' values... + opts = defaults(); + for ( i = order.length; i < nfields; i++ ) { + order.push( opts.order[ 0 ] ); + } + } else if ( order.length > nfields ) { + // Truncate excess order entries... + order.length = nfields; + } + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/index.js new file mode 100644 index 000000000000..fcf753945c8c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/index.js @@ -0,0 +1,42 @@ +/** +* @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'; + +/** +* Compare constructor. +* +* @module @stdlib/plot/vega/compare/ctor +* +* @example +* var Compare = require( '@stdlib/plot/vega/compare/ctor' ); +* +* var compare = new Compare({ +* 'field': 'amount' +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/main.js new file mode 100644 index 000000000000..220fea5fca7e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/main.js @@ -0,0 +1,263 @@ +/** +* @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-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var isArray = require( '@stdlib/assert/is-array' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); +var defaults = require( './defaults.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getField = require( './field/get.js' ); +var setField = require( './field/set.js' ); + +var getOrder = require( './order/get.js' ); +var setOrder = require( './order/set.js' ); + +var getProperties = require( './properties/get.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:compare:main' ); + + +// MAIN // + +/** +* Compare constructor. +* +* @constructor +* @param {Options} [options] - constructor options +* @param {(string|Array|SignalReference)} options.field - data fields to sort +* @param {(string|Array|SignalReference)} [options.order=['ascending']] - desired sort order for each field +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {Compare} compare instance +* +* @example +* var compare = new Compare({ +* 'field': 'amount' +* }); +* // returns +*/ +function Compare( options ) { + var nfields; + var norders; + var nargs; + var keys; + var opts; + var v; + var k; + var i; + + nargs = arguments.length; + if ( !( this instanceof Compare ) ) { + if ( nargs ) { + return new Compare( options ); + } + return new Compare(); + } + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + if ( !hasProp( options, 'field' ) ) { + throw new TypeError( 'invalid argument. Options argument must contain a field property.' ); + } + EventEmitter.call( this ); + + // Resolve the default configuration: + opts = defaults(); + + // Initialize internal state for the required `field` property: + this._field = []; + + // Set internal properties according to the default configuration... + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + this[ '_'+k ] = opts[ k ]; + } + + if ( isSignalReference( options.field ) ) { + if ( !hasProp( options, 'order' ) || !isSignalReference( options.order ) ) { + throw new TypeError( format( 'invalid argument. `%s` must be a signal reference when `field` is a signal reference.', 'order' ) ); + } + } else if ( isString( options.field ) ) { + if ( hasProp( options, 'order' ) && !isString( options.order ) ) { + throw new TypeError( format( 'invalid argument. `%s` must be a string when `field` is a string.', 'order' ) ); + } + if ( !hasProp( options, 'order' ) ) { + options.order = opts.order[ 0 ]; + } + } else if ( isArray( options.field ) ) { + nfields = options.field.length; + if ( hasProp( options, 'order' ) ) { + norders = options.order.length; + if ( isSignalReference( options.order ) ) { + throw new TypeError( format( 'invalid argument. `%s` must be a string or an array of strings when `field` is an array of strings.', 'order' ) ); + } + if ( isString( options.order ) ) { + options.order = [ options.order ]; + } + if ( isArray( options.order ) && norders !== 0 && norders !== nfields ) { + throw new RangeError( format( 'invalid argument. `%s` array length must equal the number of fields. Number of fields: `%u`. Value: `%s`.', 'order', nfields, options.order ) ); + } + } + if ( !hasProp( options, 'order' ) || norders === 0 ) { + options.order = []; + for ( i = 0; i < nfields; i++ ) { + options.order.push( opts.order[ 0 ] ); + } + } + } + + for ( i = 0; i < properties.length; i++ ) { + k = properties[ i ]; + if ( !hasProp( options, k ) ) { + continue; + } + v = options[ k ]; + try { + this[ k ] = v; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + } + + return this; +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( Compare, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof Compare +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( Compare, 'name', 'Compare' ); + +/** +* Data fields to sort. +* +* @name field +* @memberof Compare.prototype +* @type {(string|Array|SignalReference)} +* +* @example +* var compare = new Compare({ +* 'field': 'amount' +* }); +* +* var v = compare.field; +* // returns [ 'amount' ] +*/ +setReadWriteAccessor( Compare.prototype, 'field', getField, setField ); + +/** +* Desired sort order for each field. +* +* @name order +* @memberof Compare.prototype +* @type {(string|Array|SignalReference)} +* @default [ 'ascending' ] +* +* @example +* var compare = new Compare({ +* 'field': 'amount', +* 'order': 'descending' +* }); +* +* var v = compare.order; +* // returns [ 'descending' ] +*/ +setReadWriteAccessor( Compare.prototype, 'order', getOrder, setOrder ); + +/** +* Compare properties. +* +* @name properties +* @memberof Compare.prototype +* @type {Array} +* +* @example +* var compare = new Compare({ +* 'field': 'amount' +* }); +* +* var v = compare.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( Compare.prototype, 'properties', getProperties ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof Compare.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var compare = new Compare({ +* 'field': 'amount' +* }); +* +* var v = compare.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( Compare.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = Compare; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/get.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/get.js new file mode 100644 index 000000000000..0dd522ed8e9a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/get.js @@ -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'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the desired sort order for each field. +* +* @private +* @returns {(Array|SignalReference|void)} sort order +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/properties.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/properties.js new file mode 100644 index 000000000000..d48ece2b868d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/properties.js @@ -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( 'order' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/set.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/set.js new file mode 100644 index 000000000000..4eba56dfb274 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/order/set.js @@ -0,0 +1,120 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var isCompareOrder = require( '@stdlib/plot/vega/base/assert/is-compare-order' ); +var compareOrders = require( '@stdlib/plot/vega/compare/orders' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './../defaults.js' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:compare:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the desired sort order for each field. +* +* @private +* @param {(string|Array|SignalReference|void)} value - input value +* @throws {TypeError} must be a string, an array of strings, or a SignalReference +* @throws {TypeError} each order value must be a valid order +* @throws {TypeError} when field is a SignalReference, order must also be a SignalReference +* @throws {RangeError} order array length must not exceed field array length +* @returns {void} +*/ +function set( value ) { + var isSigRef; + var nfields; + var isStr; + var opts; + var i; + + isSigRef = isSignalReference( value ); + if ( isSigRef ) { + // When order is a SignalReference, field must also be a SignalReference... + if ( !isSignalReference( this._field ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a signal reference when `field` is a signal reference. Value: `%s`.', prop.name, value ) ); + } + if ( this[ prop.private ] !== value ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } + return; + } + isStr = isString( value ); + if ( !isStr ) { + if ( !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string, an array of strings, or a signal reference. Value: `%s`.', prop.name, value ) ); + } + } + if ( isStr ) { + if ( !isCompareOrder( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( compareOrders(), '", "' ), value ) ); + } + value = [ value ]; + } else { + // Validate each order value... + for ( i = 0; i < value.length; i++ ) { + if ( !isCompareOrder( value[ i ] ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( compareOrders(), '", "' ), value[ i ] ) ); + } + } + value = copy( value ); + } + + // If there are fewer order entries than field entries, pad with default 'ascending' values... + nfields = ( this._field ) ? this._field.length : 0; + if ( value.length > nfields && nfields > 0 ) { + throw new RangeError( format( 'invalid assignment. `%s` array length must not exceed the number of fields. Number of fields: `%u`. Value: `%s`.', prop.name, nfields, value ) ); + } + if ( value.length < nfields ) { + opts = defaults(); + for ( i = value.length; i < nfields; i++ ) { + value.push( opts.order[ 0 ] ); + } + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: ["%s"]. New value: ["%s"].', join( this[ prop.private ], '", "' ), join( value, '", "' ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties.json new file mode 100644 index 000000000000..cb752719b507 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties.json @@ -0,0 +1,4 @@ +[ + "field", + "order" +] diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/lib/properties/get.js @@ -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'; + +// MODULES // + +var properties = require( './../properties.json' ); + + +// MAIN // + +/** +* Returns the list of enumerable properties. +* +* @private +* @returns {Array} properties +*/ +function get() { + return properties.slice(); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/compare/ctor/package.json b/lib/node_modules/@stdlib/plot/vega/compare/ctor/package.json new file mode 100644 index 000000000000..c7e89bdb7810 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/compare/ctor/package.json @@ -0,0 +1,60 @@ +{ + "name": "@stdlib/plot/vega/compare/ctor", + "version": "0.0.0", + "description": "Compare constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "vega", + "compare", + "constructor", + "ctor" + ], + "__stdlib__": {} +}