Socket
Socket
Sign inDemoInstall

varname

Package Overview
Dependencies
0
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

varname


Version published
Weekly downloads
26K
decreased by-8.07%
Maintainers
0
Install size
7.78 kB
Created
Weekly downloads
 

Changelog

Source

6.2.0 (2024-06-23)

Features

  • add Node.js 22 support (05d540a)

Readme

Source

Varname

Convert strings between different variable naming formats.

Table of Contents

Requirements

This library requires the following to run:

Usage

Install with npm:

npm install varname

Load the library into your code with a require call:

const varname = require('varname');

varname.camelback( name )

Convert a variable name to camelBack format (capitalize the first letter of all but the first word).
name: (string) The variable name to convert.
return: (string) Returns the converted variable name.

varname.camelback('foo_bar_baz'); // 'fooBarBaz'

varname.camelcase( name )

Convert a variable name to CamelCase format (capitalize the first letter of each word).
name: (string) The variable name to convert.
return: (string) Returns the converted variable name.

varname.camelcase('foo_bar_baz'); // 'FooBarBaz'

varname.dash( name )

Convert a variable name to dash format.
name: (string) The variable name to convert.
return: (string) Returns the converted variable name.

varname.dash('FooBarBaz'); // 'foo-bar-baz'

varname.underscore( name )

Convert a variable name to underscore format.
name: (string) The variable name to convert.
return: (string) Returns the converted variable name.

varname.underscore('FooBarBaz'); // 'foo_bar_baz'

varname.split( name )

Split a string into separate variable parts. This allows you to write your own format converters easily. name: (string) The variable name to split.
return: (array) Returns an array of parts.

varname.split('fooBarBaz');
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']

Contributing

The contributing guide is available here. All contributors must follow this library's code of conduct.

License

Licensed under the MIT license.
Copyright © 2015, Rowan Manning

Keywords

FAQs

Last updated on 23 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc