Voca is a comprehensive JavaScript library designed for efficient string manipulation, offering a wide array of functions for tasks such as changing case, trimming, padding, slugifying, latinising, formatting (like `sprintf`), truncating, and escaping strings. Currently stable at version 1.4.1, the library maintains a steady release cadence with minor versions introducing new utility functions and improvements. A key differentiator is its modular design, which allows developers to either load the entire library or import individual functions, optimizing application bundle sizes through tree-shaking. It boasts 100% test coverage, comprehensive documentation, and no external dependencies, making it a robust and lightweight solution for string operations across various environments, including Node.js (0.10+), modern browsers (Chrome, Firefox, Safari 7+, Edge 13+, IE 9+), and bundlers like Webpack and Rollup.
npm install vocaVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the entire Voca library and individual functions, then using several string manipulation utilities.
Always use `import functionName from 'voca/functionName';` for specific functions in ES2015 modules, or `const functionName = require('voca/functionName');` in CommonJS.Be explicit about your imports. For ES modules, `import voca from 'voca';` is standard. For CommonJS, `const v = require('voca');` or `const voca = require('voca');` are common, but stick to `v` if mirroring browser usage. For browsers, ensure `voca.js` is loaded to expose the global `v`.Correct the import statement to `import slugify from 'voca/slugify';`
In Node.js, add `const v = require('voca');`. In a browser, ensure `<script src="voca.js"></script>` is present before your script, or `import voca from 'voca'` if using a module bundler.For browser-only usage, load `dist/voca.min.js` via a script tag which exposes a global `v` object. If using a bundler, ensure it's configured to handle CommonJS modules.
No dependency data recorded yet.