Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能删除自定义类型吗? #5

Open
zhuscat opened this issue Aug 7, 2017 · 7 comments
Open

能删除自定义类型吗? #5

zhuscat opened this issue Aug 7, 2017 · 7 comments

Comments

@zhuscat
Copy link

zhuscat commented Aug 7, 2017

我用 yod-mock 搭建了一个服务器端的 mock-server,大概的功能是,用户可以传一个对象定义给我,然后我根据相关信息进行 mock,会需要使用 yod.type 定义许多类型(这样可以使用其 repeat)。

但是我担心定义类型定义过多会导致内存泄漏问题,不知道能不能将自定义类型删除。

@qiu8310
Copy link
Owner

qiu8310 commented Aug 7, 2017

你可以使用 yod.emptyTypes() 来清空你自定义的类型,也可以使用 delete yod.types['xxx'] 来删除指定的类型

@qiu8310
Copy link
Owner

qiu8310 commented Aug 7, 2017

参考文档: https://github.com/qiu8310/yod

@zhuscat
Copy link
Author

zhuscat commented Aug 7, 2017

感谢!

@zhuscat zhuscat closed this as completed Aug 7, 2017
@zhuscat
Copy link
Author

zhuscat commented Aug 24, 2017

好像 yod.emptyTypes() 会清空所有类型

@zhuscat zhuscat reopened this Aug 24, 2017
@zhuscat
Copy link
Author

zhuscat commented Aug 24, 2017

另外 yod.typesundefined,但是 typesyod 的一个键('type' in yod === true

@zhuscat
Copy link
Author

zhuscat commented Aug 24, 2017

是 npm 包没更新吗,我下下来的 yod1.0.0-alpha.3,然而我发现跟你的 yod git 仓库下的代码是不同的,造成这种现象的原因是如下

/**
 * all types
 * @type {Object}
 */
yod.types = tm.type.all;

实际上应该是 tm.t.all

@qiu8310
Copy link
Owner

qiu8310 commented Aug 29, 2017

谢谢了,确实如你分析的那样,yod 提交了代码,没有更新到 npm 上,现在更新了一个版本 1.0.0-alpha.4,你重新安装下 yod-mock 应该就 OK 了

不好意思,最近比较忙,回复晚了些。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants