Files
memecoin-botV2/.pnpm-store/v10/files/87/47fbe9f679ac4cfd377e0b313c47d1d93919c637cecec9bbe742c7d445b41c1b6faf6e13e753bb308dd4e9e702e4d19125a7dcef45c47515a94056b96c068a

59 lines
1.4 KiB
Plaintext

'use strict';
const FilterBase = require('./FilterBase');
const withParser = require('../utils/withParser');
class Pick extends FilterBase {
static make(options) {
return new Pick(options);
}
static withParser(options) {
return withParser(Pick.make, options);
}
_checkChunk(chunk) {
switch (chunk.name) {
case 'startObject':
case 'startArray':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passObject;
this._depth = 1;
return true;
}
break;
case 'startString':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passString;
return true;
}
break;
case 'startNumber':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passNumber;
return true;
}
break;
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._once ? this._skip : this._check;
return true;
}
break;
}
return false;
}
}
Pick.pick = Pick.make;
Pick.make.Constructor = Pick;
module.exports = Pick;