Slang is a lightweight JavaScript library providing a collection of utility functions for common string manipulations, such as capitalization, camel case conversion, dasherization, and pluralization. Originally published over a decade ago (v0.3.0, December 2013), it was designed for use in both browser environments and CommonJS Node.js projects. The library is stable in its functionality but has not seen active development or maintenance since its last release. Key differentiators at the time included its small footprint and a focus on essential string transformations. Due to its age, it primarily uses CommonJS module patterns and lacks native ESM support or TypeScript definitions, making it less suitable for modern, type-safe, or highly modular JavaScript/TypeScript ecosystems without additional tooling or shims.
npm install slangVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the `slang` library using CommonJS and utilize several of its core string utility functions like `capitalize`, `camelize`, `dasherize`, `pluralize`, and `isString`.
Avoid calling `slang.addToPrototype()`. Instead, explicitly call functions via the `slang` object (e.g., `slang.camelize('my-string')`) or destructure individual functions if preferred, ensuring proper scoping.For new projects, consider using a more modern, maintained string utility library with explicit ESM and TypeScript support (e.g., `lodash/string` or `change-case`). If retained, use bundlers like Webpack or Rollup to handle CommonJS imports, and create custom `.d.ts` files for TypeScript support.
If using `import`, ensure you import the default export and then access the function: `import slang from 'slang'; slang.camelize('string');`. If using `require`, assign the result to a variable and access methods: `const slang = require('slang'); slang.camelize('string');`Configure your build tool (e.g., Webpack, Rollup, Vite) to correctly handle CommonJS modules, or use dynamic import `import('slang')` with `await` if suitable. Alternatively, ensure your Node.js environment is configured for CommonJS (`'type': 'commonjs'` in `package.json`) or use a CommonJS wrapper.No dependency data recorded yet.