How to use the humps.depascalize function in humps

To help you get started, we’ve selected a few humps 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 DefinitelyTyped / DefinitelyTyped / humps / humps-tests.ts View on Github external
});

humps.decamelizeKeys(someObject, function (key, convert, options) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});


humps.camelize('hello_world-foo bar');

humps.pascalize('hello_world-foo bar');

humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })

humps.depascalize('helloWorldFooBar');

humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);

humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);

humps.camelizeKeys(someObject, someOptions2);
humps.pascalizeKeys(someObject, someOptions2);
humps.decamelizeKeys(someObject, someOptions2);
humps.depascalizeKeys(someObject, someOptions2);
github SpencerCDixon / redux-cli / src / util / text-helper.js View on Github external
const types = ['default', 'snake', 'pascal', 'camel', 'dashes'];

  if (types.indexOf(casing) === -1) {
    throw new Error(`Casing must be one of: ${types.join(', ')} types`);
  }

  if (casing === 'snake') {
    return depascalize(pascalize(string));
  } else if (casing === 'pascal') {
    return pascalize(string);
  } else if (casing === 'camel') {
    return camelize(string);
  } else if (casing === 'default') {
    return string;
  } else if (casing == 'dashes') {
    return depascalize(string, { separator: '-' });
  }
};
github SpencerCDixon / redux-cli / src / util / text-helper.js View on Github external
export const normalizeCasing = (string, casing) => {
  const types = ['default', 'snake', 'pascal', 'camel', 'dashes'];

  if (types.indexOf(casing) === -1) {
    throw new Error(`Casing must be one of: ${types.join(', ')} types`);
  }

  if (casing === 'snake') {
    return depascalize(pascalize(string));
  } else if (casing === 'pascal') {
    return pascalize(string);
  } else if (casing === 'camel') {
    return camelize(string);
  } else if (casing === 'default') {
    return string;
  } else if (casing == 'dashes') {
    return depascalize(string, { separator: '-' });
  }
};

humps

Underscore-to-camelCase converter (and vice versa) for strings and object keys in JavaScript.

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis