Skip to content

Commit ad86867

Browse files
feat(iter/cartesian-square): add package.json
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 96a1cb4 commit ad86867

2 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 randu = require( '@stdlib/random/base/randu' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var isIteratorLike = require( '@stdlib/assert/is-iterator-like' );
27+
var linspace = require( '@stdlib/array/linspace' );
28+
var ceil = require( '@stdlib/math/base/special/ceil' );
29+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
30+
var format = require( '@stdlib/string/format' );
31+
var pkg = require( './../package.json' ).name;
32+
var iterCartesianSquare = require( './../lib' );
33+
34+
35+
// MAIN //
36+
37+
bench( pkg, function benchmark( b ) {
38+
var iter;
39+
var i;
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
iter = iterCartesianSquare( linspace( randu(), randu(), 100 ) );
44+
if ( typeof iter !== 'object' ) {
45+
b.fail( 'should return an object' );
46+
}
47+
}
48+
b.toc();
49+
if ( !isIteratorLike( iter ) ) {
50+
b.fail( 'should return an iterator protocol-compliant object' );
51+
}
52+
b.pass( 'benchmark finished' );
53+
b.end();
54+
});
55+
56+
bench( format( '%s::iteration', pkg ), function benchmark( b ) {
57+
var iter;
58+
var z;
59+
var i;
60+
var x;
61+
62+
x = linspace( randu(), randu(), ceil(sqrt(b.iterations)) + 1 );
63+
iter = iterCartesianSquare( x );
64+
65+
b.tic();
66+
for ( i = 0; i < b.iterations; i++ ) {
67+
z = iter.next().value;
68+
if ( isnan( z ) ) {
69+
b.fail( 'should not return NaN' );
70+
}
71+
}
72+
b.toc();
73+
if ( isnan( z ) ) {
74+
b.fail( 'should not return NaN' );
75+
}
76+
b.pass( 'benchmark finished' );
77+
b.end();
78+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "@stdlib/iter/cartesian-square",
3+
"version": "0.0.0",
4+
"description": "Create an iterator of the Cartesian square.",
5+
"license": "Apache-2.0",
6+
"author": {
7+
"name": "The Stdlib Authors",
8+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9+
},
10+
"contributors": [
11+
{
12+
"name": "The Stdlib Authors",
13+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14+
}
15+
],
16+
"main": "./lib",
17+
"directories": {
18+
"benchmark": "./benchmark",
19+
"doc": "./docs",
20+
"example": "./examples",
21+
"lib": "./lib",
22+
"test": "./test"
23+
},
24+
"types": "./docs/types",
25+
"scripts": {},
26+
"homepage": "https://github.com/stdlib-js/stdlib",
27+
"repository": {
28+
"type": "git",
29+
"url": "git://github.com/stdlib-js/stdlib.git"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/stdlib-js/stdlib/issues"
33+
},
34+
"dependencies": {},
35+
"devDependencies": {},
36+
"engines": {
37+
"node": ">=0.10.0",
38+
"npm": ">2.7.0"
39+
},
40+
"os": [
41+
"aix",
42+
"darwin",
43+
"freebsd",
44+
"linux",
45+
"macos",
46+
"openbsd",
47+
"sunos",
48+
"win32",
49+
"windows"
50+
],
51+
"keywords": [
52+
"stdlib",
53+
"stdutils",
54+
"stdutil",
55+
"utilities",
56+
"utility",
57+
"utils",
58+
"util",
59+
"linspace",
60+
"linear",
61+
"sequence",
62+
"monotonic",
63+
"arange",
64+
"range",
65+
"iterator",
66+
"iterable",
67+
"iterate"
68+
]
69+
}

0 commit comments

Comments
 (0)