Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 10, 2024
1 parent 8a31265 commit 6738c3a
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2016-2023 The Stdlib Authors.
Copyright (c) 2016-2024 The Stdlib Authors.
26 changes: 26 additions & 0 deletions base/distances/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,38 @@

/* eslint-disable max-lines */

import hammingDistance = require( './../../../../base/distances/hamming' );
import levenshteinDistance = require( './../../../../base/distances/levenshtein' );

/**
* Interface describing the `distances` namespace.
*/
interface Namespace {
/**
* Calculates the Hamming distance between two equal-length strings.
*
* ## Notes
*
* - The function returns a sentinel value of `-1` if the input string lengths differ.
*
* @param str1 - first input string
* @param str2 - second input string
* @returns Hamming distance
*
* @example
* var dist = ns.hammingDistance( 'fly', 'ant' );
* // returns 3
*
* @example
* var dist = ns.hammingDistance( 'algorithms', 'altruistic' );
* // returns 7
*
* @example
* var dist = ns.hammingDistance( 'hippopod', 'elephant' );
* // returns 7
*/
hammingDistance: typeof hammingDistance;

/**
* Calculates the Levenshtein (edit) distance between two strings.
*
Expand Down
244 changes: 243 additions & 1 deletion base/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/* eslint-disable max-lines */

import altcase = require( './../../../base/altcase' );
import camelcase = require( './../../../base/camelcase' );
import capitalize = require( './../../../base/capitalize' );
import codePointAt = require( './../../../base/code-point-at' );
Expand All @@ -46,22 +47,49 @@ import percentEncode = require( './../../../base/percent-encode' );
import removeFirst = require( './../../../base/remove-first' );
import removeFirstCodePoint = require( './../../../base/remove-first-code-point' );
import removeFirstGraphemeCluster = require( './../../../base/remove-first-grapheme-cluster' );
import removeLast = require( './../../../base/remove-last' );
import removeLastCodePoint = require( './../../../base/remove-last-code-point' );
import removeLastGraphemeCluster = require( './../../../base/remove-last-grapheme-cluster' );
import repeat = require( './../../../base/repeat' );
import replace = require( './../../../base/replace' );
import replaceBefore = require( './../../../base/replace-before' );
import reverse = require( './../../../base/reverse' );
import reverseCodePoints = require( './../../../base/reverse-code-points' );
import reverseGraphemeClusters = require( './../../../base/reverse-grapheme-clusters' );
import rpad = require( './../../../base/right-pad' );
import rtrim = require( './../../../base/right-trim' );
import snakecase = require( './../../../base/snakecase' );
import startcase = require( './../../../base/startcase' );
import startsWith = require( './../../../base/starts-with' );
import trim = require( './../../../base/trim' );
import truncateMiddle = require( './../../../base/truncate-middle' );
import uncapitalize = require( './../../../base/uncapitalize' );
import uppercase = require( './../../../base/uppercase' );

/**
* Interface describing the `base` namespace.
*/
interface Namespace {
/**
* Converts a string to alternate case.
*
* @param str - string to convert
* @returns alternate-cased string
*
* @example
* var str = ns.altcase( 'beep' );
* // returns 'bEeP'
*
* @example
* var str = ns.altcase( 'beep boop' );
* // returns 'bEeP BoOp'
*
* @example
* var str = ns.altcase( 'Hello World!' );
* // returns 'hElLo wOrLd!'
*/
altcase: typeof altcase;

/**
* Converts a string to camel case.
*
Expand Down Expand Up @@ -632,6 +660,97 @@ interface Namespace {
*/
removeFirstGraphemeCluster: typeof removeFirstGraphemeCluster;

/**
* Removes the last `n` UTF-16 code units of a string.
*
* @param str - input string
* @param n - number of code units to remove
* @returns output string
*
* @example
* var out = ns.removeLast( 'last man standing', 1 );
* // returns 'last man standin'
*
* @example
* var out = ns.removeLast( 'presidential election', 1 );
* // returns 'presidential electio'
*
* @example
* var out = ns.removeLast( 'JavaScript', 1 );
* // returns 'JavaScrip'
*
* @example
* var out = ns.removeLast( 'Hidden Treasures', 1 );
* // returns 'Hidden Treasure'
*
* @example
* var out = ns.removeLast( 'foo bar', 5 );
* // returns 'fo'
*/
removeLast: typeof removeLast;

/**
* Removes the last `n` Unicode code points of a string.
*
* @param str - input string
* @param n - number of code points to remove
* @returns output string
*
* @example
* var out = ns.removeLastCodePoint( 'last man standing', 1 );
* // returns 'last man standin'
*
* @example
* var out = ns.removeLastCodePoint( 'presidential election', 1 );
* // returns 'presidential electio'
*
* @example
* var out = ns.removeLastCodePoint( 'JavaScript', 1 );
* // returns 'JavaScrip'
*
* @example
* var out = ns.removeLastCodePoint( 'Hidden Treasures', 1 );
* // returns 'Hidden Treasure'
*
* @example
* var out = ns.removeLastCodePoint( 'foo bar', 5 );
* // returns 'fo'
*/
removeLastCodePoint: typeof removeLastCodePoint;

/**
* Removes the last `n` grapheme clusters (i.e., user-perceived characters) of a string.
*
* @param str - input string
* @param n - number of grapheme clusters to remove
* @returns output string
*
* @example
* var out = ns.removeLastGraphemeCluster( 'last man standing', 1 );
* // returns 'last man standin'
*
* @example
* var out = ns.removeLastGraphemeCluster( 'presidential election', 1 );
* // returns 'presidential electio'
*
* @example
* var out = ns.removeLastGraphemeCluster( 'JavaScript', 1 );
* // returns 'JavaScrip'
*
* @example
* var out = ns.removeLastGraphemeCluster( 'Hidden Treasures', 1 );
* // returns 'Hidden Treasure'
*
* @example
* var out = ns.removeLastGraphemeCluster( '🐶🐮🐷🐰🐸', 2 );
* // returns '🐶🐮🐷'
*
* @example
* var out = ns.removeLastGraphemeCluster( 'foo bar', 5 );
* // returns 'fo'
*/
removeLastGraphemeCluster: typeof removeLastGraphemeCluster;

/**
* Repeats a string `n` times and returns the concatenated result.
*
Expand Down Expand Up @@ -667,7 +786,7 @@ interface Namespace {
* // returns 'Hello Mr. President'
*
* @example
* var capitalize = require( `@stdlib/string/base/capitalize` );
* var capitalize = require( './../../../base/capitalize' );
*
* var str = 'Oranges and lemons say the bells of St. Clement\'s';
*
Expand Down Expand Up @@ -706,6 +825,94 @@ interface Namespace {
*/
replaceBefore: typeof replaceBefore;

/**
* Reverses the UTF-16 code units of a string.
*
* @param str - input string
* @returns output string
*
* @example
* var out = ns.reverse( 'last man standing' );
* // returns 'gnidnats nam tsal'
*
* @example
* var out = ns.reverse( 'presidential election' );
* // returns 'noitcele laitnediserp'
*
* @example
* var out = ns.reverse( 'JavaScript' );
* // returns 'tpircSavaJ'
*
* @example
* var out = ns.reverse( 'Hidden Treasures' );
* // returns 'serusaerT neddiH'
*
* @example
* var out = ns.reverse( 'foo bar' );
* // returns 'rab oof'
*/
reverse: typeof reverse;

/**
* Reverses the Unicode code points of a string.
*
* @param str - input string
* @returns output string
*
* @example
* var out = ns.reverseCodePoints( 'last man standing' );
* // returns 'gnidnats nam tsal'
*
* @example
* var out = ns.reverseCodePoints( 'presidential election' );
* // returns 'noitcele laitnediserp'
*
* @example
* var out = ns.reverseCodePoints( 'JavaScript' );
* // returns 'tpircSavaJ'
*
* @example
* var out = ns.reverseCodePoints( 'Hidden Treasures' );
* // returns 'serusaerT neddiH'
*
* @example
* var out = ns.reverseCodePoints( 'foo bar' );
* // returns 'rab oof'
*/
reverseCodePoints: typeof reverseCodePoints;

/**
* Reverses the grapheme clusters (i.e., user-perceived characters) of a string.
*
* @param str - input string
* @returns output string
*
* @example
* var out = ns.reverseGraphemeClusters( 'last man standing' );
* // returns 'gnidnats nam tsal'
*
* @example
* var out = ns.reverseGraphemeClusters( 'presidential election' );
* // returns 'noitcele laitnediserp'
*
* @example
* var out = ns.reverseGraphemeClusters( 'JavaScript' );
* // returns 'tpircSavaJ'
*
* @example
* var out = ns.reverseGraphemeClusters( 'Hidden Treasures' );
* // returns 'serusaerT neddiH'
*
* @example
* var out = ns.reverseGraphemeClusters( '🐶🐮🐷🐰🐸' );
* // returns '🐸🐰🐷🐮🐶'
*
* @example
* var out = ns.reverseGraphemeClusters( 'foo bar' );
* // returns 'rab oof'
*/
reverseGraphemeClusters: typeof reverseGraphemeClusters;

/**
* Right pads a string such that the padded string has a length of at least `len`.
*
Expand Down Expand Up @@ -842,6 +1049,41 @@ interface Namespace {
*/
trim: typeof trim;

/**
* Truncates the middle UTF-16 code units of a string to return a string having a specified length.
*
* @param str - input string
* @param len - output string length (including sequence)
* @param seq - custom replacement sequence
* @returns truncated string
*
* @example
* var str = 'beep boop';
* var out = ns.truncateMiddle( str, 5, '...' );
* // returns 'b...p'
*
* @example
* var str = 'beep boop';
* var out = ns.truncateMiddle( str, 5, '>>>' );
* // returns 'b>>>p'
*
* @example
* var str = 'beep boop';
* var out = ns.truncateMiddle( str, 10, '...' );
* // returns 'beep boop'
*
* @example
* var str = 'beep boop';
* var out = ns.truncateMiddle( str, 0, '...' );
* // returns ''
*
* @example
* var str = 'beep boop';
* var out = ns.truncateMiddle( str, 2, '...' );
* // returns '..'
*/
truncateMiddle: typeof truncateMiddle;

/**
* Uncapitalizes the first character of a string.
*
Expand Down
2 changes: 1 addition & 1 deletion base/replace/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* // returns 'Hello Mr. President'
*
* @example
* var capitalize = require( `@stdlib/string/base/capitalize` );
* var capitalize = require( '@stdlib/string/base/capitalize' );
*
* var str = 'Oranges and lemons say the bells of St. Clement\'s';
*
Expand Down
21 changes: 20 additions & 1 deletion docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import lpad = require( './../../left-pad' );
import ltrim = require( './../../left-trim' );
import ltrimN = require( './../../left-trim-n' );
import lowercase = require( './../../lowercase' );
import nextCodePointIndex = require( './../../next-code-point-index' );
import nextGraphemeClusterBreak = require( './../../next-grapheme-cluster-break' );
import numGraphemeClusters = require( './../../num-grapheme-clusters' );
import num2words = require( './../../num2words' );
Expand Down Expand Up @@ -471,6 +472,24 @@ interface Namespace {
*/
lowercase: typeof lowercase;

/**
* Returns the position of the next Unicode code point in a string after a specified position.
*
* @param str - input string
* @param fromIndex - position (default: 0)
* @throws first argument must be a string
* @throws second argument must be an integer
* @returns next code point position
*
* @example
* var out = ns.nextCodePointIndex( '𐒻𐓟𐒻𐓟', 0 );
* // returns 2
*
* out = ns.nextCodePointIndex( '🌷' );
* // returns -1
*/
nextCodePointIndex: typeof nextCodePointIndex;

/**
* Returns the next extended grapheme cluster break in a string after a specified position.
*
Expand Down Expand Up @@ -811,7 +830,7 @@ interface Namespace {
* // returns 'Hello Mr. President'
*
* @example
* var capitalize = require( `@stdlib/string/capitalize` );
* var capitalize = require( './../../capitalize' );
*
* var str = 'Oranges and lemons say the bells of St. Clement\'s';
*
Expand Down
Loading

0 comments on commit 6738c3a

Please sign in to comment.