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


TypeScript utils.isNil方法代碼示例

本文整理匯總了TypeScript中@nestjs/common/utils/shared.utils.isNil方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript utils.isNil方法的具體用法?TypeScript utils.isNil怎麽用?TypeScript utils.isNil使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@nestjs/common/utils/shared.utils的用法示例。


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

示例1: isNil

  public async resolveConstructorParams<T>(
    wrapper: InstanceWrapper<T>,
    module: Module,
    inject: any[],
    callback: (args) => void,
  ) {
    let isResolved = true;
    const args = isNil(inject)
      ? this.reflectConstructorParams(wrapper.metatype)
      : inject;

    const instances = await Promise.all(
      args.map(async (param, index) => {
        const paramWrapper = await this.resolveSingleParam<T>(
          wrapper,
          param,
          { index, length: args.length },
          module,
        );
        if (!paramWrapper.isResolved && !paramWrapper.forwardRef) {
          isResolved = false;
        }
        return paramWrapper.instance;
      }),
    );
    isResolved && (await callback(instances));
  }
開發者ID:a1r0,項目名稱:nest,代碼行數:27,代碼來源:injector.ts

示例2: _throw

 public send<TResult = any, TInput = any>(
   pattern: any,
   data: TInput,
 ): Observable<TResult> {
   if (isNil(pattern) || isNil(data)) {
     return _throw(new InvalidMessageException());
   }
   return defer(async () => await this.connect()).pipe(
     mergeMap(
       () =>
         new Observable((observer: Observer<TResult>) => {
           const callback = this.createObserver(observer);
           return this.publish({ pattern, data }, callback);
         }),
     ),
   );
 }
開發者ID:a1r0,項目名稱:nest,代碼行數:17,代碼來源:client-proxy.ts

示例3: isNil

  public async resolveConstructorParams<T>(
    wrapper: InstanceWrapper<T>,
    module: Module,
    inject: InjectorDependency[],
    callback: (args) => void,
  ) {
    let isResolved = true;

    const dependencies = isNil(inject)
      ? this.reflectConstructorParams(wrapper.metatype)
      : inject;
    const optionalDependenciesIds = isNil(inject)
      ? this.reflectOptionalParams(wrapper.metatype)
      : [];

    const instances = await Promise.all(
      dependencies.map(async (param, index) => {
        try {
          const paramWrapper = await this.resolveSingleParam<T>(
            wrapper,
            param,
            { index, dependencies },
            module,
          );
          if (!paramWrapper.isResolved && !paramWrapper.forwardRef) {
            isResolved = false;
          }
          return paramWrapper.instance;
        } catch (err) {
          const isOptional = optionalDependenciesIds.includes(index);
          if (!isOptional) {
            throw err;
          }
          return null;
        }
      }),
    );
    isResolved && (await callback(instances));
  }
開發者ID:timokae,項目名稱:nest,代碼行數:39,代碼來源:injector.ts

示例4: UnknownDependenciesException

 public async lookupComponentInExports<T = any>(
   dependencyContext: InjectorDependencyContext,
   module: Module,
   wrapper: InstanceWrapper<T>,
 ) {
   const instanceWrapper = await this.lookupComponentInRelatedModules(
     module,
     dependencyContext.name,
   );
   if (isNil(instanceWrapper)) {
     throw new UnknownDependenciesException(wrapper.name, dependencyContext, module);
   }
   return instanceWrapper;
 }
開發者ID:SARAVANA1501,項目名稱:nest,代碼行數:14,代碼來源:injector.ts

示例5:

  public loadPrototypeOfInstance<T>(
    { metatype, name }: InstanceWrapper<T>,
    collection: Map<string, InstanceWrapper<T>>,
  ) {
    if (!collection) return null;

    const target = collection.get(name);
    if (target.isResolved || !isNil(target.inject) || !metatype.prototype)
      return null;

    collection.set(name, {
      ...collection.get(name),
      instance: Object.create(metatype.prototype),
    });
  }
開發者ID:a1r0,項目名稱:nest,代碼行數:15,代碼來源:injector.ts

示例6: UnknownDependenciesException

 public async lookupComponentInExports<T = any>(
   components: Map<string, any>,
   { name, index, length }: { name: any; index: number; length: number },
   module: Module,
   wrapper: InstanceWrapper<T>,
 ) {
   const instanceWrapper = await this.lookupComponentInRelatedModules(
     module,
     name,
   );
   if (isNil(instanceWrapper)) {
     throw new UnknownDependenciesException(wrapper.name, index, length);
   }
   return instanceWrapper;
 }
開發者ID:a1r0,項目名稱:nest,代碼行數:15,代碼來源:injector.ts

示例7: metatype

 async instances => {
   if (isNil(inject)) {
     currentMetatype.instance = Object.assign(
       currentMetatype.instance,
       new metatype(...instances),
     );
   } else {
     const factoryResult = currentMetatype.metatype(...instances);
     currentMetatype.instance = await this.resolveFactoryInstance(
       factoryResult,
     );
   }
   currentMetatype.isResolved = true;
   done();
 },
開發者ID:a1r0,項目名稱:nest,代碼行數:15,代碼來源:injector.ts

示例8:

export const UNKNOWN_DEPENDENCIES_MESSAGE = (
  type: string,
  unknownDependencyContext: InjectorDependencyContext,
  module: Module,
) => {
  const { index, dependencies, key } = unknownDependencyContext;
  let message = `Nest can't resolve dependencies of the ${type}`;

  if (isNil(index)) {
    message += `. Please make sure that the "${key}" property is available in the current context.`;
    return message;
  }
  const dependenciesName = (dependencies || []).map(getDependencyName);
  dependenciesName[index] = '?';

  message += ` (`;
  message += dependenciesName.join(', ');
  message += `). Please make sure that the argument at index [${index}] is available in the ${getModuleName(module)} context.`;
  return message;
};
開發者ID:SARAVANA1501,項目名稱:nest,代碼行數:20,代碼來源:messages.ts

示例9: metatype

 public async instantiateClass<T = any>(
   instances: any[],
   wrapper: InstanceWrapper<any>,
   targetMetatype: InstanceWrapper<any>,
 ): Promise<T> {
   const { metatype, inject } = wrapper;
   if (isNil(inject)) {
     targetMetatype.instance = Object.assign(
       targetMetatype.instance,
       new metatype(...instances),
     );
   } else {
     const factoryResult = ((targetMetatype.metatype as any) as Function)(
       ...instances,
     );
     targetMetatype.instance = await factoryResult;
   }
   targetMetatype.isResolved = true;
   return targetMetatype.instance;
 }
開發者ID:SARAVANA1501,項目名稱:nest,代碼行數:20,代碼來源:injector.ts

示例10: return

 public async resolveProperties<T>(
   wrapper: InstanceWrapper<T>,
   module: Module,
   inject?: InjectorDependency[],
 ): Promise<PropertyDependency[]> {
   if (!isNil(inject)) {
     return [];
   }
   const properties = this.reflectProperties(wrapper.metatype);
   const instances = await Promise.all(
     properties.map(async (item: PropertyDependency) => {
       try {
         const dependencyContext = {
           key: item.key,
           name: item.name as string,
         };
         const paramWrapper = await this.resolveSingleParam<T>(
           wrapper,
           item.name,
           dependencyContext,
           module,
         );
         return (paramWrapper && paramWrapper.instance) || undefined;
       } catch (err) {
         if (!item.isOptional) {
           throw err;
         }
         return undefined;
       }
     }),
   );
   return properties.map((item: PropertyDependency, index: number) => ({
     ...item,
     instance: instances[index],
   }));
 }
開發者ID:SARAVANA1501,項目名稱:nest,代碼行數:36,代碼來源:injector.ts


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