How to use the inflection.pluralize function in inflection

To help you get started, we’ve selected a few inflection 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 marcioj / ember-cli-scaffold / blueprints / model / index.js View on Github external
locals: function(options) {
    var attrs = [];
    var needs = [];
    var entityOptions = options.entity.options;

    for (var name in entityOptions) {
      var type = entityOptions[name] || '';
      var dasherizedName = stringUtils.dasherize(name);
      var dasherizedNameSingular = inflection.singularize(dasherizedName);
      var camelizedName = stringUtils.camelize(name);
      var dasherizedType = stringUtils.dasherize(type);

      if (/has-many/.test(dasherizedType)) {
        var camelizedNamePlural = inflection.pluralize(camelizedName);
        attrs.push(camelizedNamePlural + ': ' + dsAttr(dasherizedName, dasherizedType));
      } else {
        attrs.push(camelizedName + ': ' + dsAttr(dasherizedName, dasherizedType));
      }

      if (/has-many|belongs-to/.test(dasherizedType)) {
        needs.push("'model:" + dasherizedNameSingular + "'");
      }
    }

    attrs = attrs.join(',' + EOL + '  ');
    needs = '  needs: [' + needs.join(', ') + ']';

    return {
      attrs: attrs,
      needs: needs
github postlight / lux / src / packages / cli / templates / controller.js View on Github external
export default (name: string, attrs: Array): string => {
  let normalized = chain(name)
    .pipe(underscore)
    .pipe(classify)
    .value()

  if (!normalized.endsWith('Application')) {
    normalized = pluralize(normalized)
  }

  const body = entries(
    attrs
      .filter(attr => /^(\w|-)+:(\w|-)+$/g.test(attr))
      .map(attr => attr.split(':')[0])
      .reduce((obj, attr) => ({
        ...obj,
        params: [
          ...obj.params,
          `${indent(8)}'${camelize(underscore(attr), true)}'`
        ]
      }), { params: [] })
  ).reduce((result, group, index) => {
    const [key] = group
    let [, value] = group
github verbose / verb / lib / schema.js View on Github external
function inflections(key) {
  var single = inflect.singularize(key);
  var plural = inflect.pluralize(key);
  return [single, plural].join('|');
}
github denali-js / core / dist / runtime / router-dsl.js View on Github external
resource(resourceName, options = {}) {
      let plural = pluralize(resourceName);

      let collection = '/' + plural;
      let resource = collection + '/:id';
      let relationship = resource + '/relationships/:relation';
      let related = resource + '/:relation';

      if (options.related === false) {
        options.except = [ 'related', 'fetch-related', 'replace-related', 'add-related', 'remove-related' ].concat(options.except);
      }

      let hasWhitelist = Boolean(options.only);
      options.only = ensureArray(options.only);
      options.except = ensureArray(options.except);

      function include(action) {
        let whitelisted = contains(options.only, action);
github pixelhandler / ember-jsonapi-resources / blueprints / jsonapi-service / index.js View on Github external
__resource__: function(options) {
        if (options.pod) {
          return 'service';
        }
        return inflector.pluralize(options.locals.resource);
      },
      __path__: function(options) {
github 1602 / compound / lib / utils.js View on Github external
exports.pluralize = function pluralize(str, plural) {
    return i8n.pluralize(str, plural);
};
github joelcoxokc / slush-y / slushy / Utility / strings / index.js View on Github external
function multi(name){
        var names = {};
        names.single = {};
        names.plural = {};
        names.slug              = _str.slugify(name);
        names.single.slug       =  inflect.singularize(names.slug);
        names.single.camel      =  _str.camelize(names.single.slug);
        names.single.classed    =  _str.classify(names.single.slug);
        names.single.humanized  =  _str.humanize(names.single.slug)
        names.plural.slug       =  inflect.pluralize(names.single.slug);
        names.plural.camel      =  _str.camelize(names.plural.slug);
        names.plural.classed    =  _str.classify(names.plural.slug);
        names.plural.humanized  =  _str.humanize(names.plural.slug);

        return names;
      }
    }
github bvalosek / infusionsoft-api / lib / DataContext.js View on Github external
_addTable: function(T)
    {
        var tName = inflection.pluralize(T.__name__);
        this[tName] = new Queryable(T, this.DataService);
    },
github Azure / BatchExplorer / src / @batch-flask / ui / entity-commands / entity-command.ts View on Github external
public executeMultiple(entities: TEntity[], options: ExecuteOptions = {}) {
        this._trackAction(entities.length);
        if (this.confirm && !options.skipConfirm) {
            if (this.confirm instanceof Function) {
                this.confirm(entities).subscribe((options) => {
                    this._executeMultiple(entities, options);
                });
            } else {
                const type = inflection.pluralize(this.definition.typeName.toLowerCase());
                const label = this.label(entities.first());
                const message = this.i18n.t("entity-command.confirm.multiple.title", {
                    action: label.toLowerCase(),
                    count: entities.length,
                    type,
                });

                this.dialogService.confirm(
                    message,
                    {
                        yes: () => {
                            this._executeMultiple(entities);
                        },
                    });
            }
        } else {
github martijndeh / fire / lib / modules / bridge / generators / models.js View on Github external
propertyNames.forEach(function(propertyName) {
				var property = allProperties[propertyName];

				if(!property.options.isPrivate) {
					if(property.isAssociation()) {
						if(property.options.relationshipVia && (property.options.autoFetch || property.options.relationshipVia.options.autoFetch)) {
							autoFetchedAssociationNames.push('\'' + property.options.relationshipVia.model.getName() + '\'');
						}

						if(property.isManyToMany()) {
							methodMaps.push({
								isXToMany: true,

								pluralMethodName: utils.ucfirst(inflection.pluralize(propertyName)),
								singularMethodName: utils.ucfirst(inflection.singularize(propertyName)),

								resource: inflection.transform(propertyName, ['tableize', 'dasherize']).toLowerCase(),

								propertyName: propertyName,
								modelName: property.options.relationshipVia.model.getName()
							});
						}
						else if(property.options.hasMany) {
							if(!property.options.relationshipVia) {
								throw new Error('Found has many relationship but could not find link. Did you call HasMany-BelongsTo on the correct models?');
							}

							methodMaps.push({
								isXToMany: true,