1.4.1 • Published 11 months ago

voca v1.4.1

Weekly downloads
54,383
License
MIT
Repository
github
Last release
11 months ago

Voca JavaScript library logo

travis build code coverage npm 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. The modular design allows to load the entire library, or individual functions to minimize the application builds. The library is fully tested, well documented and long-term supported.

Features

  • Provides the complete set of functions to manipulate, chop, format, escape and query strings
  • Includes detailed, easy to read and searchable documentation
  • 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 at https://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:

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

Or require individual functions:

const words = require('voca/words');
const slugify = 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:

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

Or import individual functions:

import last from '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:

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

Then a global variable v is exposed for the entire library:

<script type="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 an issue.
Please make sure that the same problem wasn't reported already.

For general usage questions please ask on StackOverflow.

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 in Contributing guide.

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

Author

Dmitri Pavlutin

| Dmitri Pavlutin | Personal blog | Email

License

Licensed under MIT

@sap-cloud-sdk/util@sap-cloud-sdk/generator@sap-cloud-sdk/coreservice-calendarchili-testquasar-app-extension-pandapoint-api-servicewp-edit-pro-cliug-lobster@tomfrenken/generator@vtangel/quasar-app-extension-panda@nobedtimes/cli@quant_insight/qi-vue-componentslandonschropp.comrduck@everything-registry/sub-chunk-3065@iatelier/sails-hook-epistle@iatelier/sails-hook-iatelier@iatelier/sails-hook-p-epistle@inrupt/generator-solid-react@harmonyjs/query@harmonyjs/adapter-couchbase@harmonyjs/adapter-mongoose@harmonyjs/controller-cloud-health@harmonyjs/persistence@haxball-bot/bot@guys/michael@guys/william@hoaphatnp/utils@hoangbkit/cli@hoangbkit/mongo@jasonsbarr/string@mavensafe/maven-ui@leganux/nucleus@lifespikes/ui@longraces/backend@longraces/cli@longraces/store@humblebee/generator-boilerplate@mwsolutions/mask@msafe/msafe-uilyteuixxlformdesignerxxl@triotech/vue-core@vatelier/sails-hook-atelier@vatelier/sails-hook-vatelier@vatelier/sails-hook-vphcms@omtty/webpack@tamedjs/tm-spawn@shqld/dangerdynamic-cust-form@whcg/x-framework@qorebase/cli@nsidc/search-interface@nsidc/soac-webapp@offcourse/atoms@offcourse/molecules@offcourse/organisms@raycloud-apaas-fe-setup/apaas-demo@sap-cloud-sdk/odata-common@sap/cloud-sdk-core@sap/cloud-sdk-generator@sap-cloud-sdk/generator-common@sannybuilder/utils@kmkf-fe-packages/kmkf-work-order-service-component@jellyware/chassisember-app-explorer@yangzw/bruce-appepuresnode-module-layer@eropple/nestjs-openapi3@translogia/tedi-ewok@wandiparis/troposphere@wavecore/core-node@vph-cms/sails-hook-offprint@vph-cms/sails-hook-vphcms-a@tomfrenken/core@tomfrenken/utilember-voca@dvit/cloudcooking@thetrg/gibson@thetrg/tamed@townvn/cli@timkit/cli@zukame/store@zukame/cloud@zukame/cmd@elliemae/ds-codemods@ziyadsk/csfilename-parseroffcourse-ui-components@fjsolutions/adonis-mongoose@fjsolutions/mongodb-uriexternal-api-util@feedloop/qore-clifultonjs_commongenerator-furkanyilmazxgenerator-convoflowable-componentgenerator-liferay-fragments
1.4.1

11 months ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

1.0.0-beta.2

7 years ago

1.0.0-beta.1

7 years ago

1.0.0-alpha.2

7 years ago

1.0.0-alpha.1

7 years ago

1.0.0-alpha.0

7 years ago

0.0.1

8 years ago