How to use decamelize - 10 common examples

To help you get started, we’ve selected a few decamelize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / decamelize_v1.x.x / test_decamelize_v1.x.x.js View on Github external
import decamelize from 'decamelize';

const a: string = decamelize('unicornRainbow');
//=> 'unicorn_rainbow'

const b: string = decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'

// $ExpectError
decamelize(42);

// $ExpectError
(decamelize('unicornRainbow'): number);
github flow-typed / flow-typed / definitions / npm / decamelize_v1.x.x / test_decamelize_v1.x.x.js View on Github external
import decamelize from 'decamelize';

const a: string = decamelize('unicornRainbow');
//=> 'unicorn_rainbow'

const b: string = decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'

// $ExpectError
decamelize(42);

// $ExpectError
(decamelize('unicornRainbow'): number);
github youzan / vant / packages / vant-cli / site / desktop / router.js View on Github external
function parseName(name) {
  if (name.indexOf('_') !== -1) {
    const pairs = name.split('_');
    const component = pairs.shift();

    return {
      component: `${decamelize(component, '-')}`,
      lang: pairs.join('-')
    };
  }

  return {
    component: `${decamelize(name, '-')}`,
    lang: ''
  };
}
github youzan / vant / packages / vant-cli / site / desktop / router.js View on Github external
function parseName(name) {
  if (name.indexOf('_') !== -1) {
    const pairs = name.split('_');
    const component = pairs.shift();

    return {
      component: `${decamelize(component, '-')}`,
      lang: pairs.join('-')
    };
  }

  return {
    component: `${decamelize(name, '-')}`,
    lang: ''
  };
}
github shoutem / cli / src / templates / settings-page-html / template-init.js View on Github external
export async function before(context) {
  const { extJson, name, extensionScope } = context;
  const pages = getOrSet(extJson, 'pages', []);

  if (!_.every(pages, isHtmlPage)) {
    throw new Error("Html pages can't be mixed with non-html settings pages in the same extension");
  }

  if (_.find(pages, { name })) {
    throw new Error(`Page ${name} already exists`);
  }

  const pageName = name;
  const pageDirectoryName = decamelize(name, '-');
  _.merge(context, { pageName, pageDirectoryName });

  pages.push({
    name: pageName,
    path: `server/pages/${pageDirectoryName}/index.html`,
    type: 'html'
  });

  if (extensionScope) {
    await instantiateExtensionTemplate('settings-page-html-extension', context)
  } else {
    await instantiateExtensionTemplate('settings-page-html-shortcut', context);
  }
}
github youzan / vant / packages / vant-cli / site / mobile / router.js View on Github external
names.forEach(name => {
    const component = decamelize(name, '-');

    if (langs.length) {
      langs.forEach(lang => {
        routes.push({
          name: `${lang}/${component}`,
          path: `/${lang}/${component}`,
          component: demos[name],
          meta: {
            name,
            lang
          }
        });
      });
    } else {
      routes.push({
        name,
github react-icons / react-icons / docs / components / IconPack.js View on Github external
{Object.keys(pack.icons).map((iconName, index) => {
                        let Icon = pack.icons[iconName];
                        let realIconName = decamelize(iconName.replace(new RegExp('^'+prefixUp), ''), '-')
                        return (
                            <div>
                                
                                <div>{iconName}</div>
                                <div style="{{fontSize:">
                                    <code>{`react-icons/lib/${prefix}/${realIconName}`}</code>
                                </div>
                            </div>
                        );
                    })}
github staeco / iris-ql / src / types / functions.js View on Github external
const parts = Object.keys(partsToDB).map((k) => ({
  value: k,
  label: capitalize.words(decamelize(k, ' '))
}))
github shoutem / cli / src / services / page.js View on Github external
    default: ({ name }) => _.upperFirst(decamelize(name, ' ')),
    message: 'Settings page title:',
github lbryio / lbry.tech / app / components / markdown.js View on Github external
function partialFinder(markdownBody) {
  const regexToFindPartials = /&lt;\w+ ?\/&gt;/g;
  const partials = markdownBody.match(regexToFindPartials);

  if (partials) {
    for (const partial of partials) {
      const filename = decamelize(partial, "-").replace("&lt;", "")
        .replace("/&gt;", "")
        .trim();
      const fileExistsTest = exists(`./app/components/${filename}.js`);

      if (!fileExistsTest)
        markdownBody = markdownBody.replace(partial, "");

      else {
        const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`));

        if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction.default);
        else markdownBody = markdownBody.replace(partial, `${partialFunction.default()}<div class="page__markup">`);
      }
    }
  }
</div>

decamelize

Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis

Popular decamelize functions