diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/examples/index.js new file mode 100644 index 000000000000..1b864a79bb9e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 FormulaTransform = require( './../lib' ); + +var transform = new FormulaTransform({ + 'expr': 'log(datum.x) / LN10', + 'as': 'logx' +}); + +console.log( transform.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/get.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/get.js new file mode 100644 index 000000000000..5580a6b537a9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/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 output field name for the formula result. +* +* @private +* @returns {string} field name +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/properties.js new file mode 100644 index 000000000000..3f2304dc2f08 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/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( 'as' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/set.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/set.js new file mode 100644 index 000000000000..77e842bb766e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/as/set.js @@ -0,0 +1,61 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:formula-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the output field name for the formula result. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/change_event.js new file mode 100644 index 000000000000..e444f9c667b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/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': 'transform', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/defaults.js new file mode 100644 index 000000000000..132b3adfb142 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/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 { + // Boolean indicating whether the formula is evaluated only when a data object is first observed: + 'initonly': false + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/get.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/get.js new file mode 100644 index 000000000000..7d418d08382d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/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 formula expression string. +* +* @private +* @returns {string} expression string +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/properties.js new file mode 100644 index 000000000000..07fc9fe6515e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/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( 'expr' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/set.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/set.js new file mode 100644 index 000000000000..32f3df2b9d4c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/expr/set.js @@ -0,0 +1,61 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:formula-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the formula expression string. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/index.js new file mode 100644 index 000000000000..438824b04584 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/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'; + +/** +* Formula transform constructor. +* +* @module @stdlib/plot/vega/transform/formula +* +* @example +* var FormulaTransform = require( '@stdlib/plot/vega/transform/formula' ); +* +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/get.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/get.js new file mode 100644 index 000000000000..2cabfe40418e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/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 a boolean indicating whether the formula is evaluated only when a data object is first observed. +* +* @private +* @returns {boolean} boolean indicating whether the formula is init-only +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/properties.js new file mode 100644 index 000000000000..529a652baff2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/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( 'initonly' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/set.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/set.js new file mode 100644 index 000000000000..8e0993bbb409 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/initonly/set.js @@ -0,0 +1,61 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:formula-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean indicating whether the formula is evaluated only when a data object is first observed. +* +* @private +* @param {boolean} value - input value +* @throws {TypeError} must be a boolean +* @returns {void} +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/main.js new file mode 100644 index 000000000000..3cb577b1a331 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/main.js @@ -0,0 +1,249 @@ +/** +* @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, stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +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 objectKeys = require( '@stdlib/utils/keys' ); +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 getAs = require( './as/get.js' ); +var setAs = require( './as/set.js' ); + +var getExpr = require( './expr/get.js' ); +var setExpr = require( './expr/set.js' ); + +var getInitonly = require( './initonly/get.js' ); +var setInitonly = require( './initonly/set.js' ); + +var getProperties = require( './properties/get.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:formula-transform:main' ); + + +// MAIN // + +/** +* Formula transform constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {string} options.expr - formula expression string +* @param {string} options.as - output field name for the formula result +* @param {boolean} [options.initonly=false] - boolean indicating whether the formula is evaluated only when a data object is first observed +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {FormulaTransform} formula transform instance +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* // returns +*/ +function FormulaTransform( options ) { + var opts; + var keys; + var v; + var k; + var i; + if ( !( this instanceof FormulaTransform ) ) { + return new FormulaTransform( options ); + } + EventEmitter.call( this ); + + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + // Check for required properties... + if ( !hasProp( options, 'expr' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify a formula expression.' ); + } + if ( !hasProp( options, 'as' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify an output field name.' ); + } + + // Resolve the default configuration: + opts = defaults(); + + // 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 ]; + } + + // Validate provided options by attempting to assign option values to corresponding fields... + 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( FormulaTransform, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof FormulaTransform +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( FormulaTransform, 'name', 'FormulaTransform' ); + +/** +* Output field name for the formula result. +* +* @name as +* @memberof FormulaTransform.prototype +* @type {string} +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* +* var v = transform.as; +* // returns 'logx' +*/ +setReadWriteAccessor( FormulaTransform.prototype, 'as', getAs, setAs ); + +/** +* Formula expression string. +* +* @name expr +* @memberof FormulaTransform.prototype +* @type {string} +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* +* var v = transform.expr; +* // returns 'log(datum.x) / LN10' +*/ +setReadWriteAccessor( FormulaTransform.prototype, 'expr', getExpr, setExpr ); + +/** +* Boolean indicating whether the formula is evaluated only when a data object is first observed. +* +* @name initonly +* @memberof FormulaTransform.prototype +* @type {boolean} +* @default false +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx', +* 'initonly': true +* }); +* +* var v = transform.initonly; +* // returns true +*/ +setReadWriteAccessor( FormulaTransform.prototype, 'initonly', getInitonly, setInitonly ); + +/** +* Formula transform properties. +* +* @name properties +* @memberof FormulaTransform.prototype +* @type {Array} +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* +* var v = transform.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( FormulaTransform.prototype, 'properties', getProperties ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof FormulaTransform.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var transform = new FormulaTransform({ +* 'expr': 'log(datum.x) / LN10', +* 'as': 'logx' +* }); +* +* var v = transform.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( FormulaTransform.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = FormulaTransform; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/properties.json new file mode 100644 index 000000000000..0100d970f7d6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/properties.json @@ -0,0 +1,5 @@ +[ + "as", + "expr", + "initonly" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/transform/formula/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/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/transform/formula/package.json b/lib/node_modules/@stdlib/plot/vega/transform/formula/package.json new file mode 100644 index 000000000000..e8fd4032e605 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/formula/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/plot/vega/transform/formula", + "version": "0.0.0", + "description": "Formula transform 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", + "transform", + "formula", + "constructor", + "ctor" + ], + "__stdlib__": {} +}