How to use the paramCase function from change-case

Find comprehensive JavaScript change-case.paramCase code examples handpicked from public code repositorys.

change-case.paramCase is a function that converts a given string into param case (kebab case) format.

75
76
77
78
79
80
81
}));

// Aliases
module.exports.push({
  name: 'dashCase',
  process: changeCase.paramCase
});
fork icon104
star icon143
watch icon21

+ 3 other calls in file

78
79
80
81
82
83
84
85
86
87
 * @param {Object} options Module-Options
 */
function prepareEntry (entry, options) {
  const tags = entry.tags.map((tag) => {
    return Object.assign(tag, {
      name: paramCase(tag.name),
      options: tag.options,
      async: tag.async || false
    });
  });
fork icon6
star icon58
watch icon4

+ 15 other calls in file

How does change-case.paramCase work?

change-case.paramCase is a function provided by the change-case library, which converts a string to param case by replacing spaces and camel casing with hyphens. For example, it would convert "helloWorld" to "hello-world".

11
12
13
14
15
16
17
18
19
20
21
22
23
})


const toDelete = ['readme-md']


const components = readdirSync(resolve(__dirname, './components'))
  .map(item => paramCase(item.replace(/.vue/g, '')))
  .filter(item => !toDelete.includes(item))


const functions = readdirSync(resolve(__dirname, './functions'))
  .map(item => paramCase(item.replace(/.ts/g, '')))
fork icon2
star icon84
watch icon3

+ 9 other calls in file

59
60
61
62
63
64
65
66
67
68
69
}


function format(displayName, type) {
  switch (type) {
    case FORMAT_TYPES.kebabCase:
      return paramCase(displayName)
    case FORMAT_TYPES.lowerCamelCase:
      return lowerCaseFirst(displayName)
    default:
      return pascalCase(displayName)
fork icon0
star icon3
watch icon0

+ 3 other calls in file

Ai Example

1
2
3
4
5
6
7
const changeCase = require("change-case");

const input = "This Is A Sample Input";
const output = changeCase.paramCase(input);

console.log(output);
// Output: this-is-a-sample-input

In this example, we first import the change-case module and assign it to a variable changeCase. We then create a string input that we want to convert to kebab case or param case. We call the changeCase.paramCase function and pass our input string as an argument to it. The function returns the converted string which we store in output. Finally, we log the output to the console which gives us the param case or kebab case version of our input string.

48
49
50
51
52
53
54
55
56
57
function swapVendorStrings() {
    if (typeof argv.vendor === "undefined") {
        argv.vendor = "App";
    }
    let pascalName = pascalCase(argv.vendor);
    let kebabName = paramCase(argv.vendor);
    return src(paths, { base: "./" })
        .pipe(replace('VendorName', pascalName))
        .pipe(replace('vendor-name', kebabName))
        .pipe(dest('./'));
fork icon0
star icon1
watch icon1

+ 35 other calls in file

39
40
41
42
43
44
45
46
47
48
    console.warn('(rollup-plugin-msfs): config.isInteractive not provided, defaulting to false');
    config.isInteractive = false;
}

const processedHtml = html(name, instrumentDir, imports, cssCode, jsCode);
const processedJs = js(name, config.isInteractive, elementName || paramCase(name));

// Write output
fs.mkdirSync(`${outputDir}/${instrumentDir}`, { recursive: true });
fs.writeFileSync(`${outputDir}/${instrumentDir}/template.html`, trim(processedHtml));
fork icon0
star icon1
watch icon1

+ 44 other calls in file

137
138
139
140
141
142
143
144
145
146
  useShortDoctype: 'Replaces the doctype with the short (HTML5) doctype'
};
var mainOptionKeys = Object.keys(mainOptions);
mainOptionKeys.forEach(function(key) {
  var option = mainOptions[key];
  key = '--' + changeCase.paramCase(key);
  if (Array.isArray(option)) {
    var optional = option[1] === parseJSON;
    program.option(key + (optional ? ' [value]' : ' <value>'), option[0], option[1]);
  }
fork icon0
star icon0
watch icon1

3
4
5
6
7
8
9
10
11
12
13
14


function html (h, node) {
  const tagName = getTagName(node.value)
  // transform to kebab-case (useful for PascalCase vue components)
  if (tagName) {
    node.value = node.value.replace(tagName, paramCase(tagName))
  }


  return handlers.html(h, node)
}
fork icon0
star icon0
watch icon0