Skip to content

Commit fc0a799

Browse files
committed
Rename file and clean-up
1 parent d088154 commit fc0a799

File tree

7 files changed

+54
-30
lines changed

7 files changed

+54
-30
lines changed

lib/node_modules/@stdlib/string/right-trim/README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
1919
-->
2020

21-
# Right Trim
21+
# rtrim
2222

2323
> Trim whitespace characters from the end of a string.
2424
@@ -47,7 +47,23 @@ var out = rtrim( ' \t\t\n Beep \r\n\t ' );
4747

4848
## Notes
4949

50-
- Following [Unicode 6.3.0][unicode] and later, "whitespace" is defined as the following characters: `[ \\f\\n\\r\\t\\v\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]`.
50+
- Following [Unicode 6.3.0][unicode] and later, "whitespace" is defined as the following characters:
51+
52+
- `\f`
53+
- `\n`
54+
- `\r`
55+
- `\t`
56+
- `\v`
57+
- `\u0020`
58+
- `\u00a0`
59+
- `\u1680`
60+
- `\u2000-\u200a`
61+
- `\u2028`
62+
- `\u2029`
63+
- `\u202f`
64+
- `\u205f`
65+
- `\u3000`
66+
- `\ufeff`
5167

5268
</section>
5369

lib/node_modules/@stdlib/string/right-trim/benchmark/benchmark.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
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 rtrim = require( './../lib' );
2827

@@ -32,23 +31,26 @@ var rtrim = require( './../lib' );
3231
var opts = {
3332
'skip': ( typeof String.prototype.trimRight !== 'function' )
3433
};
34+
var whitespace = '\\f\\n\\r\\t\\v\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';
3535

3636

3737
// MAIN //
3838

3939
bench( pkg, function benchmark( b ) {
40-
var whitespace;
41-
var str;
40+
var values;
4241
var out;
4342
var i;
4443

45-
whitespace = '\\f\\n\\r\\t\\v\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';
44+
values = [
45+
'beep boop' + whitespace,
46+
'foo bar' + whitespace,
47+
'abc xyz' + whitespace
48+
];
4649

4750
b.tic();
4851
for ( i = 0; i < b.iterations; i++ ) {
49-
str = fromCodePoint( i%126 ) + 'eep boop' + whitespace;
50-
out = rtrim( str );
51-
if ( !isString( out ) ) {
52+
out = rtrim( values[ i%values.length ] );
53+
if ( typeof out !== 'string' ) {
5254
b.fail( 'should return a string' );
5355
}
5456
}
@@ -61,18 +63,20 @@ bench( pkg, function benchmark( b ) {
6163
});
6264

6365
bench( pkg+'::built-in', opts, function benchmark( b ) {
64-
var whitespace;
65-
var str;
66+
var values;
6667
var out;
6768
var i;
6869

69-
whitespace = '\\f\\n\\r\\t\\v\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';
70+
values = [
71+
'beep boop' + whitespace,
72+
'foo bar' + whitespace,
73+
'abc xyz' + whitespace
74+
];
7075

7176
b.tic();
7277
for ( i = 0; i < b.iterations; i++ ) {
73-
str = fromCodePoint( i%126 ) + 'eep boop' + whitespace;
74-
out = str.trimRight();
75-
if ( !isString( out ) ) {
78+
out = values[ i%values.length ].trimRight();
79+
if ( typeof out !== 'string' ) {
7680
b.fail( 'should return a string' );
7781
}
7882
}

lib/node_modules/@stdlib/string/right-trim/docs/repl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( str )
3-
Trims whitespace from the end of a `string`.
3+
Trims whitespace from the end of a string.
44

55
"Whitespace" is defined as the following characters:
66

lib/node_modules/@stdlib/string/right-trim/docs/types/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import rtrim = require( './index' );
2626
rtrim( ' Whitespace ' ); // $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
rtrim( true ); // $ExpectError
3232
rtrim( false ); // $ExpectError
@@ -38,7 +38,7 @@ import rtrim = require( './index' );
3838
rtrim( ( 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
rtrim(); // $ExpectError
4444
}

lib/node_modules/@stdlib/string/right-trim/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
// MODULES //
4040

41-
var rtrim = require( './right_trim.js' );
41+
var rtrim = require( './main.js' );
4242

4343

4444
// EXPORTS //

lib/node_modules/@stdlib/string/right-trim/lib/right_trim.js renamed to lib/node_modules/@stdlib/string/right-trim/lib/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
24-
var replace = require( '@stdlib/string/replace' );
24+
var replace = require( '@stdlib/string/base/replace' );
2525
var format = require( '@stdlib/string/format' );
2626

2727

@@ -37,7 +37,7 @@ var RE = /[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u30
3737
* Trims whitespace from the end of a string.
3838
*
3939
* @param {string} str - input string
40-
* @throws {TypeError} must provide a string primitive
40+
* @throws {TypeError} must provide a string
4141
* @returns {string} trimmed string
4242
*
4343
* @example

lib/node_modules/@stdlib/string/right-trim/test/test.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ tape( 'main export is a function', function test( t ) {
3232
t.end();
3333
});
3434

35-
tape( 'the function throws an error if not provided a string primitive', function test( t ) {
35+
tape( 'the function throws an error if not provided a string', function test( t ) {
3636
var values;
3737
var i;
3838

3939
values = [
40-
new String( 'beep' ), // eslint-disable-line no-new-wrappers
4140
5,
4241
null,
4342
true,
43+
false,
4444
void 0,
4545
NaN,
4646
[],
@@ -100,13 +100,6 @@ tape( 'the function removes all whitespace characters at the end of a string', f
100100
actual = rtrim( 'beep\u1680' );
101101
t.equal( actual, expected, 'removes \\u1680' );
102102

103-
/*
104-
* Note: removed support to match Unicode 6.3.0 and later.
105-
* expected = 'beep';
106-
* actual = rtrim( 'beep\u180e' );
107-
* t.equal( actual, expected, 'removes \\u180e' );
108-
*/
109-
110103
expected = 'beep';
111104
actual = rtrim( 'beep\u2000' );
112105
t.equal( actual, expected, 'removes \\u2000' );
@@ -177,3 +170,14 @@ tape( 'the function removes all whitespace characters at the end of a string', f
177170

178171
t.end();
179172
});
173+
174+
tape( 'the function does not trim the Mongolian space separator in accordance with Unicode 6.3.0 and later', function test( t ) {
175+
var expected;
176+
var actual;
177+
178+
expected = 'beep';
179+
actual = rtrim( 'beep\u180e' );
180+
t.equal( actual, expected, 'does not remove \\u180e' );
181+
182+
t.end();
183+
});

0 commit comments

Comments
 (0)