(columnName, operator, fixedValue)
| 15884 | // todo: preserve subclasses! |
| 15885 | // todo: preserve links back to parent so you could edit as normal? |
| 15886 | where(columnName, operator, fixedValue) { |
| 15887 | const isArray = Array.isArray(fixedValue) |
| 15888 | const valueType = isArray ? typeof fixedValue[0] : typeof fixedValue |
| 15889 | let parser |
| 15890 | if (valueType === "number") parser = parseFloat |
| 15891 | const fn = particle => { |
| 15892 | const atom = particle.get(columnName) |
| 15893 | const typedAtom = parser ? parser(atom) : atom |
| 15894 | if (operator === WhereOperators.equal) return fixedValue === typedAtom |
| 15895 | else if (operator === WhereOperators.notEqual) return fixedValue !== typedAtom |
| 15896 | else if (operator === WhereOperators.includes) return typedAtom !== undefined && typedAtom.includes(fixedValue) |
| 15897 | else if (operator === WhereOperators.doesNotInclude) return typedAtom === undefined || !typedAtom.includes(fixedValue) |
| 15898 | else if (operator === WhereOperators.greaterThan) return typedAtom > fixedValue |
| 15899 | else if (operator === WhereOperators.lessThan) return typedAtom < fixedValue |
| 15900 | else if (operator === WhereOperators.greaterThanOrEqual) return typedAtom >= fixedValue |
| 15901 | else if (operator === WhereOperators.lessThanOrEqual) return typedAtom <= fixedValue |
| 15902 | else if (operator === WhereOperators.empty) return !particle.has(columnName) |
| 15903 | else if (operator === WhereOperators.notEmpty) return particle.has(columnName) || (atom !== "" && atom !== undefined) |
| 15904 | else if (operator === WhereOperators.in && isArray) return fixedValue.includes(typedAtom) |
| 15905 | else if (operator === WhereOperators.notIn && isArray) return !fixedValue.includes(typedAtom) |
| 15906 | } |
| 15907 | const result = new Particle() |
| 15908 | this.filter(fn).forEach(particle => { |
| 15909 | result.appendParticle(particle) |
| 15910 | }) |
| 15911 | return result |
| 15912 | } |
| 15913 | with(cue) { |
| 15914 | return this.filter(particle => particle.has(cue)) |
| 15915 | } |
nothing calls this directly
no test coverage detected