Skip to content

Commit de69cef

Browse files
committed
Update docs, code style, and tests + requires
1 parent 6b4a44c commit de69cef

File tree

7 files changed

+64
-16
lines changed

7 files changed

+64
-16
lines changed

lib/node_modules/@stdlib/string/next-grapheme-cluster-break/lib/main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
2525
var codePointAt = require( '@stdlib/string/code-point-at' );
2626
var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
27-
var breakType = require( '@stdlib/string/tools/grapheme-cluster-break' ).breakType;
28-
var graphemeBreakProperty = require( '@stdlib/string/tools/grapheme-cluster-break' ).breakProperty;
29-
var emojiProperty = require( '@stdlib/string/tools/grapheme-cluster-break' ).emojiProperty;
27+
var grapheme = require( '@stdlib/string/tools/grapheme-cluster-break' );
28+
29+
30+
// VARIABLES //
31+
32+
var breakType = grapheme.breakType;
33+
var breakProperty = grapheme.breakProperty;
34+
var emojiProperty = grapheme.emojiProperty;
3035

3136

3237
// MAIN //
@@ -93,7 +98,7 @@ function nextGraphemeClusterBreak( str, fromIndex ) {
9398
cp = codePointAt( str, idx );
9499

95100
// Get the corresponding grapheme break and emoji properties:
96-
breaks.push( graphemeBreakProperty( cp ) );
101+
breaks.push( breakProperty( cp ) );
97102
emoji.push( emojiProperty( cp ) );
98103

99104
// Begin searching for the next grapheme cluster break...
@@ -106,7 +111,7 @@ function nextGraphemeClusterBreak( str, fromIndex ) {
106111
cp = codePointAt( str, i );
107112

108113
// Get the corresponding grapheme break and emoji properties:
109-
breaks.push( graphemeBreakProperty( cp ) );
114+
breaks.push( breakProperty( cp ) );
110115
emoji.push( emojiProperty( cp ) );
111116

112117
// Determine if we've encountered a grapheme cluster break...

lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/docs/usage.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Options:
55

66
-h, --help Print this message.
77
-V, --version Print the package version.
8-
--from index Starting search position in string. Default: 0.
8+
--from index Starting search position. Default: str.length-1.

lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/lib/main.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isInteger = require( '@stdlib/assert/is-integer' );
2525
var codePointAt = require( '@stdlib/string/code-point-at' );
2626
var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
27-
var breakType = require( '@stdlib/string/tools/grapheme-cluster-break' ).breakType;
28-
var breakProperty = require( '@stdlib/string/tools/grapheme-cluster-break' ).breakProperty;
29-
var emojiProperty = require( '@stdlib/string/tools/grapheme-cluster-break' ).emojiProperty;
27+
var grapheme = require( '@stdlib/string/tools/grapheme-cluster-break' );
28+
29+
30+
// VARIABLES //
31+
32+
var breakType = grapheme.breakType;
33+
var breakProperty = grapheme.breakProperty;
34+
var emojiProperty = grapheme.emojiProperty;
3035

3136

3237
// MAIN //
@@ -99,8 +104,8 @@ function prevGraphemeClusterBreak( str, fromIndex ) {
99104
// If the current character is part of a surrogate pair, move along...
100105
if ( hasUTF16SurrogatePairAt( str, i-1 ) ) {
101106
ans = i-2;
102-
breaks = [];
103-
emoji = [];
107+
breaks.length = 0;
108+
emoji.length = 0;
104109
continue;
105110
}
106111
cp = codePointAt( str, i );
@@ -112,8 +117,8 @@ function prevGraphemeClusterBreak( str, fromIndex ) {
112117
// Determine if we've encountered a grapheme cluster break...
113118
if ( breakType( breaks, emoji ) > 0 ) {
114119
ans = i-1;
115-
breaks = [];
116-
emoji = [];
120+
breaks.length = 0;
121+
emoji.length = 0;
117122
continue;
118123
}
119124
}

lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ tape( 'the command-line interface returns the previous grapheme break position i
162162
}
163163
});
164164

165-
tape( 'the command-line interface uses a default starting search index of `0`', opts, function test( t ) {
165+
tape( 'the command-line interface uses a default starting search index of `string.length-1`', opts, function test( t ) {
166166
var cmd = [
167167
EXEC_PATH,
168168
'-e',

lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,37 @@ tape( 'the function throws an error if the first argument is not a string primit
5656
}
5757
t.end();
5858

59+
function badValue( value ) {
60+
return function badValue() {
61+
prevGraphemeClusterBreak( value );
62+
};
63+
}
64+
});
65+
66+
tape( 'the function throws an error if the first argument is not a string primitive (with second argument)', function test( t ) {
67+
var values;
68+
var i;
69+
70+
values = [
71+
-5,
72+
3.14,
73+
-1.0,
74+
NaN,
75+
true,
76+
false,
77+
null,
78+
void 0,
79+
[ 'beep', 'boop' ],
80+
[ 1, 2, 3 ],
81+
{},
82+
function noop() {}
83+
];
84+
85+
for ( i = 0; i < values.length; i++ ) {
86+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
87+
}
88+
t.end();
89+
5990
function badValue( value ) {
6091
return function badValue() {
6192
prevGraphemeClusterBreak( value, 0 );

lib/node_modules/@stdlib/string/reverse/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function reverse( str ) {
6565
idx = str.length - 1;
6666
while ( idx >= 0 ) {
6767
brk = prevGraphemeClusterBreak( str, idx );
68-
for ( i=brk+1; i<=idx; i++ ) {
68+
for ( i = brk + 1; i <= idx; i++ ) {
6969
out.push( str.charAt( i ) );
7070
}
7171
idx = brk;

lib/node_modules/@stdlib/string/tools/grapheme-cluster-break/docs/types/index.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818

1919
// TypeScript Version: 2.0
2020

21+
/**
22+
* An object mapping break type names to integer values.
23+
*/
24+
interface Constants {
25+
[key: string]: number;
26+
}
27+
2128
/**
2229
* Interface describing grapheme cluster break tooling.
2330
*/
@@ -78,7 +85,7 @@ interface Grapheme {
7885
/**
7986
* An object mapping break type names to integer values.
8087
*/
81-
constants: any;
88+
constants: Constants;
8289
}
8390

8491
/**

0 commit comments

Comments
 (0)