Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
to-snake-case
Advanced tools
The 'to-snake-case' npm package is a utility that converts strings to snake_case format. This is particularly useful for formatting strings in a consistent manner, especially when dealing with identifiers in programming languages or databases that prefer snake_case.
Convert camelCase to snake_case
This feature converts a camelCase string to snake_case. For example, 'camelCaseString' becomes 'camel_case_string'.
const toSnakeCase = require('to-snake-case');
const result = toSnakeCase('camelCaseString');
console.log(result); // Outputs: camel_case_string
Convert PascalCase to snake_case
This feature converts a PascalCase string to snake_case. For example, 'PascalCaseString' becomes 'pascal_case_string'.
const toSnakeCase = require('to-snake-case');
const result = toSnakeCase('PascalCaseString');
console.log(result); // Outputs: pascal_case_string
Convert space-separated string to snake_case
This feature converts a space-separated string to snake_case. For example, 'space separated string' becomes 'space_separated_string'.
const toSnakeCase = require('to-snake-case');
const result = toSnakeCase('space separated string');
console.log(result); // Outputs: space_separated_string
Convert hyphen-separated string to snake_case
This feature converts a hyphen-separated string to snake_case. For example, 'hyphen-separated-string' becomes 'hyphen_separated_string'.
const toSnakeCase = require('to-snake-case');
const result = toSnakeCase('hyphen-separated-string');
console.log(result); // Outputs: hyphen_separated_string
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It includes a function `_.snakeCase` that converts strings to snake_case. Compared to 'to-snake-case', Lodash offers a broader range of utility functions beyond just string case conversion.
The 'change-case' package provides a collection of functions for changing the case of strings, including snake_case. It is more versatile than 'to-snake-case' as it supports multiple case transformations like camelCase, PascalCase, and more.
The 'case' package is another utility for converting strings between different cases, including snake_case. It is similar to 'to-snake-case' but offers additional case transformations and is designed to be lightweight and easy to use.
Convert a string to a snake case. Part of the series of case helpers.
$ npm install to-snake-case
var snake = require('to-snake-case');
snake('camelCase'); // "camel_case"
snake('space case'); // "snake_case"
snake('dot.case'); // "dot_case"
snake('weird[case'); // "weird_case"
Returns the string
converted to snake case.
The MIT License (MIT)
Copyright © 2016, Ian Storm Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Convert a string to snake case.
The npm package to-snake-case receives a total of 176,640 weekly downloads. As such, to-snake-case popularity was classified as popular.
We found that to-snake-case 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.