8000 Auto-generated commit · stdlib-js/utils-function-name@86d7c9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 86d7c9f

Browse files
committed
Auto-generated commit
1 parent f1ab33f commit 86d7c9f

File tree

3 files changed

+12
-108
lines changed

3 files changed

+12
-108
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
},
3939
"dependencies": {
4040
"@stdlib/assert-has-function-name-support": "^0.1.0",
41-
"@stdlib/assert-is-function": "^0.1.0",
42-
"@stdlib/regexp-function-name": "^0.1.0",
43-
"@stdlib/string-format": "^0.1.0"
41+
"@stdlib/assert-is-function": "^0.1.1",
42+
"@stdlib/regexp-function-name": "^0.1.1",
43+
"@stdlib/string-format": "^0.1.1"
4444
},
4545
"devDependencies": {
4646
"@stdlib/array-buffer": "^0.1.0",
@@ -53,12 +53,12 @@
5353
"@stdlib/array-uint32": "^0.1.0",
5454
"@stdlib/array-uint8": "^0.1.0",
5555
"@stdlib/array-uint8c": "^0.1.0",
56-
"@stdlib/assert-is-string": "^0.1.0",
56+
"@stdlib/assert-is-string": "^0.1.1",
5757
"@stdlib/bench": "^0.1.0",
58-
"@stdlib/boolean-ctor": "^0.1.0",
59-
"@stdlib/buffer-ctor": "^0.1.0",
60-
"@stdlib/function-ctor": "^0.1.0",
61-
"@stdlib/number-ctor": "^0.1.0",
58+
"@stdlib/boolean-ctor": "^0.1.1",
59+
"@stdlib/buffer-ctor": "^0.1.1",
60+
"@stdlib/function-ctor": "^0.1.1",
61+
"@stdlib/number-ctor": "^0.1.1",
6262
"proxyquire": "^2.0.0",
6363
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
6464
"istanbul": "^0.4.1",

test/dist/test.js

Lines changed: 4 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,108 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var proxyquire = require( 'proxyquire' );
25-
var Int8Array = require( '@stdlib/array-int8' );
26-
var Buffer = require( '@stdlib/buffer-ctor' );
27-
var Number = require( '@stdlib/number-ctor' );
28-
var Boolean = require( '@stdlib/boolean-ctor' );
29-
var Fcn = require( '@stdlib/function-ctor' );
30-
var functionName = require( './../../dist' );
24+
var main = require( './../../dist' );
3125

3226

3327
// TESTS //
3428

35-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3630
t.ok( true, __filename );
37-
t.strictEqual( typeof functionName, 'function', 'export is a function' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
3832
t.end();
3933
});
40-
41-
tape( 'if not provided a function, the function will throw a type error', function test( t ) {
42-
var values;
43-
var i;
44-
45-
values = [
46-
'beep',
47-
5,
48-
NaN,
49-
null,
50-
true,
51-
void 0,
52-
[],
53-
{}
54-
];
55-
56-
for ( i = 0; i < values.length; i++ ) {
57-
t.throws( badValue( values[i] ), TypeError, 'throws a TypeError when provided '+values[i] );
58-
}
59-
t.end();
60-
61-
function badValue( value ) {
62-
return function badValue() {
63-
functionName( value );
64-
};
65-
}
66-
});
67-
68-
tape( 'the function returns a function\'s name', function test( t ) {
69-
function beep() {
70-
return 'boop';
71-
}
72-
t.equal( functionName( beep ), 'beep', 'returns beep' );
73-
t.equal( functionName( Date ), 'Date', 'returns Date' );
74-
t.equal( functionName( Buffer ), 'Buffer', 'returns Buffer' );
75-
t.equal( functionName( Number ), 'Number', 'returns Number' );
76-
t.equal( functionName( Math.sqrt ), 'sqrt', 'returns sqrt'< A3E2 /span> ); // eslint-disable-line stdlib/no-builtin-math
77-
t.equal( functionName( Int8Array ), 'Int8Array', 'returns Int8Array' );
78-
t.equal( functionName( Boolean ), 'Boolean', 'returns Boolean' );
79-
t.equal( functionName( String ), 'String', 'returns String' );
80-
t.equal( functionName( Fcn ), 'Function', 'returns Function' );
81-
t.end();
82-
});
83-
84-
tape( 'if provided an anonymous function, the function returns an empty string or "anonymous" (ES2015 and some browsers)', function test( t ) {
85-
var name;
86-
87-
/*
88-
* See
89-
* - http://www.2ality.com/2015/09/function-names-es6.html
90-
* - https://bugs.webkit.org/show_bug.cgi?id=7726
91-
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name (which claims that functions created using the `Function` constructor should have an empty string as a name)
92-
* - "Functions created with the syntax new Function(...) or just Function(...) have their name property set to an empty string."
93-
*
94-
* In Node.js <v6.0, the returned name is an empty string. For Node.js v6.0, the returned name when using the `Function` constructor is `"anonymous"`.
95-
*/
96-
97-
name = functionName( function () {} ); // eslint-disable-line func-names
98-
t.equal( check( name ), true, 'returns an empty string (or "anonymous")' );
99-
100-
name = functionName( new Fcn('a', 'b', 'return') );
101-
t.equal( check( name ), true, 'returns an empty string (or "anonymous")' );
102-
103-
t.end();
104-
105-
function check() {
106-
if ( name === '' || name === 'anonymous' ) {
107-
return true;
108-
}
109-
return false;
110-
}
111-
});
112-
113-
tape( 'the function supports returning a function name in ES5 and earlier environments', function test( t ) {
114-
var functionName = proxyquire( './../dist/main.js', {
115-
'@stdlib/assert-has-function-name-support': stub
116-
});
117-
t.equal( functionName( beep ), 'beep', 'returns beep' );
118-
t.end();
119-
120-
function beep() {
121-
return 'boop';
122-
}
123-
124-
// Earlier environments did not have a `name` property:
125-
function stub() {
126-
return false;
127-
}
128-
});

0 commit comments

Comments
 (0)
0