0.2.1 • Published 2 months ago

@stdlib/string-base v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

Base String

NPM version Build Status Coverage Status

Base (i.e., lower-level) string functions.

Installation

npm install @stdlib/string-base

Usage

var string = require( '@stdlib/string-base' );

string

Namespace containing "base" (i.e., lower-level) string functions.

var ns = string;
// returns {...}

The namespace contains the following functions:

Examples

var ns = require( '@stdlib/string-base' );

// Generate a Pascal case string...
var str = ns.pascalcase( 'beep boop' );
// returns 'BeepBoop'

// Tokenize a string into an array of string parts and format identifier objects...
str = 'The %d %s foxes jumped over the %d %s dogs.';
var tokens = ns.formatTokenize( str );
// returns [ 'The ', {...}, ' ', {...}, ' foxes jumped over the ', {...}, ' ', {...}, ' dogs.' ]

// Generate a string from a token array by interpolating values...
str = ns.formatInterpolate( tokens, 3, 'quick', 4, 'lazy' );
// returns 'The 3 quick foxes jumped over the 4 lazy dogs.'

// Test whether a string starts with the characters of another string...
str = 'Lorem ipsum dolor sit amet';
var bool = ns.startsWith( str, 'Lorem' );
// returns true

// Test whether a string ends with the characters of another string...
bool = ns.endsWith( str, 'amet' );
// returns true

// Trim whitespace characters from the beginning and end of a string...
str = '   \t\n Lorem ipsum dolor sit amet   \n\t  ';
str = ns.trim( str );
// returns 'Lorem ipsum dolor sit amet'

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

@stdlib/string-base-altcase@stdlib/string-base-camelcase@stdlib/string-base-capitalize@stdlib/string-base-code-point-at@stdlib/string-base-constantcase@stdlib/string-base-distances@stdlib/string-base-dotcase@stdlib/string-base-ends-with@stdlib/string-base-first@stdlib/string-base-first-code-point@stdlib/string-base-first-grapheme-cluster@stdlib/string-base-for-each@stdlib/string-base-for-each-code-point@stdlib/string-base-for-each-grapheme-cluster@stdlib/string-base-format-interpolate@stdlib/string-base-format-tokenize@stdlib/string-base-headercase@stdlib/string-base-invcase@stdlib/string-base-kebabcase@stdlib/string-base-left-pad@stdlib/string-base-left-trim@stdlib/string-base-lowercase@stdlib/string-base-pascalcase@stdlib/string-base-percent-encode@stdlib/string-base-remove-first@stdlib/string-base-remove-first-code-point@stdlib/string-base-remove-first-grapheme-cluster@stdlib/string-base-remove-last@stdlib/string-base-remove-last-code-point@stdlib/string-base-remove-last-grapheme-cluster@stdlib/string-base-repeat@stdlib/string-base-replace@stdlib/string-base-replace-before@stdlib/string-base-reverse@stdlib/string-base-reverse-code-points@stdlib/string-base-reverse-grapheme-clusters@stdlib/string-base-right-pad@stdlib/string-base-right-trim@stdlib/string-base-snakecase@stdlib/string-base-startcase@stdlib/string-base-starts-with@stdlib/string-base-trim@stdlib/string-base-truncate-middle@stdlib/string-base-uncapitalize@stdlib/string-base-uppercase@stdlib/utils-define-read-only-property
0.2.1

2 months ago

0.2.0

3 months ago

0.1.0

8 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago