当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pluralize.singular函数代码示例

本文整理汇总了TypeScript中pluralize.singular函数的典型用法代码示例。如果您正苦于以下问题:TypeScript singular函数的具体用法?TypeScript singular怎么用?TypeScript singular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了singular函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: singularizeLastWord

export function singularizeLastWord(name:string) {
    const parts = getWords(name);
    if (parts.length == 0) {
        return name;
    }
    const lastWord = parts.pop();
    const lastPos = name.lastIndexOf(lastWord);

    return name.substr(0, lastPos) + plural.singular(lastWord) + name.substr(lastPos + lastWord.length);
}
开发者ID:cevek,项目名称:gen-templates,代码行数:10,代码来源:strings.ts

示例2: singular

export const storeReference = (scope: string, identifier: string, store?: Store | string) => {
  if (!store) {
    return singular(identifier);
  }
  else if (typeof(store) === 'string') {
    return store;
  }
  else {
    invariant(store instanceof Store,
      `${scope} - A valid store reference of either a \`String\` or \`Store\` type must be passed, ` +
      `but found type \`${typeof(store)}\`.`
    );
  }

  return store;
};
开发者ID:netarc,项目名称:refrax,代码行数:16,代码来源:tools.ts

示例3: invariant

export const createSchemaCollection = (path: string, options: IKeyValue = {}): SchemaPath => {
  let collectionPath: SchemaPath;
  let memberIdentifier: string;
  let memberId: string;
  let identifier: string;

  invariant(typeof(path) === 'string', `createSchemaCollection: expected string path identifier but found \`${path}\``);
  // tslint:disable-next-line:max-line-length
  invariant(isPlainObject(options), `createSchemaCollection: expected object options identifier but found \`${options}\``);

  path = validatePath('schema/createSchemaCollection', path);
  identifier = options.identifier || cleanIdentifier(path);

  // Collection Node

  collectionPath = createSchemaPath(
    new SchemaNode(IClassification.collection, identifier, extend({
      store: storeReference('schema/createSchemaCollection', identifier, options.store),
      path
    }, options.collection))
  );

  // Member Node

  memberIdentifier = singular(identifier);
  if (memberIdentifier === identifier) {
    memberIdentifier = 'member';
    memberId = identifier + 'Id';
  }
  else {
    memberId = memberIdentifier + 'Id';
  }

  collectionPath.addLeaf(
    new SchemaNode(IClassification.item, memberIdentifier, extend({
      paramId: memberId
    }, options.member))
  );

  return collectionPath;
};
开发者ID:netarc,项目名称:refrax,代码行数:41,代码来源:createSchemaCollection.ts

示例4: singular

export function singular(plural?: string | null) {
  return plural ? pluralize.singular(plural) : plural;
}
开发者ID:philcockfield,项目名称:command-interface,代码行数:3,代码来源:util.pluralize.ts

示例5:

 ...(_.differenceWith(relationFields, relationTableFields, (a, b) => {
   // TODO: Manage this ugly hack if finding relation field in 
   // directive of relation table field 
   // there is also plural to singular hack in this
   return b.directives.join('').indexOf(pluralize.singular(a.name)) > -1
 })),
开发者ID:nunsie,项目名称:prisma,代码行数:6,代码来源:SDLInferrer.ts


注:本文中的pluralize.singular函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。