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,29 @@
/**
* @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( './../lib' );

var signal = new SignalReference( 'width' );
console.log( signal.toJSON() );
// => { 'signal': 'width' }

signal = new SignalReference( 'width / 2' );
console.log( signal.toJSON() );
// => { 'signal': 'width / 2' }
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': 'signal-reference',
'property': property
};
}


// EXPORTS //

module.exports = event;
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/reference/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';

/**
* SignalReference constructor.
*
* @module @stdlib/plot/vega/signal/reference
*
* @example
* var SignalReference = require( '@stdlib/plot/vega/signal/reference' );
*
* var signal = new SignalReference( 'width' );
* // returns <SignalReference>
*/

// MODULES //

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


// EXPORTS //

module.exports = main;
164 changes: 164 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/signal/reference/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/**
* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive;
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 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' );

// Note: keep the following in alphabetical order according to the `require` path...
var getProperties = require( './properties/get.js' );

var getSignal = require( './signal/get.js' );
var setSignal = require( './signal/set.js' );


// VARIABLES //

var debug = logger( 'vega:signal-reference:main' );


// MAIN //

/**
* SignalReference constructor.
*
* @constructor
* @param {string} reference - signal reference string
* @throws {TypeError} must provide a string
* @throws {Error} must provide valid options
* @returns {SignalReference} signal reference instance
*
* @example
* var signal = new SignalReference( 'width' );
* // returns <SignalReference>
*
* @example
* var signal = new SignalReference( 'width / 2' );
* // returns <SignalReference>
*/
function SignalReference( reference ) {
if ( !( this instanceof SignalReference ) ) {
return new SignalReference( reference );
}
EventEmitter.call( this );
if ( !isString( reference ) ) {
throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', reference ) );
}
try {
this.signal = reference;
} catch ( err ) {
debug( 'Encountered an error. Error: %s', err.message );

// FIXME: retain thrown error type

Check warning on line 81 in lib/node_modules/@stdlib/plot/vega/signal/reference/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: retain thrown error type'
throw new Error( transformErrorMessage( err.message ) );
}
return this;
}

/*
* Inherit from the `EventEmitter` prototype.
*/
inherit( SignalReference, EventEmitter );

/**
* Constructor name.
*
* @private
* @name name
* @memberof SignalReference
* @readonly
* @type {string}
*/
setNonEnumerableReadOnly( SignalReference, 'name', 'SignalReference' );

/**
* Signal reference string.
*
* @name signal
* @memberof SignalReference.prototype
* @type {string}
*
* @example
* var signal = new SignalReference( 'width' );
*
* var v = signal.signal;
* // returns 'width'
*
* @example
* var signal = new SignalReference( 'width / 2' );
*
* var v = signal.signal;
* // returns 'width / 2'
*/
setReadWriteAccessor( SignalReference.prototype, 'signal', getSignal, setSignal );

/**
* SignalReference properties.
*
* @name properties
* @memberof SignalReference.prototype
* @type {Array<string>}
*
* @example
* var signal = new SignalReference( 'width' );
*
* var v = signal.properties;
* // returns [...]
*/
setNonEnumerableReadOnlyAccessor( SignalReference.prototype, 'properties', getProperties );

/**
* Serializes an instance to a JSON object.
*
* ## Notes
*
* - This method is implicitly invoked by `JSON.stringify`.
*
* @name toJSON
* @memberof SignalReference.prototype
* @type {Function}
* @returns {Object} JSON object
*
* @example
* var signal = new SignalReference( 'width' );
*
* var v = signal.toJSON();
* // returns { 'signal': 'width' }
*/
setNonEnumerableReadOnly( SignalReference.prototype, 'toJSON', function toJSON() {
return instance2json( this, properties );
});


// EXPORTS //

module.exports = SignalReference;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"signal"
]
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';

// MODULES //

var properties = require( './../properties.json' );


// MAIN //

/**
* Returns the list of enumerable properties.
*
* @private
* @returns {Array<string>} properties
*/
function get() {
return properties.slice();
}


// EXPORTS //

module.exports = get;
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 signal reference.
*
* @private
* @returns {string} signal reference
*/
function get() {
return this[ prop.private ];
}


// EXPORTS //

module.exports = get;
Loading
Loading