Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

The ultimate JavaScript string library

License

NotificationsYou must be signed in to change notification settings

panzerdp/voca

Repository files navigation

Voca JavaScript library logo

travis buildcode coveragenpm package

Voca is a JavaScript library for manipulating strings.https://vocajs.pages.dev

v.camelCase('bird flight');// => 'birdFlight'v.sprintf('%s costs $%.2f','Tea',1.5);// => 'Tea costs $1.50'v.slugify('What a wonderful world');// => 'what-a-wonderful-world'

The Voca library offers helpful functions to make string manipulations comfortable:change case, trim, pad, slugify,latinise, sprintf'y, truncate, escape and much more. Themodular design allows to load the entire library, orindividual functions to minimize the application builds. The library isfully tested,well documented andlong-term supported.

Features

  • Provides the complete set of functions to manipulate, chop, format, escape and query strings
  • Includes detailed, easy to read and searchabledocumentation
  • Supports a wide range of environments: Node.js 0.10+, Chrome, Firefox, Safari 7+, Edge 13+, IE 9+
  • 100% code coverage
  • No dependencies

Documentation

See the complete documentation athttps://vocajs.pages.dev

Usage

Voca can be used in various environments.

Node.js, Rollup, Webpack, Browserify

Voca JavaScript library supports Node.js, Rollup, Webpack, Browserify

Install the library with npm into your local modules directory:

npm install voca

CommonJS modules

Then in your application require the entire library:

constv=require('voca');v.trim(' Hello World! ');// => 'Hello World'v.sprintf('%d red %s',3,'apples');// => '3 red apples'

Or require individual functions:

constwords=require('voca/words');constslugify=require('voca/slugify');words('welcome to Earth');// => ['welcome', 'to', 'Earth']slugify('caffé latté');// => 'caffe-latte'

ES2015 modules

Voca is compatible with ES2015 modules to import the entire library:

importvocafrom'voca';voca.kebabCase('goodbye blue sky');// => 'goodbye-blue-sky'

Or import individual functions:

importlastfrom'voca/last';last('sun rises',5);// => 'rises'

Browser

Voca JavaScript library supports Chrome, Firefox, Safari, Edge, Internet Explorer

Load the UMD builds directly into browser's web page:

<scriptsrc="voca.js"type="text/javascript"></script>

Then a global variablev is exposed for the entire library:

<scripttype="text/javascript">v.last('wonderful world',5);// => 'world'</script>

Functions

ManipulateQueryChopCaseIndex
v.insertv.endsWithv.charAtv.camelCasev.indexOf
v.latinisev.includesv.codePointAtv.capitalizev.lastIndexOf
v.padv.isAlphav.firstv.decapitalizev.search
v.padLeftv.isAlphaDigitv.graphemeAtv.kebabCaseEscape
v.padRightv.isBlankv.lastv.lowerCasev.escapeHtml
v.repeatv.isDigitv.prunev.snakeCasev.escapeRegExp
v.replacev.isEmptyv.slicev.swapCasev.unescapeHtml
v.replaceAllv.isLowerCasev.substrv.titleCaseStrip
v.reversev.isNumericv.substringv.upperCasev.stripBom
v.reverseGraphemev.isStringv.truncateSplitv.stripTags
v.slugifyv.isUpperCaseCountv.chars
v.splicev.matchesv.countv.codePoints
v.trv.startsWithv.countGraphemesv.graphemes
v.trimFormatv.countSubstringsv.split
v.trimLeftv.sprintfv.countWherev.words
v.trimRightv.vprintfv.countWords
v.wordWrap

Bug reports

For bug reports, documentation typos or feature requests feel free to create anissue.
Please make sure that the same problem wasn't reported already.

For general usage questions please ask onStackOverflow.

Contributing

Contribution is welcome!

  • Create a pull request containing bug fixes or new features. Include unit tests and keep the code coverage report near 100% 😎
  • Propose new functions, improvements, better documentation

See more details inContributing guide.

Please note that this project is released with a ContributorCode of Conduct. By participating in this project you agree to abide by its terms.

Author

Dmitri Pavlutin
Dmitri Pavlutin
Personal blog
Email

License

Licensed underMIT


[8]ページ先頭

©2009-2025 Movatter.jp