How to use the pluralize.isPlural function in pluralize

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 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 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 dotansimha / graphql-code-generator / packages / plugins / java / apollo-android / src / operation-visitor.ts View on Github external
for (const selection of selections) {
      if (selection.kind === Kind.FIELD) {
        this._imports.add(Imports.ResponseField);
        const field = fields[selection.name.value];
        const isObject = selection.selectionSet && selection.selectionSet.selections && selection.selectionSet.selections.length > 0;
        const isNonNull = isNonNullType(field.type);
        const fieldAnnotation = isNonNull ? 'Nonnull' : 'Nullable';
        this._imports.add(Imports[fieldAnnotation]);
        const baseType = getBaseType(field.type);
        const isList = isListType(field.type) || (isNonNullType(field.type) && isListType(field.type.ofType));

        if (isObject) {
          let childClsName = this.convertName(field.name);

          if (isList && isPlural(childClsName)) {
            childClsName = singular(childClsName);
          }

          this.transformSelectionSet(
            {
              className: childClsName,
              result: options.result,
              selectionSet: selection.selectionSet.selections,
              schemaType: baseType as GraphQLObjectType,
            },
            false
          );

          childFields.push({
            rawType: field.type,
            isObject: true,
github HeskeyBaozi / umi-plugin-mobx / lib / index.js View on Github external
function transformWord(word, toSingular) {
    if (pluralize.isPlural(word)) {
        return toSingular ? pluralize.singular(word) : word;
    }
    else {
        return toSingular ? word : pluralize.plural(word);
    }
}
function optsToArray(item) {
github HeskeyBaozi / umi-plugin-mobx / src / utils / helpers.ts View on Github external
export function transformWord(word: string, toSingular: boolean) {
  if (isPlural(word)) {
    return toSingular ? singular(word) : word;
  } else {
    return toSingular ? word : plural(word);
  }
}
github infinitered / gluegun / src / toolbox / string-tools.ts View on Github external
pluralize.isPlural = (word: string) => require('pluralize').isPlural(word)
pluralize.isSingular = (word: string) => require('pluralize').isSingular(word)