How to use pluralize - 10 common examples

To help you get started, we’ve selected a few pluralize 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 / pluralize_v1.x.x / test_pluralize_v1.x.x.js View on Github external
// @flow

import pluralize from "pluralize";

(pluralize('word'): string);
pluralize('word', 0);
pluralize('word', 0, true);
pluralize.addIrregularRule('word', 'wordz');

// $ExpectError
pluralize();
// $ExpectError
pluralize.nope;
github flow-typed / flow-typed / definitions / npm / pluralize_v1.x.x / test_pluralize_v1.x.x.js View on Github external
// @flow

import pluralize from "pluralize";

(pluralize('word'): string);
pluralize('word', 0);
pluralize('word', 0, true);
pluralize.addIrregularRule('word', 'wordz');

// $ExpectError
pluralize();
// $ExpectError
pluralize.nope;
github dexteryy / Project-WebCube / packages / redux-source-utils / src / createSource.js View on Github external
//     '[redux-source] The result of query/mutation operation (an object or objects in an array) must have id attrubute',
    //   );
    // }
    const childRoot = {};
    spreadSections.forEach(traverseProp(childRoot));
    let isList = false;
    let dataName = alias ? alias.value : originName;
    if (RE_LIST_SUFFIX.test(dataName)) {
      isList = true;
      dataName = dataName.replace(RE_LIST_SUFFIX, '$1');
      if (alias) {
        alias.value = originName;
      } else {
        name.value = originName;
      }
    } else if (isPlural(dataName)) {
      isList = true;
    }
    const entity = hasId
      ? new schema.Entity(singular(dataName), childRoot, {
          idAttribute,
        })
      : childRoot;
    root[dataName] = isList ? [entity] : entity;
  };
  definitions.forEach(definition => {
github OpenNeuroOrg / openneuro / app / src / scripts / upload / upload.validation-results.issues.jsx View on Github external
) : null
      })

      if (issue.additionalFileCount > 0) {
        subErrors.push(
          <div>
            <span>
              and {issue.additionalFileCount} more{' '}
              {pluralize('files', issue.additionalFileCount)}
            </span>
          </div>,
        )
      }

      // issue panel
      return (
        
          {subErrors}
        
      )
    })
github zeit / now / packages / now-cli / src / commands / list.js View on Github external
if (argv['--all']) {
    await Promise.all(
      deployments.map(async ({ uid, instanceCount }, i) => {
        deployments[i].instances =
          instanceCount > 0 ? await now.listInstances(uid) : [];
      })
    );
  }

  if (host) {
    deployments = deployments.filter(deployment => deployment.url === host);
  }

  stopSpinner();
  log(
    `Fetched ${plural(
      'deployment',
      deployments.length,
      true
    )} under ${chalk.bold(contextName)} ${elapsed(Date.now() - start)}`
  );

  // we don't output the table headers if we have no deployments
  if (!deployments.length) {
    return 0;
  }

  // information to help the user find other deployments or instances
  if (app == null) {
    log(
      `To list more deployments for a project run ${cmd('now ls [project]')}`
    );
github nicoespeon / abracadabra / src / refactorings / convert-for-to-foreach / convert-for-to-foreach.ts View on Github external
createVisitor(selection, (path, accessor, list) => {
      const { body } = path.node;

      const item = t.identifier(singular(getListName(list)));
      const forEachBody = t.isBlockStatement(body)
        ? body
        : t.blockStatement([body]);

      replaceListWithItemIn(forEachBody, list, accessor, item, path.scope);

      // After we replaced, we check if there are remaining accessors.
      const params = isAccessorReferencedIn(forEachBody, accessor)
        ? [item, accessor]
        : [item];

      path.replaceWith(t.forEach(list, params, forEachBody));
    })
  );
github strapi / strapi / packages / strapi-bookshelf / lib / index.js View on Github external
case 'belongsTo':
                loadedModel[name] = function () {
                  return this.belongsTo(global[_.capitalize(details.model)], name);
                };
                break;

              case 'belongsToMany':
                const tableName = _.map(_.sortBy([strapi.models[details.collection].attributes[details.via], details], 'collection'), function (table) {
                  return _.snakeCase(pluralize.plural(table.collection) + ' ' + pluralize.plural(table.via));
                }).join('__');

                const relationship = _.clone(strapi.models[details.collection].attributes[details.via]);

                // Force singular foreign key
                relationship.attribute = pluralize.singular(relationship.collection);
                details.attribute = pluralize.singular(details.collection);

                // Define PK column
                details.column = utils.getPK(model, strapi.models);
                relationship.column = utils.getPK(details.collection, strapi.models);

                // Sometimes the many-to-many relationships
                // is on the same keys on the same models (ex: `friends` key in model `User`)
                if (details.attribute + '_' + details.column === relationship.attribute + '_' + relationship.column) {
                  relationship.attribute = pluralize.singular(details.via);
                }

                loadedModel[name] = function () {
                  return this.belongsToMany(global[_.capitalize(details.collection)], tableName, relationship.attribute + '_' + relationship.column, details.attribute + '_' + details.column);
                };
                break;
github somus / prisma-admin / src / utils.js View on Github external
export const getConnectionQueryName = type =>
	// Check is necessary since prisma pluralizes existing plural words
	isPlural(type.name)
		? `${camelCase(type.name)}esConnection`
		: `${pluralize(camelCase(type.name))}Connection`;
github Jonesus / gatsby-source-directus7 / src / process.js View on Github external
const getNodeTypeNameForCollection = name => {
    let nodeName = name;
    // If the name is plural, use the Pluralize plugin to try make it singular
    // This is to conform to the Gatsby convention of using singular names in their node types
    if (Pluralize.isPlural(nodeName)) {
        nodeName = Pluralize.singular(nodeName);
    }
    // Make the first letter upperace as per Gatsby's convention
    nodeName = nodeName.charAt(0).toUpperCase() + nodeName.slice(1);
    return nodeName;
};
github elementary / houston / src / lib / helpers / lang.js View on Github external
/**
 * lib/helpers/lang.js
 * English language helpers
 *
 * @exports {Function} s - Pluralizes string based on number or length
 */

import _ from 'lodash'
import pluralize from 'pluralize'

// Add some rules for more extensive use
pluralize.addUncountableRule('the')
pluralize.addUncountableRule('in')

 /**
  * S
  * Pluralizes string based on number or length
  *
  * @param {String} string - String to be translated
  * @param {Blob} len - What to base pluralization on
  * @returns {String} - Transformed string
  */
export function s (string, len = 0) {
  if (_.isArray(len)) {
    len = len.length
  }
  if (_.isPlainObject(len)) {
    len = Object.keys(len)