Skip to content

Commit 3286c01

Browse files
committed
feat: add constructor name property
--- 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: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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 19c80d8 commit 3286c01

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/node_modules/@stdlib/complex/float64/ctor/lib/main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ function Complex128( real, imag ) {
6060
return this;
6161
}
6262

63+
/**
64+
* Constructor name.
65+
*
66+
* @name name
67+
* @memberof Complex128
68+
* @readonly
69+
* @type {string}
70+
* @default 'Complex128'
71+
*
72+
* @example
73+
* var name = Complex128.name;
74+
* // returns 'Complex128'
75+
*/
76+
setReadOnly( Complex128, 'name', 'Complex128' );
77+
6378
/**
6479
* Size (in bytes) of each component.
6580
*

lib/node_modules/@stdlib/complex/float64/ctor/test/test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ tape( 'the constructor requires the `new` keyword', function test( t ) {
101101
}
102102
});
103103

104+
tape( 'the constructor has a read-only `name` property', function test( t ) {
105+
t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' );
106+
t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' );
107+
t.throws( foo, Error, 'throws an error' );
108+
t.end();
109+
110+
function foo() {
111+
Complex128.name = 'Foo';
112+
}
113+
});
114+
104115
tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) {
105116
t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' );
106117
t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' );

0 commit comments

Comments
 (0)