我简单地写了这样的接口:
interface IProduct {
id: number;
name: string;
price: number;
description?: string;
}
Run Code Online (Sandbox Code Playgroud)
现在我想id
在 ReadonlyArray 中保持唯一。因此,当创建一些产品时,我想防止添加具有相同 id 的对象。包含产品的数组将在文件中创建一次,并且不会被修改。
你对此有什么想法吗?JS Set 将是一个很好的解决方案,但我无法向它们添加自己的比较器。请不要提供需要额外框架等的解决方案。
$ npm login --scope=@username --registry=https://npm.pkg.github.com
$ Username: username
$ Password: ********
$ Email: (this IS public) example@gmail.com
$ npm ERR! code E401
$ npm ERR! 401 Unauthorized - PUT $ https://npm.pkg.github.com/-/user/org.couchdb.user:forinda - Error authenticating user: Requires authentication
$npm ERR! A complete log of this run can be found in:
$npm ERR! /home/orinda/.npm/_logs/2021-10-15T02_25_19_104Z-debug.log
Run Code Online (Sandbox Code Playgroud)
无法验证 npm 注册表和 github 我在填写密码时收到 401 错误 如何解决此问题