當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.getName函數代碼示例

本文整理匯總了TypeScript中@ember/-internals/utils.getName函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getName函數的具體用法?TypeScript getName怎麽用?TypeScript getName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getName函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: calculateToString

function calculateToString(target: object): string {
  let str;

  if (!searchDisabled) {
    processAllNamespaces();

    str = getName(target);
    if (str !== void 0) {
      return str;
    }
    let superclass = target;
    do {
      superclass = Object.getPrototypeOf(superclass);
      if (superclass === Function.prototype || superclass === Object.prototype) {
        break;
      }
      str = getName(target);
      if (str !== void 0) {
        str = `(subclass of ${str})`;
        break;
      }
    } while (str === void 0);
  }
  return str || '(unknown)';
}
開發者ID:cibernox,項目名稱:ember.js,代碼行數:25,代碼來源:namespace_search.ts

示例2: removeNamespace

export function removeNamespace(namespace: Namespace): void {
  let name = getName(namespace) as string;
  delete NAMESPACES_BY_ID[name];
  NAMESPACES.splice(NAMESPACES.indexOf(namespace), 1);
  if (name in context.lookup && namespace === context.lookup[name]) {
    context.lookup[name] = undefined;
  }
}
開發者ID:cibernox,項目名稱:ember.js,代碼行數:8,代碼來源:namespace_search.ts

示例3: classToString

export function classToString(this: object): string {
  let name = getName(this);
  if (name !== void 0) {
    return name;
  }
  name = calculateToString(this);
  setName(this, name);
  return name;
}
開發者ID:cibernox,項目名稱:ember.js,代碼行數:9,代碼來源:namespace_search.ts

示例4: _processNamespace

function _processNamespace(paths: string[], root: Namespace, seen: Set<Namespace>): void {
  let idx = paths.length;

  let id = paths.join('.');

  NAMESPACES_BY_ID[id] = root;
  setName(root, id);

  // Loop over all of the keys in the namespace, looking for classes
  for (let key in root) {
    if (!hasOwnProperty.call(root, key)) {
      continue;
    }
    let obj = root[key];

    // If we are processing the `Ember` namespace, for example, the
    // `paths` will start with `["Ember"]`. Every iteration through
    // the loop will update the **second** element of this list with
    // the key, so processing `Ember.View` will make the Array
    // `['Ember', 'View']`.
    paths[idx] = key;

    // If we have found an unprocessed class
    if (obj && obj.toString === classToString && getName(obj) === void 0) {
      // Replace the class' `toString` with the dot-separated path
      setName(obj, paths.join('.'));
      // Support nested namespaces
    } else if (obj && obj.isNamespace) {
      // Skip aliased namespaces
      if (seen.has(obj)) {
        continue;
      }
      seen.add(obj);
      // Process the child namespace
      _processNamespace(paths, obj, seen);
    }
  }

  paths.length = idx; // cut out last item
}
開發者ID:cibernox,項目名稱:ember.js,代碼行數:40,代碼來源:namespace_search.ts


注:本文中的@ember/-internals/utils.getName函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。