@@ -33,13 +33,17 @@ import firstCodePoint = require( '@stdlib/string-base-first-code-point' );
33
33
import firstGraphemeCluster = require( '@stdlib/string-base-first-grapheme-cluster' ) ;
34
34
import forEach = require( '@stdlib/string-base-for-each' ) ;
35
35
import forEachCodePoint = require( '@stdlib/string-base-for-each-code-point' ) ;
36
+ import forEachCodePointRight = require( '@stdlib/string-base-for-each-code-point-right' ) ;
36
37
import forEachGraphemeCluster = require( '@stdlib/string-base-for-each-grapheme-cluster' ) ;
37
38
import forEachRight = require( '@stdlib/string-base-for-each-right' ) ;
38
39
import formatInterpolate = require( '@stdlib/string-base-format-interpolate' ) ;
39
40
import formatTokenize = require( '@stdlib/string-base-format-tokenize' ) ;
40
41
import headercase = require( '@stdlib/string-base-headercase' ) ;
41
42
import invcase = require( '@stdlib/string-base-invcase' ) ;
42
43
import kebabcase = require( '@stdlib/string-base-kebabcase' ) ;
44
+ import last = require( '@stdlib/string-base-last' ) ;
45
+ import lastCodePoint = require( '@stdlib/string-base-last-code-point' ) ;
46
+ import lastGraphemeCluster = require( '@stdlib/string-base-last-grapheme-cluster' ) ;
43
47
import lpad = require( '@stdlib/string-base-left-pad' ) ;
44
48
import ltrim = require( '@stdlib/string-base-left-trim' ) ;
45
49
import lowercase = require( '@stdlib/string-base-lowercase' ) ;
@@ -65,6 +69,7 @@ import rtrim = require( '@stdlib/string-base-right-trim' );
65
69
import snakecase = require( '@stdlib/string-base-snakecase' ) ;
66
70
import startcase = require( '@stdlib/string-base-startcase' ) ;
67
71
import startsWith = require( '@stdlib/string-base-starts-with' ) ;
72
+ import stickycase = require( '@stdlib/string-base-stickycase' ) ;
68
73
import trim = require( '@stdlib/string-base-trim' ) ;
69
74
import truncateMiddle = require( '@stdlib/string-base-truncate-middle' ) ;
70
75
import uncapitalize = require( '@stdlib/string-base-uncapitalize' ) ;
@@ -363,6 +368,31 @@ interface Namespace {
363
368
*/
364
369
forEachCodePoint : typeof forEachCodePoint ;
365
370
371
+ /**
372
+ * Invokes a function for each Unicode code point in a string, iterating from right to left.
373
+ *
374
+ * ## Notes
375
+ *
376
+ * - When invoked, the provided function is provided three arguments:
377
+ *
378
+ * - **value**: code point.
379
+ * - **index**: starting code point index.
380
+ * - **str**: input string.
381
+ *
382
+ * @param str - input string
383
+ * @param clbk - function to invoke
384
+ * @param thisArg - execution context
385
+ * @returns input string
386
+ *
387
+ * @example
388
+ * function log( value, index ) {
389
+ * console.log( '%d: %s', index, value );
390
+ * }
391
+ *
392
+ * ns.forEachCodePointRight( 'Hello, World!', log );
393
+ */
394
+ forEachCodePointRight : typeof forEachCodePointRight ;
395
+
366
396
/**
367
397
* Invokes a function for each grapheme cluster (i.e., user-perceived character) in a string.
368
398
*
@@ -504,6 +534,85 @@ interface Namespace {
504
534
*/
505
535
kebabcase : typeof kebabcase ;
506
536
537
+ /**
538
+ * Returns the last `n` UTF-16 code units of a string.
539
+ *
540
+ * @param str - input string
541
+ * @param n - number of code units to return
542
+ * @returns output string
543
+ *
544
+ * @example
545
+ * var s = ns.last( 'hello world', 1 );
546
+ * // returns 'd'
547
+ *
548
+ * @example
549
+ * var s = ns.last( 'foo', 2 );
550
+ * // returns 'oo'
551
+ *
552
+ * @example
553
+ * var s = ns.last( 'JavaScript', 6 );
554
+ * // returns 'Script'
555
+ *
556
+ * @example
557
+ * var s = ns.last( 'foo bar', 10 );
558
+ * // returns 'foo bar'
559
+ */
560
+ last : typeof last ;
561
+
562
+ /**
563
+ * Returns the last `n` Unicode code points of a string.
564
+ *
565
+ * @param str - input string
566
+ * @param n - number of code points to return
567
+ * @returns output string
568
+ *
569
+ * @example
570
+ * var out = ns.lastCodePoint( 'Hello World', 1 );
571
+ * // returns 'd'
572
+ *
573
+ * @example
574
+ * var out = ns.lastCodePoint( 'JavaScript', 6 );
575
+ * // returns 'Script'
576
+ *
577
+ * @example
578
+ * var out = ns.lastCodePoint( 'New', 5 );
579
+ * // returns 'New'
580
+ *
581
+ * @example
582
+ * var out = ns.lastCodePoint( 'अनुच्छेद', 1 );
583
+ * // returns 'द'
584
+ */
585
+ lastCodePoint : typeof lastCodePoint ;
586
+
587
+ /**
588
+ * Returns the last `n` grapheme clusters (i.e., user-perceived characters) of a string.
589
+ *
590
+ * @param str - input string
591
+ * @param n - number of grapheme clusters to return
592
+ * @returns output string
593
+ *
594
+ * @example
595
+ * var out = ns.lastGraphemeCluster( 'Hello World', 1 );
596
+ * // returns 'd'
597
+ *
598
+ * @example
599
+ * var out = ns.lastGraphemeCluster( 'Evening', 3 );
600
+ * // returns 'ing'
601
+ *
602
+ * @example
603
+ * var out = ns.lastGraphemeCluster( 'JavaScript', 6 );
604
+ * // returns 'Script'
605
+ *
606
+ * @example
607
+ * var out = ns.lastGraphemeCluster( '🐶🐮🐷🐰🐸', 2 );
608
+ * // returns '🐰🐸'
609
+ *
610
+ * @example
611
+ * var out = ns.lastGraphemeCluster( 'foo bar', 5 );
612
+ * // returns 'o bar'
613
+ */
614
+ lastGraphemeCluster : typeof lastGraphemeCluster ;
615
+
507
616
/**
508
617
* Left pads a string such that the padded string has a length of at least `len`.
509
618
*
@@ -1198,6 +1307,27 @@ interface Namespace {
1198
1307
*/
1199
1308
startsWith : typeof startsWith ;
1200
1309
1310
+ /**
1311
+ * Converts a string to "sticky caps" case.
1312
+ *
1313
+ * @param str - input string
1314
+ * @param p - probability of capitalization (default: 0.5)
1315
+ * @returns sticky case string
1316
+ *
1317
+ * @example
1318
+ * var str = ns.stickycase( 'hello world' );
1319
+ * // returns <string>
1320
+ *
1321
+ * @example
1322
+ * var str = ns.stickycase( 'hello world', 0.2 );
1323
+ * // returns <string>
1324
+ *
1325
+ * @example
1326
+ * var str = ns.stickycase( 'hello world', 0.8 );
1327
+ * // returns <string>
1328
+ */
1329
+ stickycase : typeof stickycase ;
1330
+
1201
1331
/**
1202
1332
* Trims whitespace characters from the beginning and end of a string.
1203
1333
*
0 commit comments