How to use the inflected.singularize function in inflected

To help you get started, we’ve selected a few inflected 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 / inflected / inflected-tests.ts View on Github external
import * as Inflector from "inflected";

Inflector.pluralize("Category");
Inflector.singularize("Categories");
Inflector.camelize("nerd_bar", false);
Inflector.underscore('FooBar')      // => 'foo_bar'
//Inflector.humanize('employee_salary')                   // => 'Employee salary'
//Inflector.humanize('author_id')                         // => 'Author'
Inflector.humanize('author_id', { capitalize: false })  // => 'author'

Inflector.titleize('man from the boondocks')   // => 'Man From The Boondocks'
Inflector.titleize('x-men: the last stand')    // => 'X Men: The Last Stand'
Inflector.titleize('TheManWithoutAPast')       // => 'The Man Without A Past'
Inflector.titleize('raiders_of_the_lost_ark')  // => 'Raiders Of The Lost Ark'

Inflector.tableize('RawScaledScorer')  // => 'raw_scaled_scorers'
Inflector.tableize('egg_and_ham')      // => 'egg_and_hams'
Inflector.tableize('fancyCategory')    // => 'fancy_categories'

Inflector.classify('egg_and_hams')  // => 'EggAndHam'
github thardy / generator-ngbp / module / index.js View on Github external
var modulePath;
        this.projectName = this.config.get('projectName');
        var self = this;
        var capitalModuleName = [];
        // controller name cannot have a dot or dash in it and must be unique in the app
        this.name.split(/[\.-]/).forEach(function (value) {
            capitalModuleName.push(self._.capitalize(value));
        });

        this.capitalModuleName = capitalModuleName.join('');
        this.routeFriendlyName = this.name.replace('.', '-');
        this.camelModuleName = _.camelCase(this.capitalModuleName, false);
        this.resourceInstance = inflector.singularize(this.camelModuleName);
        this.resourceName = this._.capitalize(this.resourceInstance);
        this.kebabModuleName = _.kebabCase(this.name);
        this.singularKebabModuleName = _.kebabCase(inflector.singularize(this.name));

        if (this.isSubmodule) {
            this.lowerModuleName = this.name.toLowerCase().replace('.', '/');
            this.filePrefix = this.name.substr(this.name.lastIndexOf('.') + 1);
            this.path = this.name.replace(/\./g, '/')
            modulePath = path.join('src', this.rootFolder, this.path);

            this.resourceInstance = inflector.singularize(_.camelCase(this._.capitalize(this.filePrefix), false));
            this.resourceName = this._.capitalize(this.resourceInstance);
            this.singularKebabModuleName = _.kebabCase(inflector.singularize(this.filePrefix));

        } else {
            this.lowerModuleName = this.name.toLowerCase();
            this.filePrefix = this.name;
            this.path = this.name;
            modulePath = path.join('src', this.rootFolder, this.name);
github aws-amplify / amplify-cli / packages / amplify-graphql-types-generator / src / swift / helpers.ts View on Github external
structNameForPropertyName(propertyName: string) {
    return pascalCase(Inflector.singularize(propertyName));
  }
github amazon-archives / aws-appsync-codegen / src / swift / helpers.ts View on Github external
structNameForPropertyName(propertyName: string) {
    return pascalCase(Inflector.singularize(propertyName));
  }
github aws-amplify / amplify-cli / packages / amplify-graphql-types-generator / src / scala / naming.js View on Github external
export function caseClassNameForPropertyName(propertyName) {
  return pascalCase(Inflector.singularize(propertyName));
}
github apollographql / apollo-tooling / packages / apollo-codegen-scala / src / naming.ts View on Github external
): GraphQLInputField & Property {
  const name = field.name;
  const unescapedPropertyName = isMetaFieldName(name) ? name : camelCase(name);
  const propertyName = escapeIdentifierIfNeeded(unescapedPropertyName);

  const type = field.type;
  const isList = isListType(type);
  const isOptional = !isNonNullType(type);
  const bareType = getNamedType(type);

  const bareTypeName = isCompositeType(bareType)
    ? join(
        [
          namespace,
          parentTraitName,
          escapeIdentifierIfNeeded(pascalCase(Inflector.singularize(name)))
        ],
        "."
      )
    : undefined;
  const typeName = typeNameFromGraphQLType(
    context,
    type,
    bareTypeName,
    isOptional,
    true
  );
  return {
    ...field,
    propertyName,
    typeName,
    isOptional,
github marmelab / ng-admin-react / app / View / Edit.js View on Github external
const entityName = this.context.router.getCurrentParams().entity;
        const view = this.getView(entityName);
        const dataStore = this.state.data.get('dataStore').first();
        const entry = dataStore.getFirstEntry(view.entity.uniqueId);

        if (!entry) {
            return null;
        }

        return (
            <div>
                

                <div>
                    <h1>{view.title() || 'Edit one ' + Inflector.singularize(entityName)}</h1>
                    <p>{view.description()}</p>
                </div>

                <div id="edit-view">
                    <form>

                        {this.buildFields(view, entry, dataStore)}

                        <div>
                            <div>
                                <button type="submit"><span></span> Save Changes</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
github moltin / js-sdk / src / endpoints / addresses.js View on Github external
Update({ customer, address, body, token = null }) {
    return this.request.send(
      `customers/${customer}/${this.endpoint}/${address}`,
      'PUT',
      { ...body, type: singularize(this.endpoint) },
      token
    )
  }
}
github cowboyd / mirage-server / lib / db.js View on Github external
identityManagerFor(name) {
    return this._identityManagers[singularize(name)] || this._identityManagers.application || IdentityManager;
  }