Skip to content

Commit 2fde416

Browse files
authored
Merge branch 'refactor/plot' into assert-is-rule-mark-encoding-set
2 parents c6632d3 + 67e1a10 commit 2fde416

67 files changed

Lines changed: 4356 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# isTrailMarkEncodingSet
22+
23+
> Test if an input value is a trail mark [encoding set][@stdlib/plot/vega/mark/trail/encoding-set].
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var isTrailMarkEncodingSet = require( '@stdlib/plot/vega/base/assert/is-trail-mark-encoding-set' );
41+
```
42+
43+
#### isTrailMarkEncodingSet( value )
44+
45+
Tests if an input value is a trail mark [encoding set][@stdlib/plot/vega/mark/trail/encoding-set].
46+
47+
```javascript
48+
var Value = require( '@stdlib/plot/vega/value/ctor' );
49+
var TrailEncodingSet = require( '@stdlib/plot/vega/mark/trail/encoding-set' );
50+
51+
var v = new TrailEncodingSet({
52+
'x': new Value({
53+
'field': 'x',
54+
'scale': 'xScale'
55+
})
56+
});
57+
var bool = isTrailMarkEncodingSet( v );
58+
// returns true
59+
60+
bool = isTrailMarkEncodingSet( {} );
61+
// returns false
62+
```
63+
64+
</section>
65+
66+
<!-- /.usage -->
67+
68+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
69+
70+
<section class="notes">
71+
72+
</section>
73+
74+
<!-- /.notes -->
75+
76+
<!-- Package usage examples. -->
77+
78+
<section class="examples">
79+
80+
## Examples
81+
82+
<!-- eslint no-undef: "error" -->
83+
84+
```javascript
85+
var Value = require( '@stdlib/plot/vega/value/ctor' );
86+
var TrailEncodingSet = require( '@stdlib/plot/vega/mark/trail/encoding-set' );
87+
var isTrailMarkEncodingSet = require( '@stdlib/plot/vega/base/assert/is-trail-mark-encoding-set' );
88+
89+
var v = new TrailEncodingSet({
90+
'x': new Value({
91+
'field': 'x',
92+
'scale': 'xScale'
93+
})
94+
});
95+
var bool = isTrailMarkEncodingSet( v );
96+
// returns true
97+
98+
bool = isTrailMarkEncodingSet( {} );
99+
// returns false
100+
101+
bool = isTrailMarkEncodingSet( 'foo' );
102+
// returns false
103+
```
104+
105+
</section>
106+
107+
<!-- /.examples -->
108+
109+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
110+
111+
<section class="references">
112+
113+
</section>
114+
115+
<!-- /.references -->
116+
117+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
118+
119+
<section class="related">
120+
121+
</section>
122+
123+
<!-- /.related -->
124+
125+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
126+
127+
<section class="links">
128+
129+
[@stdlib/plot/vega/mark/trail/encoding-set]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/plot/vega/mark/trail/encoding-set
130+
131+
</section>
132+
133+
<!-- /.links -->
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 bench = require( '@stdlib/bench' );
24+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
25+
var TrailEncodingSet = require( '@stdlib/plot/vega/mark/trail/encoding-set' );
26+
var Value = require( '@stdlib/plot/vega/value/ctor' );
27+
var format = require( '@stdlib/string/format' );
28+
var pkg = require( './../package.json' ).name;
29+
var isTrailMarkEncodingSet = require( './../lib' );
30+
31+
32+
// MAIN //
33+
34+
bench( format( '%s::true', pkg ), function benchmark( b ) {
35+
var values;
36+
var out;
37+
var v;
38+
var i;
39+
40+
values = [
41+
new TrailEncodingSet({
42+
'x': new Value({
43+
'field': 'x',
44+
'scale': 'xScale'
45+
})
46+
}),
47+
new TrailEncodingSet({
48+
'y': new Value({
49+
'field': 'y',
50+
'scale': 'yScale'
51+
})
52+
})
53+
];
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
v = values[ i%values.length ];
58+
out = isTrailMarkEncodingSet( v );
59+
if ( typeof out !== 'boolean' ) {
60+
b.fail( 'should return a boolean' );
61+
}
62+
}
63+
b.toc();
64+
if ( !isBoolean( out ) ) {
65+
b.fail( 'should return a boolean' );
66+
}
67+
b.pass( 'benchmark finished' );
68+
b.end();
69+
});
70+
71+
bench( format( '%s::false', pkg ), function benchmark( b ) {
72+
var values;
73+
var out;
74+
var v;
75+
var i;
76+
77+
values = [
78+
'foo',
79+
'bar',
80+
'',
81+
'beep',
82+
'boop',
83+
[],
84+
{}
85+
];
86+
87+
b.tic();
88+
for ( i = 0; i < b.iterations; i++ ) {
89+
v = values[ i%values.length ];
90+
out = isTrailMarkEncodingSet( v );
91+
if ( typeof out !== 'boolean' ) {
92+
b.fail( 'should return a boolean' );
93+
}
94+
}
95+
b.toc();
96+
if ( !isBoolean( out ) ) {
97+
b.fail( 'should return a boolean' );
98+
}
99+
b.pass( 'benchmark finished' );
100+
b.end();
101+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
{{alias}}( value )
3+
Tests if an input value is a trail mark encoding set.
4+
5+
Parameters
6+
----------
7+
value: any
8+
Value to test.
9+
10+
Returns
11+
-------
12+
bool: boolean
13+
Boolean indicating if an input value is a trail mark encoding set.
14+
15+
Examples
16+
--------
17+
> var o = { 'field': 'x', 'scale': 'xScale' };
18+
> var v = new {{alias:@stdlib/plot/vega/value/ctor}}( o );
19+
> o = { 'x': v };
20+
> v = new {{alias:@stdlib/plot/vega/mark/trail/encoding-set}}( o );
21+
> var bool = {{alias}}( v )
22+
true
23+
> bool = {{alias}}( {} )
24+
false
25+
26+
See Also
27+
--------
28+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Tests whether an input value is a trail mark encoding set.
23+
*
24+
* @param v - value to test
25+
* @returns boolean indicating whether an input value is a trail mark encoding set
26+
*
27+
* @example
28+
* var Value = require( '@stdlib/plot/vega/value/ctor' );
29+
* var TrailEncodingSet = require( '@stdlib/plot/vega/mark/trail/encoding-set' );
30+
*
31+
* var v = new TrailEncodingSet({
32+
* 'x': new Value({
33+
* 'field': 'x',
34+
* 'scale': 'xScale'
35+
* })
36+
* });
37+
* var bool = isTrailMarkEncodingSet( v );
38+
* // returns true
39+
*
40+
* bool = isTrailMarkEncodingSet( {} );
41+
* // returns false
42+
*
43+
* bool = isTrailMarkEncodingSet( 'foo' );
44+
* // returns false
45+
*/
46+
declare function isTrailMarkEncodingSet( v: any ): boolean;
47+
48+
49+
// EXPORTS //
50+
51+
export = isTrailMarkEncodingSet;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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+
import isTrailMarkEncodingSet = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isTrailMarkEncodingSet( {} ); // $ExpectType boolean
27+
isTrailMarkEncodingSet( 'foo' ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isTrailMarkEncodingSet(); // $ExpectError
33+
isTrailMarkEncodingSet( undefined, 123 ); // $ExpectError
34+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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+
var Value = require( '@stdlib/plot/vega/value/ctor' );
22+
var TrailEncodingSet = require( '@stdlib/plot/vega/mark/trail/encoding-set' );
23+
var isTrailMarkEncodingSet = require( './../lib' );
24+
25+
var v = new TrailEncodingSet({
26+
'x': new Value({
27+
'field': 'x',
28+
'scale': 'xScale'
29+
})
30+
});
31+
var bool = isTrailMarkEncodingSet( v );
32+
console.log( bool );
33+
// => true
34+
35+
bool = isTrailMarkEncodingSet( {} );
36+
console.log( bool );
37+
// => false
38+
39+
bool = isTrailMarkEncodingSet( 'foo' );
40+
console.log( bool );
41+
// => false

0 commit comments

Comments
 (0)