@stdlib/string-base

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

https://github.com/stdlib-js/string-base

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

base javascript node node-js nodejs stdlib str string util utilities utility utils

Keywords from Contributors

iterator assert abbreviate prop property normal squared counts symbol
Last synced: 6 months ago · JSON representation ·

Repository

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

Basic Info
Statistics
  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
base javascript node node-js nodejs stdlib str string util utilities utility utils
Created almost 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Base String

NPM version Build Status Coverage Status <!-- dependencies -->

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

## Installation ```bash npm install @stdlib/string-base ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var string = require( '@stdlib/string-base' ); ``` #### string Namespace containing "base" (i.e., lower-level) string functions. ```javascript var ns = string; // returns {...} ``` The namespace contains the following functions:
- [`altcase( str )`][@stdlib/string/base/altcase]: convert a string to alternate case. - [`atob( str )`][@stdlib/string/base/atob]: decode a string of data which has been encoded using Base64 encoding. - [`base64ToUint8Array( str )`][@stdlib/string/base/base64-to-uint8array]: convert a Base64-encoded string to a Uint8Array. - [`camelcase( str )`][@stdlib/string/base/camelcase]: convert a string to camel case. - [`capitalize( str )`][@stdlib/string/base/capitalize]: capitalize the first character in a string. - [`codePointAt( string, position, backward )`][@stdlib/string/base/code-point-at]: return a Unicode code point from a string at a specified position. - [`constantcase( str )`][@stdlib/string/base/constantcase]: convert a string to constant case. - [`distances`][@stdlib/string/base/distances]: implementations of various string similarity metrics. - [`dotcase( str )`][@stdlib/string/base/dotcase]: convert a string to dot case. - [`endsWith( str, search, len )`][@stdlib/string/base/ends-with]: test if a string ends with the characters of another string. - [`firstCodePoint( str, n )`][@stdlib/string/base/first-code-point]: return the first `n` Unicode code points of a string. - [`firstGraphemeCluster( str, n )`][@stdlib/string/base/first-grapheme-cluster]: return the first `n` grapheme clusters (i.e., user-perceived characters) of a string. - [`first( str, n )`][@stdlib/string/base/first]: return the first `n` UTF-16 code units of a string. - [`forEachCodePointRight( str, clbk[, thisArg ] )`][@stdlib/string/base/for-each-code-point-right]: invokes a function for each Unicode code point in a string, iterating from right to left. - [`forEachCodePoint( str, clbk[, thisArg ] )`][@stdlib/string/base/for-each-code-point]: invokes a function for each Unicode code point in a string. - [`forEachGraphemeCluster( str, clbk[, thisArg ] )`][@stdlib/string/base/for-each-grapheme-cluster]: invokes a function for each grapheme cluster (i.e., user-perceived character) in a string. - [`forEachRight( str, clbk[, thisArg ] )`][@stdlib/string/base/for-each-right]: invokes a function for each UTF-16 code unit in a string, iterating from right to left. - [`forEach( str, clbk[, thisArg ] )`][@stdlib/string/base/for-each]: invokes a function for each UTF-16 code unit in a string. - [`formatInterpolate( tokens, ...args )`][@stdlib/string/base/format-interpolate]: generate string from a token array by interpolating values. - [`formatTokenize( str )`][@stdlib/string/base/format-tokenize]: tokenize a string into an array of string parts and format identifier objects. - [`headercase( str )`][@stdlib/string/base/headercase]: convert a string to HTTP header case. - [`invcase( str )`][@stdlib/string/base/invcase]: convert a string to inverse case. - [`kebabcase( str )`][@stdlib/string/base/kebabcase]: convert a string to kebab case. - [`lastCodePoint( str, n )`][@stdlib/string/base/last-code-point]: return the last `n` Unicode code points of a string. - [`lastGraphemeCluster( str, n )`][@stdlib/string/base/last-grapheme-cluster]: return the last `n` grapheme clusters (i.e., user-perceived characters) of a string. - [`last( str, n )`][@stdlib/string/base/last]: return the last `n` UTF-16 code units of a string. - [`lpad( str, len, pad )`][@stdlib/string/base/left-pad]: left pad a string. - [`ltrim( str )`][@stdlib/string/base/left-trim]: trim whitespace characters from the beginning of a string. - [`lowercase( str )`][@stdlib/string/base/lowercase]: convert a string to lowercase. - [`pascalcase( str )`][@stdlib/string/base/pascalcase]: convert a string to Pascal case. - [`percentEncode( str )`][@stdlib/string/base/percent-encode]: percent-encode a UTF-16 encoded string according to RFC 3986. - [`removeFirstCodePoint( str, n )`][@stdlib/string/base/remove-first-code-point]: remove the first `n` Unicode code points of a string. - [`removeFirstGraphemeCluster( str, n )`][@stdlib/string/base/remove-first-grapheme-cluster]: remove the first `n` grapheme clusters (i.e., user-perceived characters) of a string. - [`removeFirst( str, n )`][@stdlib/string/base/remove-first]: remove the first `n` UTF-16 code units of a string. - [`removeLastCodePoint( str, n )`][@stdlib/string/base/remove-last-code-point]: remove the last `n` Unicode code points of a string. - [`removeLastGraphemeCluster( str, n )`][@stdlib/string/base/remove-last-grapheme-cluster]: remove the last `n` grapheme clusters (i.e., user-perceived characters) of a string. - [`removeLast( str, n )`][@stdlib/string/base/remove-last]: remove the last `n` UTF-16 code units of a string. - [`repeat( str, n )`][@stdlib/string/base/repeat]: repeat a string a specified number of times and return the concatenated result. - [`replaceAfterLast( str, search, replacement, fromIndex )`][@stdlib/string/base/replace-after-last]: replace the substring after the last occurrence of a specified search string. - [`replaceAfter( str, search, replacement, fromIndex )`][@stdlib/string/base/replace-after]: replace the substring after the first occurrence of a specified search string. - [`replaceBeforeLast( str, search, replacement, fromIndex )`][@stdlib/string/base/replace-before-last]: replace the substring before the last occurrence of a specified search string. - [`replaceBefore( str, search, replacement, fromIndex )`][@stdlib/string/base/replace-before]: replace the substring before the first occurrence of a specified search string. - [`replace( str, search, newval )`][@stdlib/string/base/replace]: replace search occurrences with a replacement string. - [`reverseCodePoints( str )`][@stdlib/string/base/reverse-code-points]: reverse the Unicode code points of a string. - [`reverseGraphemeClusters( str )`][@stdlib/string/base/reverse-grapheme-clusters]: reverse the grapheme clusters (i.e., user-perceived characters) of a string. - [`reverse( str )`][@stdlib/string/base/reverse]: reverse the UTF-16 code units of a string. - [`rpad( str, len, pad )`][@stdlib/string/base/right-pad]: right pad a string. - [`rtrim( str )`][@stdlib/string/base/right-trim]: trim whitespace characters from the end of a string. - [`snakecase( str )`][@stdlib/string/base/snakecase]: convert a string to snake case. - [`startcase( str )`][@stdlib/string/base/startcase]: capitalize the first letter of each word in a string. - [`startsWith( str, search, position )`][@stdlib/string/base/starts-with]: test if a string starts with the characters of another string. - [`stickycase( str[, p] )`][@stdlib/string/base/stickycase]: convert a string to sticky case. - [`trim( str )`][@stdlib/string/base/trim]: trim whitespace characters from the beginning and end of a string. - [`truncateMiddle( str, len, seq )`][@stdlib/string/base/truncate-middle]: truncate the middle UTF-16 code units of a string to return a string having a specified length. - [`uncapitalize( str )`][@stdlib/string/base/uncapitalize]: uncapitalize the first character of a string. - [`uppercase( str )`][@stdlib/string/base/uppercase]: convert a string to uppercase.
## Examples ```javascript 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][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][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 25
Last Year
  • Push event: 25

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 88
  • Total Committers: 2
  • Avg Commits per committer: 44.0
  • Development Distribution Score (DDS): 0.148
Past Year
  • Commits: 50
  • Committers: 2
  • Avg Commits per committer: 25.0
  • Development Distribution Score (DDS): 0.26
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 75
Philipp Burckhardt p****t@o****m 13
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 5 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 0
  • Total versions: 8
  • Total maintainers: 4
npmjs.org: @stdlib/string-base

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

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.2.1
    published almost 2 years ago
  • Versions: 8
  • Dependent Packages: 2
  • Dependent Repositories: 0
  • Downloads: 5 Last month
Rankings
Dependent packages count: 9.5%
Stargazers count: 19.4%
Forks count: 20.5%
Average: 24.1%
Dependent repos count: 25.3%
Downloads: 45.7%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 6 months ago

Dependencies

package.json npm
  • @stdlib/assert-is-array ^0.0.x development
  • @stdlib/assert-is-boolean ^0.0.x development
  • @stdlib/assert-is-nonnegative-integer ^0.0.x development
  • @stdlib/assert-is-string ^0.0.x development
  • @stdlib/bench ^0.0.x development
  • @stdlib/constants-float64-ninf ^0.0.x development
  • @stdlib/constants-float64-pi ^0.0.x development
  • @stdlib/constants-float64-pinf ^0.0.x development
  • @stdlib/constants-unicode-max ^0.0.x development
  • @stdlib/math-base-special-ceil ^0.0.x development
  • @stdlib/random-base-discrete-uniform ^0.0.x development
  • @stdlib/regexp-whitespace ^0.0.x development
  • @stdlib/string-from-code-point ^0.0.x development
  • @stdlib/string-utf16-to-utf8-array ^0.0.x development
  • @stdlib/utils-keys ^0.0.x development
  • istanbul ^0.4.1 development
  • proxyquire ^2.0.0 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/string-base-camelcase ^0.0.x
  • @stdlib/string-base-capitalize ^0.0.x
  • @stdlib/string-base-code-point-at ^0.0.x
  • @stdlib/string-base-constantcase ^0.0.x
  • @stdlib/string-base-ends-with ^0.0.x
  • @stdlib/string-base-format-interpolate ^0.0.x
  • @stdlib/string-base-format-tokenize ^0.0.x
  • @stdlib/string-base-kebabcase ^0.0.x
  • @stdlib/string-base-left-pad ^0.0.x
  • @stdlib/string-base-left-trim ^0.0.x
  • @stdlib/string-base-lowercase ^0.0.x
  • @stdlib/string-base-pascalcase ^0.0.x
  • @stdlib/string-base-percent-encode ^0.0.x
  • @stdlib/string-base-repeat ^0.0.x
  • @stdlib/string-base-replace ^0.0.x
  • @stdlib/string-base-right-trim ^0.0.x
  • @stdlib/string-base-snakecase ^0.0.x
  • @stdlib/string-base-startcase ^0.0.x
  • @stdlib/string-base-starts-with ^0.0.x
  • @stdlib/string-base-trim ^0.0.x
  • @stdlib/string-base-uncapitalize ^0.0.x
  • @stdlib/string-base-uppercase ^0.0.x
  • @stdlib/utils-define-read-only-property ^0.0.x
.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite