Skip to content

Commit

Permalink
Remove old inline methods
Browse files Browse the repository at this point in the history
  • Loading branch information
elenatorro committed Nov 12, 2019
1 parent 2ee9ad8 commit e39548d
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/renderer/viz/expressions/belongs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@ import BaseExpression from './base';
* @function
* @api
*/
export const In = generateBelongsExpression('in', IN_INLINE_MAKER, (input, list) => list.some(item => item === input) ? 1 : 0);
export const In = generateBelongsExpression('in', (input, list) => list.some(item => item === input) ? 1 : 0);

const OPERATORS = {
nin: '!=',
in: '=='
};

function IN_INLINE_MAKER (list) {
if (!list || list.length === 0) {
return () => '0.';
}
return inline => `((${list.map((cat, index) => `(${inline.input} == ${inline.list[index]})`).join(' || ')})? 1.: 0.)`;
}

/**
* Check if value does not belong to the list of elements.
*
Expand All @@ -61,16 +54,9 @@ function IN_INLINE_MAKER (list) {
* @function
* @api
*/
export const Nin = generateBelongsExpression('nin', NIN_INLINE_MAKER, (input, list) => list.some(item => item === input) ? 0 : 1);

function NIN_INLINE_MAKER (list) {
if (list.length === 0) {
return () => '1.';
}
return inline => `((${list.map((cat, index) => `(${inline.input} != ${inline.list[index]})`).join(' && ')})? 1.: 0.)`;
}
export const Nin = generateBelongsExpression('nin', (input, list) => list.some(item => item === input) ? 0 : 1);

function generateBelongsExpression (name, inlineMaker, jsEval) {
function generateBelongsExpression (name, jsEval) {
return class BelongExpression extends BaseExpression {
constructor (input, list) {
checkMaxArguments(arguments, 2, name);
Expand Down

0 comments on commit e39548d

Please sign in to comment.