99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Vinyl.isCustomProp()

2020-09-30 18:08 更新

Vinyl.isCustomProp()介紹

確定一個(gè)屬性是否由 Vinyl 在內(nèi)部進(jìn)行管理。Vinyl 在構(gòu)造函數(shù)中設(shè)置值或在 clone() 實(shí)例方法中復(fù)制屬性時(shí)使用。

這種方法在擴(kuò)展 Vinyl 類時(shí)很有用。詳情參見下文:擴(kuò)展 Vinyl。

Vinyl.isCustomProp()用法

const Vinyl = require('vinyl');

Vinyl.isCustomProp('sourceMap') === true;
Vinyl.isCustomProp('path') === false; 

Vinyl.isCustomProp()函數(shù)原型

Vinyl.isCustomProp(property)

參數(shù)

參數(shù)類型注解
propertystring要檢查的屬性名。

返回值

如果屬性不是內(nèi)部管理的,則為 True。

擴(kuò)展 Vinyl

當(dāng)在內(nèi)部管理自定義屬性時(shí),必須擴(kuò)展靜態(tài) isCustomProp 方法,并在查詢其中一個(gè)自定義屬性時(shí)返回 false。

const Vinyl = require('vinyl');

const builtInProps = ['foo', '_foo'];

class SuperFile extends Vinyl {
  constructor(options) {
    super(options);
    this._foo = 'example internal read-only value';
  }

  get foo() {
    return this._foo;
  }

  static isCustomProp(name) {
    return super.isCustomProp(name) && builtInProps.indexOf(name) === -1;
  }
}

在上面的例子中,foo 和 _foo 在克隆或?qū)?nbsp;options 傳遞給 new SuperFile(options) 時(shí)不會(huì)分配給新對(duì)象。

如果您的自定義屬性或邏輯在克隆期間需要特殊處理,請(qǐng)?jiān)跀U(kuò)展 Vinyl 時(shí)覆蓋 clone 方法。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)