• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.nameOf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.Metadata类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.getDecoratorType函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap