
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Convert strings between different variable naming formats.
Current Version: 1.0.0
Build Status:
Node Support: 0.6, 0.8
Browser Support: Android Browser 2.2–4.2, Firefox 3.6, Firefox 4–17, Google Chrome 14–25, Internet Explorer 6–10, Mobile Safari iOS 3–6, Opera 12.10, Safari 5–6
You can use Varname on the server side with Node.js and npm:
$ npm install varname
On the client side, you can either install Varname through Component:
$ component install rowanmanning/varname
or by simply including varname.js
in your page:
<script src="path/to/lib/varname.js"></script>
In Node.js or using Component, you can include Varname in your script by using require:
var varname = require('varname');
Varname also works with AMD-style module loaders, just specify it as a dependency.
If you're just including with a <script>
, varname
is available as a global variable.
Convert a variable name to camelBack format (capitalize the first letter of all but the first word).
str: (string) The string to convert.
return: (string) Returns the converted string.
varname.camelback('foo_bar_baz'); // 'fooBarBaz'
Convert a variable name to CamelCase format (capitalize the first letter of each word).
str: (string) The string to convert.
return: (string) Returns the converted string.
varname.camelcase('foo_bar_baz'); // 'FooBarBaz'
Convert a variable name to dash format.
str: (string) The string to convert.
return: (string) Returns the converted string.
varname.dash('FooBarBaz'); // 'foo-bar-baz'
Convert a variable name to underscore format.
str: (string) The string to convert.
return: (string) Returns the converted string.
varname.underscore('FooBarBaz'); // 'foo_bar_baz'
Split a string into separate variable parts. This allows you to write your own format converters easily.
str: (string) The string to split.
return: (array) Returns an array of parts.
varname.split('fooBarBaz');
varname.split('FooBarBaz');
varname.split('foo-bar-baz');
varname.split('foo_bar_baz');
varname.split('♥~foo|bar|baz~♥');
// all return ['foo', 'bar', 'baz']
To develop Varname, you'll need to clone the repo and install dependencies with make deps
. If you're on Windows, you'll also need to install Make for Windows.
Once you're set up, you can run the following commands:
$ make deps # Install dependencies
$ make lint # Run JSHint with the correct config
$ make test # Run unit tests in Node
$ make test-server # Run a server for browser unit testing (visit localhost:3000)
When no build target is specified, make will run deps lint test
. This means you can use the following command for brevity:
$ make
Code with lint errors or no/failing tests will not be accepted, please use the build tools outlined above.
Varname is licensed under the MIT license.
FAQs
Convert strings between different variable naming formats
The npm package varname receives a total of 22,644 weekly downloads. As such, varname popularity was classified as popular.
We found that varname demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.