dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

immutable require clone API?

Open mx1700 opened this issue 8 years ago • 4 comments

我认为 immutable 不需要 clone。 各位有告知一下 clone 的使用场景吗?

mx1700 avatar Apr 27 '18 04:04 mx1700

All public APIs are all immutable.

Still, if you want to get a copy of current Dayjs instance, use clone.

iamkun avatar Apr 27 '18 05:04 iamkun

@iamkun Since immutable, why do you need to obtain a copy? There is no need for two identical objects.

mx1700 avatar Apr 28 '18 03:04 mx1700

For user from Moment, If they want to replace the package with Dayjs without modifying existing code, they might need this.

Cause there are quite a lot of clone used in a moment code.

iamkun avatar Apr 28 '18 05:04 iamkun

@iamkun 出于兼容 moment 考虑可以理解。 如果不考虑兼容,我觉得可以私有 clone,没必要暴露出来给用户。

mx1700 avatar Apr 28 '18 08:04 mx1700