Vinyl.isCustomProp()#
确定属性是否由 Vinyl 内部管理。在构造函数内设置值或在 clone() 实例方法中复制属性时由 Vinyl 使用。
¥Determines if a property is internally managed by Vinyl. Used by Vinyl when setting values inside the constructor or when copying properties in the clone() instance method.
该方法在扩展 Vinyl 类时很有用。详细见下文 扩展 Vinyl。
¥This method is useful when extending the Vinyl class. Detailed in Extending Vinyl below.
用法#
¥Usage
签名#
¥Signature
参数#
¥Parameters
| 参数 | type | note |
|---|---|---|
| property | string | 要检查的属性名称。 |
返回#
¥Returns
如果该属性不是内部管理的,则为 true。
¥True if the property is not internally managed.
扩展 Vinyl#
¥Extending Vinyl
当自定义属性在内部管理时,必须扩展静态 isCustomProp 方法,并在查询自定义属性之一时返回 false。
¥When custom properties are managed internally, the static isCustomProp method must be extended and return false when one of the custom properties is queried.
上例中,克隆时或传入 options 至 new SuperFile(options) 时,foo 和 _foo 不会分配给新对象。
¥In the example above, foo and _foo will not be assigned to the new object when cloning or passed in options to new SuperFile(options).
如果你的自定义属性或逻辑在克隆期间需要特殊处理,请在扩展 Vinyl 时覆盖 clone 方法。
¥If your custom properties or logic require special handling during cloning, override the clone method while extending Vinyl.