private multi-value handlers and helpers
544106
private void _handleMultiValues(ArrayList<String> values, String key, String command) {
        if (key == null) return;

        if (values == null || values.isEmpty()) {
            _generateEmptyMultiValueError(key);
            return;
        }

        ValidationResult vr;

        // validate the key
        vr = validator.cleanMultiValuePropertyKey(key);

        // Check for an error
        if (vr.getErrorCode() != 0) {
            pushValidationResult(vr);
        }

        // reset the key
        Object _key = vr.getObject();
        String cleanKey = (_key != null) ? vr.getObject().toString() : null;

        // if key is empty generate an error and return
        if (cleanKey == null || cleanKey.isEmpty()) {
            _generateInvalidMultiValueKeyError(key);
            return;
        }

        key = cleanKey;

        try {
            JSONArray currentValues = _constructExistingMultiValue(key, command);
            JSONArray newValues = _cleanMultiValues(values, key);
            _validateAndPushMultiValue(currentValues, newValues, values, key, command);

        } catch (Throwable t) {
            getConfigLogger().verbose(getAccountId(), "Error handling multi value operation for key " + key, t);
        }
    }
258719
function setMultiValuedContainer(intoObj, fromObj, key, config = {}) {
  const intoVal = intoObj[key];
  const fromVal = fromObj[key];

  // don't merge private attrs
  if (
    (typeof key === 'string' && key.charAt(0) === '_' && key !== '_group') ||
    typeof intoVal === 'function' ||
    key === 'module'
  ) {
    return;
  }

  // already a mixture of values, can't get any worse
  if (intoVal === MULTI_VALUED) {
    return;
  } else if (intoVal === void 0) {
    // if the original doesn't have the key it's because that key
    // doesn't do anything there - so use the new value
    // note that if fromObj doesn't have a key in intoObj we will not
    // attempt to merge them at all, so this behavior makes the merge
    // independent of order.

    // WARNING: Careful that data copies were passed in as args here, as mutation can occur
    intoObj[key] = fromVal;
  } else if (key === 'colorscale') {
    // colorscales are arrays... need to stringify before comparing
    // (other vals we don't want to stringify, as differences could
    // potentially be real, like 'false' and false)
    if (String(intoVal) !== String(fromVal)) {
      intoObj[key] = MULTI_VALUED;
    }
  } else if (Array.isArray(intoVal)) {
    // in data, other arrays are data, which we don't care about
    // for styling purposes
    if (!config.searchArrays) {
      return;
    }
    if (!Array.isArray(fromVal)) {
      intoObj[key] = MULTI_VALUED;
    } else {
      // in layout though, we need to recurse into arrays
      for (let i = 0; i < fromVal.length; i++) {
        setMultiValuedContainer(intoVal, fromVal, i, config);
      }
    }
  } else if (isPlainObject(fromVal)) {
    // recurse into objects
    if (!isPlainObject(intoVal)) {
      throw new Error('tried to merge object into non-object: ' + key);
    }
    Object.keys(fromVal).forEach(function(key2) {
      setMultiValuedContainer(intoVal, fromVal, key2, config);
    });
  } else if (isPlainObject(intoVal)) {
    throw new Error('tried to merge non-object into object: ' + key);
  } else if (intoVal !== fromVal) {
    // different non-empty values -
    intoObj[key] = MULTI_VALUED;
  }
}
120403
def render_hidden(name, value):
    
    if isinstance(value, list):
        return MultipleHiddenInput().render(name, value)
    return HiddenInput().render(name, value)
704018
function(curr, name, value) {
        /* global process: true */
        /* global setImmediate: true */
        /* global setTimeout: true */

        /*  short-circuit processing  */
        if (curr[name].length === 0)
            return;

        /*  iterate over all handlers, exactly once  */
        var handlers = curr[name];
        curr[name] = [];                                             /*  [Promises/A+ 2.2.2.3, 2.2.3.3]  */
        var func = function() {
            for (var i = 0; i < handlers.length; i++)
                handlers[i](value);                                  /*  [Promises/A+ 2.2.5]  */
        };

        /*  execute procedure asynchronously  */                     /*  [Promises/A+ 2.2.4, 3.1]  */
        if (typeof process === 'object' && typeof process.nextTick === 'function')
            process.nextTick(func);
        else if (typeof setImmediate === 'function')
            setImmediate(func);
        else
            setTimeout(func, 0);
    }
865179
function onData( numValues ) {
		var i = -1, buffer;

		// Initialize the buffer array used for chunking:
		buffer = new Array( numValues );

		/**
		* FUNCTION: onData( newVal, encoding, clbk )
		*	Data event handler. Chunks data.
		*
		* @private
		* @param {Number} newVal - new streamed data value
		* @param {String} encoding
		* @param {Function} clbk - callback to invoke after handling streamed data. Function accepts two arguments: [ error, chunk ].
		*/
		return function onData( newVal, encoding, clbk ) {
			i += 1;
			buffer[ i ] = newVal;
			if ( i === numValues-1 ) {
				i = -1;
				clbk( null, buffer.slice() );
				return;
			}
			clbk();
		}; // end FUNCTION onData()
	}
1027025
function valueGetter({ attrs, attributeBlocks }) {
      let values = null;
      return function getValue(name) {
        if (!values) {
          values = new Map();
          // Look in &attributes(...) style attribute blocks for any known values.
          // eslint-disable-next-line no-unused-vars
          for (const attributeBlock of attributeBlocks) {
            const jsAst = parseExpression(attributeBlock.val);
            if (jsAst.type === 'ObjectExpression' && jsAst.properties) {
              for (const property of jsAst.properties) {
                if (property.type !== 'ObjectProperty' || property.method || property.computed) {
                  // Can't sanitize getters or methods, or spread elements.
                  continue;
                }
                const attrName = property.key.name || property.key.value;
                const { code: valueExpression } = generate(property.value);
                if (constantinople(valueExpression)) {
                  values.set(attrName, constantinople.toConstant(valueExpression));
                }
              }
            }
          }
          // Find any known values among the (attr=expr, ...) style attributes.
          for (const attr of attrs) {
            if (constantinople(attr.val)) {
              values.set(attr.name, constantinople.toConstant(attr.val));
            }
          }
        }

        name = String(name).toLowerCase();
        return values.get(name);
      };
    }
672612
function (value) {
        var handler = Variable.types[this.type] || Variable.types.any;
        return _.isFunction(handler) ? handler(value) : handler.in(value);
    }
284178
function getValueHandler (value, localHandlers, globalHandlers) {
  return _getValueHandler(value, localHandlers) || _getValueHandler(value, globalHandlers);
}
618591
def parse_value_reference(parser, event, node): #pylint: disable=unused-argument

    

    (next_event, next_node) = six.next(parser)

    # TODO 2/16 KS: Functions below do not exist: i.e. class stuff broken:
    #               parse_classpath, parse_localclasspath, parse_classname.

    if _is_start(next_event, next_node, 'CLASSPATH'):
        result = parse_classpath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'LOCALCLASSPATH'):
        result = parse_localclasspath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'CLASSNAME'):
        result = parse_classname(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'INSTANCEPATH'):
        result = parse_instancepath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'LOCALINSTANCEPATH'):
        result = parse_localinstancepath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'INSTANCENAME'):
        result = parse_instancename(parser, next_event, next_node)

    else:
        raise ParseError('Expecting (CLASSPATH | LOCALCLASSPATH | CLASSNAME '
                         '| INSTANCEPATH | LOCALINSTANCEPATH | INSTANCENAME)')

    _get_end_event(parser, 'VALUE.REFERENCE')

    return result
459636
def make_variable_handler(dec_f, sized_values, min_size, non_minimal_data_handler):
    
    sized_values = list(sized_values)

    def f(script, pc, verify_minimal_data=False):
        size, pc = dec_f(script, pc)
        data = bytes_as_hex(script[pc:pc+size])
        if len(data) < size:
            return pc+1, None
        if verify_minimal_data:
            if size in sized_values or size <= min_size:
                non_minimal_data_handler("not minimal push of data with size %d" % size)
        return pc+size, data
    return f
279963
function handlePropertyValues(schema, values, prop) {
    var length = values.length
    var result = []
    var index = -1
    var value

    while (++index < length) {
        value = handlePropertyValue(schema, values[index], prop)

        if (value !== null && value !== undefined) {
            result.push(value)
        }
    }

    return result
}
505922
function Closure (parent, listOfKeys, accessor) {
  "use strict";

  var closure = {};

  listOfKeys = listOfKeys || [];
  accessor   = accessor || function () {};
  
  parent && parent.__mixin__ && parent.__mixin__(closure);

  listOfKeys.forEach(function (key) {
    closure[key] = accessor.bind(null, key);
  });

  this.getValues = function () {
    var values = {};
    Object.keys(closure).forEach(function (key) {
      values[key] = closure[key]();
      if (values[key] === undefined) {
        values[key] = null;
      }
      if (typeof values[key] === 'function') {
        throw new Error('a closure variable must be serializable, so you cannot use a function');
      }
    });
    return values;
  }

  this.setValues = function (values) {
    Object.keys(values).forEach(function (key) {
      closure[key](values[key]);
    });
  }

  this.__mixin__ = function (object) {
    Object.keys(closure).forEach(function (key) {
      object[key] = closure[key];
    });
  }

}
1372832
function handleField (name, value, options) {
      var serialized
      var length
      var key
      var i

      options = options || { attachment: false }

      if (is(name).a(Object)) {
        for (key in name) {
          if (Object.prototype.hasOwnProperty.call(name, key)) {
            handleField(key, name[key], options)
          }
        }
      } else {
        if (is(value).a(Array)) {
          for (i = 0, length = value.length; i < length; i++) {
            serialized = handleFieldValue(value[i])
            if (serialized) {
              $this.rawField(name, serialized, options)
            }
          }
        } else if (value != null) {
          $this.rawField(name, handleFieldValue(value), options)
        }
      }

      return $this
    }
623992
function _handleMultipleAPIs(obj, method, f) {
    if (this._wrapped) {
        f = this._wrapped;
        this._wrapped = method(f, obj);
        return this;
    } else if (f === undefined) {
        f = this;
        return method(f, obj);
    } else {
        return method(f, obj);
    }
}
339172
function processValuesFromContext(node, params, msg, varList) {
                let pMsg = {};
                Object.assign(pMsg, params);
                varList.forEach((varItem) => {
                    if (varItem.type === undefined || params[varItem.type] === undefined) {
                        pMsg[varItem.name] = params[varItem.name];
                    } else if (params[varItem.type] === 'flow' || params[varItem.type] === 'global') {
                        pMsg[varItem.name] = RED.util.evaluateNodeProperty(params[varItem.name], params[varItem.type], node, msg);
                        pMsg[varItem.type] = params[varItem.type];
                        console.log('Inside flow or global');
                        console.log(varItem.name + ' - - ' + pMsg[varItem.name]);
                    } else {
                        pMsg[varItem.name] = params[varItem.name];
                        pMsg[varItem.type] = params[varItem.type];
                    }
                });
                return pMsg;
            }
650654
def _inject_closure_values_fix_code(c, injected, **kwargs):
    
    # Add more closure variables
    c.freevars += injected

    # Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)
    # for named variables
    for i, (opcode, value) in enumerate(c.code):
        if opcode == byteplay.LOAD_GLOBAL and value in kwargs:
            c.code[i] = byteplay.LOAD_DEREF, value

    _inject_closure_values_fix_closures(c, injected, **kwargs)

    return c
138068
function processTerm (handler, obj = {}, isDefault) {
  let req = {
    term: this._request.term.then(value => {
      assignRequest(req, this._request, obj)
      if (this._request.error && !isDefault) return null
      if (isDefault) req.error = null
      return handler(value, req)
    })
  }
  return new v(this._client, req)
}