Detalhes do pacote

varname

rowanmanning194.3kMIT7.1.0

Convert strings between different variable naming formats

camelcase, camelback, naming, string

readme (leia-me)

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

changelog (log de mudanças)

Changelog

7.1.0 (2025-05-21)

Features

7.0.0 (2025-03-04)

⚠ BREAKING CHANGES

  • drop Node.js 18

Miscellaneous Chores

6.2.1 (2024-07-27)

Bug Fixes

  • prevent husky from failing (7e4867a)

6.2.0 (2024-06-23)

Features

6.1.0 (2024-01-30)

Features

  • add official support for npm 10 (5d46792)

6.0.0 (2023-09-11)

⚠ BREAKING CHANGES

  • drop support for Node.js 16

Miscellaneous

  • drop support for Node.js 16 (6362150)

5.0.2 (2023-07-25)

Bug Fixes

  • sort out broken releases

5.0.1 (2023-04-18)

Bug Fixes

  • add support for Node.js 20 (c862c72)

5.0.0 (2023-03-25)

⚠ BREAKING CHANGES

  • drop official support for npm v7
  • drop support for Node.js 14

Miscellaneous

  • drop official support for npm v7 (ac9594a)
  • drop support for Node.js 14 (0696b3a)

4.1.4 (2023-02-14)

Bug Fixes

4.1.3 (2023-01-07)

Bug Fixes

  • bump json5 from 2.2.1 to 2.2.3 (6c073f0)

4.1.2 (2022-11-14)

Bug Fixes

  • improve TypeScript compatibility (041b22f)

4.1.1 (2022-07-09)

Bug Fixes

  • hide the misc changelog section (8f5eaa2)

4.1.0 (2022-06-10)

Features

  • ensure typescript types are always valid (ecf4031)

Miscellaneous

  • bump @commitlint/cli from 17.0.1 to 17.0.2 (f53cc1b)
  • bump @commitlint/config-conventional from 17.0.0 to 17.0.2 (ea0b843)
  • bump @rowanmanning/eslint-config from 3.5.0 to 4.0.2 (eebcbf1)
  • bump eslint from 8.16.0 to 8.17.0 (8330208)
  • fix eslint issues (9c10c74)

4.0.1 (2022-05-25)

Miscellaneous

  • bump @commitlint/cli from 16.2.4 to 17.0.0 (5b3508f)
  • bump @commitlint/cli from 17.0.0 to 17.0.1 (37fa31f)
  • bump @commitlint/config-conventional from 16.2.4 to 17.0.0 (b890405)
  • bump @rowanmanning/eslint-config from 3.4.0 to 3.5.0 (81c6bd2)
  • bump eslint from 8.14.0 to 8.15.0 (69bbbe7)
  • bump eslint from 8.15.0 to 8.16.0 (e3bbf40)
  • bump husky from 7.0.4 to 8.0.1 (dbd4c51)

4.0.0 (2022-05-02)

⚠ BREAKING CHANGES

  • drop support for Node.js versions below 14
  • mocha no longer supports Node.js v12

Documentation Changes

  • manually define changelog sections (1fbdd55)

Miscellaneous

  • bump mocha from 9.2.2 to 10.0.0 (e002adb)
  • drop support for Node.js versions below 14 (897d2ab)
  • overhaul release pipeline (58d34a1)