當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。