Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Convert a camelcase or space-separated string to a dash-separated string. ~12 sloc, fast, supports diacritics.
The dashify npm package is a utility that converts a string with spaces or camelCase into a dash-separated string. This is particularly useful for creating URL slugs, CSS class names, or other identifiers that require a specific format.
Convert camelCase to dash-case
This feature allows you to convert a camelCase string into a dash-separated string. This is useful for transforming variable names or other identifiers into a format suitable for URLs or CSS class names.
const dashify = require('dashify');
const result = dashify('camelCaseString');
console.log(result); // Output: camel-case-string
Convert space-separated string to dash-case
This feature allows you to convert a space-separated string into a dash-separated string. This is useful for creating URL slugs or other identifiers from user input or other sources.
const dashify = require('dashify');
const result = dashify('space separated string');
console.log(result); // Output: space-separated-string
Convert mixed case and space-separated string to dash-case
This feature allows you to convert a string that contains both camelCase and spaces into a dash-separated string. This is useful for normalizing various types of input into a consistent format.
const dashify = require('dashify');
const result = dashify('MixedCase and space separated');
console.log(result); // Output: mixed-case-and-space-separated
The slugify package converts strings into URL-friendly slugs. It offers more customization options compared to dashify, such as handling special characters and providing options for different separator characters.
The kebab-case package converts camelCase or space-separated strings into kebab-case (dash-separated) strings. It is similar to dashify but focuses specifically on converting to kebab-case.
The lodash.kebabcase function from the lodash library converts strings to kebab-case. It is part of the larger lodash utility library, which offers a wide range of functions for manipulating and working with data.
Convert a camelcase or space-separated string to a dash-separated string. ~12 sloc, fast, supports diacritics.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save dashify
Most slugify libs cover way too many corner cases and are bloated and slow as a result. I made this as a fast and light alternative (it even supports diacritics in ~12 sloc).
var dashify = require('dashify');
console.log(dashify('fooBar'));
//=> 'foo-bar'
console.log(dashify('fooBarBaz'));
//=> 'foo-bar-baz'
console.log(dashify('foo bar'));
//=> 'foo-bar'
console.log(dashify('foo barBaz'));
//=> 'foo-bar-baz'
console.log(dashify('foo barBaz quux'));
//=> 'foo-bar-baz-quux'
console.log(dashify('São Tomé and Príncipe'));
//=> 'são-tomé-and-príncipe'
Type: boolean
Default: undefined
Condense multiple consecutive dashes to one.
console.log(dashify('Foo----Bar'));
//=> 'foo----bar'
console.log(dashify('Foo----Bar', {condense: true}));
//=> 'foo-bar'
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Other awesome string libs you might like:
Commits | Contributor |
---|---|
23 | jonschlinkert |
1 | der-On |
1 | jeffreypriebe |
Jon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on November 19, 2018.
FAQs
Convert a camelcase or space-separated string to a dash-separated string. ~12 sloc, fast, supports diacritics.
The npm package dashify receives a total of 468,108 weekly downloads. As such, dashify popularity was classified as popular.
We found that dashify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.