Skip to content

Commit 4c4ff66

Browse files
committed
Auto-generated commit
1 parent 0a39a05 commit 4c4ff66

10 files changed

Lines changed: 37 additions & 22 deletions

File tree

.gitattributes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@
2323
# Automatically normalize the line endings of any committed text files:
2424
* text=auto
2525

26+
# Override line endings for certain files on checkout:
27+
*.crlf.csv text eol=crlf
28+
29+
# Denote that certain files are binary and should not be modified:
30+
*.png binary
31+
*.jpg binary
32+
*.jpeg binary
33+
*.gif binary
34+
*.ico binary
35+
*.gz binary
36+
*.zip binary
37+
*.7z binary
38+
*.mp3 binary
39+
*.mp4 binary
40+
*.mov binary
41+
2642
# Override what is considered "vendored" by GitHub's linguist:
2743
/deps/** linguist-vendored=false
2844
/lib/node_modules/** linguist-vendored=false linguist-generated=false

.github/.keepalive

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

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var capitalize = require( '@stdlib/string-capitalize' );
5252

5353
#### capitalize( str )
5454

55-
Capitalizes the first character in a `string`.
55+
Capitalizes the first character in a string.
5656

5757
```javascript
5858
var out = capitalize( 'last man standing' );
@@ -75,9 +75,7 @@ out = capitalize( 'Hidden Treasures' );
7575
```javascript
7676
var capitalize = require( '@stdlib/string-capitalize' );
7777

78-
var str;
79-
80-
str = capitalize( 'last man standing' );
78+
var str = capitalize( 'last man standing' );
8179
// returns 'Last man standing'
8280

8381
str = capitalize( 'presidential election' );

benchmark/benchmark.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,27 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
25-
var fromCodePoint = require( '@stdlib/string-from-code-point' );
2625
var pkg = require( './../package.json' ).name;
2726
var capitalize = require( './../lib' );
2827

2928

3029
// MAIN //
3130

3231
bench( pkg, function benchmark( b ) {
33-
var str;
32+
var values;
3433
var out;
3534
var i;
3635

36+
values = [
37+
'beep boop',
38+
'foo bar',
39+
'xyz xyz'
40+
];
41+
3742
b.tic();
3843
for ( i = 0; i < b.iterations; i++ ) {
39-
str = fromCodePoint( i%126 ) + 'eep boop';
40-
out = capitalize( str );
41-
if ( !isString( out ) ) {
44+
out = capitalize( values[ i%values.length ] );
45+
if ( typeof out !== 'string' ) {
4246
b.fail( 'should return a string' );
4347
}
4448
}

docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( str )
3-
Capitalizes the first character in a `string`.
3+
Capitalizes the first character in a string.
44

55
Parameters
66
----------

docs/types/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import capitalize = require( './index' );
2626
capitalize( 'abc' ); // $ExpectType string
2727
}
2828

29-
// The function does not compile if provided a value other than a string...
29+
// The compiler throws an error if the function is provided a value other than a string...
3030
{
3131
capitalize( true ); // $ExpectError
3232
capitalize( false ); // $ExpectError
@@ -38,7 +38,7 @@ import capitalize = require( './index' );
3838
capitalize( ( x: number ): number => x ); // $ExpectError
3939
}
4040

41-
// The function does not compile if provided insufficient arguments...
41+
// The compiler throws an error if the function is provided insufficient arguments...
4242
{
4343
capitalize(); // $ExpectError
4444
}

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535

3636
// MODULES //
3737

38-
var capitalize = require( './capitalize.js' );
38+
var main = require( './main.js' );
3939

4040

4141
// EXPORTS //
4242

43-
module.exports = capitalize;
43+
module.exports = main;

lib/capitalize.js renamed to lib/main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
2424
var format = require( '@stdlib/string-format' );
25+
var base = require( '@stdlib/string-base-capitalize' );
2526

2627

2728
// MAIN //
@@ -30,7 +31,7 @@ var format = require( '@stdlib/string-format' );
3031
* Capitalizes the first character in a string.
3132
*
3233
* @param {string} str - input string
33-
* @throws {TypeError} must provide a string primitive
34+
* @throws {TypeError} must provide a string
3435
* @returns {string} capitalized string
3536
*
3637
* @example
@@ -53,10 +54,7 @@ function capitalize( str ) {
5354
if ( !isString( str ) ) {
5455
throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
5556
}
56-
if ( str === '' ) {
57-
return '';
58-
}
59-
return str.charAt( 0 ).toUpperCase() + str.slice( 1 );
57+
return base( str );
6058
}
6159

6260

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@stdlib/process-read-stdin": "^0.0.x",
4848
"@stdlib/regexp-eol": "^0.0.x",
4949
"@stdlib/streams-node-stdin": "^0.0.x",
50+
"@stdlib/string-base-capitalize": "^0.0.x",
5051
"@stdlib/string-format": "^0.0.x",
5152
"@stdlib/utils-regexp-from-string": "^0.0.x"
5253
},
@@ -55,7 +56,6 @@
5556
"@stdlib/assert-is-windows": "^0.0.x",
5657
"@stdlib/bench": "^0.0.x",
5758
"@stdlib/process-exec-path": "^0.0.x",
58-
"@stdlib/string-from-code-point": "^0.0.x",
5959
"@stdlib/string-replace": "^0.0.x",
6060
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
6161
"proxyquire": "^2.0.0",

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tape( 'the function returns an empty string if provided an empty string', functi
6464
t.end();
6565
});
6666

67-
tape( 'the function capitalizes the first character in a given string', function test( t ) {
67+
tape( 'the function capitalizes the first character in a provided string', function test( t ) {
6868
var out;
6969

7070
out = capitalize( 'hello world' );

0 commit comments

Comments
 (0)