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


TypeScript core.nameOf函數代碼示例

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


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

示例1: type

 /**
  *
  * @param {any | JSONSchema6TypeName | JSONSchema6TypeName[]} value
  */
 @Enumerable()
 set type(value: any | JSONSchema6TypeName | JSONSchema6TypeName[]) {
   if (value) {
     this._refName = nameOf(value);
     this._type = JsonSchema.getJsonType(value);
   } else {
     delete this._refName;
     delete this._type;
   }
 }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:14,代碼來源:JsonSchema.ts

示例2: nameOf

export function createModel<T>(
  target: any,
  schema: mongoose.Schema,
  name: string = nameOf(target),
  collection?: string,
  skipInit?: boolean
): MongooseModel<T> {
  Store.from(target).set(MONGOOSE_MODEL_NAME, name);

  return mongoose.model(name, schema, collection, skipInit);
}
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:11,代碼來源:createModel.ts

示例3: expect

const runValidation = (obj: any, targetType: any, collectionType?: any): Chai.Assertion => {
  try {
    const result = ajvService.validate(obj, targetType, collectionType);

    return expect(result);
  } catch (err) {
    if (err.name === "AJV_VALIDATION_ERROR") {
      const message = "" + new ParseExpressionError(nameOf(targetType), undefined, err);

      return expect(message.split("\n")[1]);
    }

    return expect("" + err);
  }
};
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:15,代碼來源:ajv.spec.ts

示例4: return

    return (request: any, response: any, next: any) => {
      const debug = injector.settings.debug;
      /* istanbul ignore else */
      if (debug) {
        request.log.debug({
          event: "bind.request",
          target: nameOf(endpoint.target),
          methodClass: endpoint.methodClassName,
          httpMethod: request.method
        });
      }

      request.ctx.endpoint = endpoint;

      next();
    };
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:16,代碼來源:EndpointBuilder.ts

示例5: constructor

  constructor(target: Type<any>, propertyName: string | symbol) {
    super(RequiredPropertyError.buildMessage(target, propertyName));

    this.errors = [
      {
        dataPath: "",
        keyword: "required",
        message: `should have required property '${String(propertyName)}'`,
        modelName: nameOf(target),
        params: {
          missingProperty: propertyName
        },
        schemaPath: "#/required"
      }
    ];
  }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:16,代碼來源:RequiredPropertyError.ts

示例6: from

  /**
   *
   * @param obj
   * @returns {HandlerBuilder}
   */
  static from(obj: any | EndpointMetadata) {
    return {
      build(injector: InjectorService) {
        const handlerMetadata = HandlerBuilder.resolve(obj, injector);

        if (handlerMetadata.type === HandlerType.FUNCTION) {
          injector.logger.debug("Return handler as function", handlerMetadata.handler.name);

          return handlerMetadata.handler;
        }

        injector.logger.debug("Build handler", `${nameOf(handlerMetadata.target)}.${handlerMetadata.method}()`);

        return new HandlerBuilder(handlerMetadata).build(injector);
      }
    };
  }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:22,代碼來源:HandlerBuilder.ts

示例7: log

  /**
   *
   * @param {Express.Request} request
   * @param o
   * @returns {string}
   */
  private log(request: Express.Request, o: any = {}) {
    if (request.log && this.debug) {
      const {target, injectable, method} = this.handlerMetadata;

      request.log.debug(
        {
          type: this.handlerMetadata.type,
          target: (target ? nameOf(target) : target.name) || "anonymous",
          methodName: method,
          injectable,
          data: request.ctx.data,
          ...o
        },
        false
      );
    }
  }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:23,代碼來源:HandlerBuilder.ts

示例8: getHandler

  /**
   *
   */
  private getHandler(locals: Map<string | Function, any>): Function {
    const {token, method} = this.handlerMetadata;
    const provider = this.injector.getProvider(token);

    /* istanbul ignore next */
    if (!provider) {
      throw new Error(`${nameOf(token)} component not found in the injector`);
    }

    let instance: any;

    if (provider.scope !== ProviderScope.SINGLETON) {
      instance = this.injector.invoke<any>(provider.useClass, locals, undefined, true);
      locals.set(token, instance);
    } else {
      instance = this.injector.get<any>(token);
    }

    return instance[method!].bind(instance);
  }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:23,代碼來源:HandlerBuilder.ts

示例9: buildMessage

 /**
  *
  * @returns {string}
  */
 static buildMessage(target: Type<any> | string, method: string, err: Error) {
   return `Template rendering error : ${nameOf(target)}.${method}()\n` + err;
 }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:7,代碼來源:TemplateRenderingError.ts

示例10: buildMessage

 /**
  *
  * @returns {string}
  * @param target
  * @param propertyName
  */
 static buildMessage(target: Type<any>, propertyName: string | symbol) {
   return `Property ${propertyName as string} on class ${nameOf(target)} is required.`;
 }
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:9,代碼來源:RequiredPropertyError.ts


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