Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
The dasherize npm package is used to convert strings into a dasherized (kebab-case) format. This can be particularly useful for creating URL-friendly strings, CSS class names, or other identifiers that require a consistent, lowercase, hyphen-separated format.
Basic Dasherization
Converts camelCase strings into dasherized format. This is useful for transforming variable names or other identifiers into a more readable and URL-friendly format.
const dasherize = require('dasherize');
console.log(dasherize('helloWorld')); // Output: 'hello-world'
Dasherize with Spaces
Converts strings with spaces into dasherized format. This is useful for transforming titles or phrases into a consistent, URL-friendly format.
const dasherize = require('dasherize');
console.log(dasherize('Hello World')); // Output: 'hello-world'
Dasherize with Underscores
Converts snake_case strings into dasherized format. This is useful for transforming database field names or other identifiers into a more readable and URL-friendly format.
const dasherize = require('dasherize');
console.log(dasherize('hello_world')); // Output: 'hello-world'
The lodash.kebabcase package is a utility function from the Lodash library that converts strings to kebab case. It offers similar functionality to dasherize but is part of the larger Lodash utility library, which provides a wide range of other utility functions.
The change-case package provides a variety of string transformation utilities, including kebab case conversion. It offers more flexibility and additional string transformation options compared to dasherize.
The param-case package is part of the 'no-case' family of packages and is specifically designed to convert strings to param-case (kebab-case). It offers similar functionality to dasherize but is part of a suite of packages that handle different case transformations.
recursively transform key strings to dash-case
var dasherize = require('dasherize');
var obj = {
feeFieFoe: 'fum',
beepBoop: [
{ 'abcXyz': 'mno' },
{ 'fooBar': 'baz' }
]
};
var res = dasherize(obj);
console.log(JSON.stringify(res, null, 2));
output:
{
"fee-fie-foe": "fum",
"beep-boop": [
{
"abc-xyz": "mno"
},
{
"foo-bar": "baz"
}
]
}
var dasherize = require('dasherize')
Convert the key strings in obj
to dash-case recursively.
Convert the string to dash-case.
With npm do:
npm install dasherize
To use in the browser, use browserify.
derives directly from camelize
MIT
FAQs
recursively transform key strings to dash-case
The npm package dasherize receives a total of 329,491 weekly downloads. As such, dasherize popularity was classified as popular.
We found that dasherize 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.