Recursively replace the given regular object

@author   Jelle De Loecker   <jelle@develry.be>
@since    1.0.11
@version  1.0.11

@param    {Function}   dryReplacer
@param    {Object}     value

@return   {Object}
506457
function recurseGeneralObject(dryReplacer, value) {

	var new_value = {},
	    keys = Object.keys(value),
	    key,
	    i;

	for (i = 0; i < keys.length; i++) {
		key = keys[i];
		new_value[key] = dryReplacer(value, key, value[key]);
	}

	return new_value;
}
172850
function str(key, holder) {
		var mind = gap, value = holder[key];
		
		// If the value has a toJSON method, call it to obtain a replacement value.
		if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
			value = value.toJSON(key);
		}
		
		// If we were called with a replacer function, then call the replacer to
		// obtain a replacement value.
		if (typeof rep === 'function') { value = rep.call(holder, key, value); }
		
		switch (typeof value) {
			case 'string':
				return quote(value);
			case 'number':
				// JSON numbers must be finite
				return isFinite(value) ? String(value) : 'null';
			case 'boolean':
				return String(value);
			case 'object': // object, array, date, null
				if (value === null) { return 'null'; } // typeof null == 'object'
				if (value.constructor === Date) { return exports.stringifyDate(value); }
			
				gap += indent;
				var partial = [];
				
				// Is the value an array?
				if (value.constructor === Array) {
					var length = value.length;
					for (var i = 0; i < length; i += 1) {
						partial[i] = str(i, value) || 'null';
					}
					
					// Join all of the elements together, separated with commas, and wrap them in brackets.
					var v = partial.length === 0 ? '[]' :
						gap ? '[\n' + gap +
								partial.join(',\n' + gap) + '\n' +
									mind + ']' :
							  '[' + partial.join(',') + ']';
					gap = mind;
					return v;
				}
				
				if (rep && typeof rep === 'object') { // rep is an array
					var length = rep.length;
					for (var i = 0; i < length; i += 1) {
						var k = rep[i];
						if (typeof k === 'string') {
							var v = str(k, value);
							if (v) {
								partial.push(quote(k) + (gap ? ': ' : ':') + v);
							}
						}
					}
				} else { // iterate through all of the keys in the object.
					for (var k in value) {
						if (Object.hasOwnProperty.call(value, k)) {
							var v = str(k, value);
							if (v) {
								partial.push(quote(k) + (gap ? ': ' : ':') + v);
							}
						}
					}
				}

				// Join all of the member texts together, separated with commas,
				// and wrap them in braces.
				var v = partial.length === 0 ? '{}' :
					gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
							mind + '}' : '{' + partial.join(',') + '}';
				gap = mind;
				return v;
		}
	}
4347
function replaceObject(dryReplacer, value, chain, flags, is_wrap, holder, path, value_paths, key) {

	var class_name,
	    seen_path,
	    new_value,
	    replaced,
	    is_array,
	    keys,
	    last,
	    temp,
	    len,
	    i;

	if (typeof value.constructor == 'function') {
		class_name = value.constructor.name;
	} else {
		class_name = 'Object';
	}

	// See if the chain needs popping
	while (len = chain.length) {

		// If the current object at the end of the chain does not
		// match the current holder, move one up
		// Don't mess with the chain if this is a wrap object
		if (!is_wrap && holder !== chain[len-1]) {

			last = chain.pop();

			// Only pop the path if the popped object isn't a wrapper
			if (last && !last.__is_wrap) {
				path.pop();
			}
		} else {
			break;
		}
	}

	// Has the object been seen before?
	seen_path = value_paths.get(value);

	if (seen_path) {

		// If the path is still an array,
		// turn it into a string now
		if (typeof seen_path != 'string') {

			// First iterate over the pieces and escape them
			for (i = 0; i < seen_path.length; i++) {
				if (seen_path[i].indexOf(special_char) > -1) {
					seen_path[i] = seen_path[i].replace(special_char_rg, safe_special_char);
				}
			}

			seen_path = special_char + seen_path.join(special_char);
			value_paths.set(value, seen_path);
		}

		// Replace the value with the path
		new_value = seen_path;

		// See if the new path is shorter
		len = 1;
		for (i = 0; i < path.length; i++) {
			len += 1 + path[i].length;
		}
		len += key.length;

		if (len < seen_path.length) {
			temp = seen_path;
			seen_path = path.slice(0);

			// The key of the current value still needs to be added
			seen_path.push(key);

			// First iterate over the pieces and escape them
			for (i = 0; i < seen_path.length; i++) {
				if (seen_path[i].indexOf(special_char) > -1) {
					seen_path[i] = seen_path[i].replace(special_char_rg, safe_special_char);
				}
			}

			seen_path = special_char + seen_path.join(special_char);
			value_paths.set(value, seen_path);

			// This entry still has to refer to the longer path,
			// otherwise it'll refer to itself
			seen_path = temp;
		}

		value = new_value;

		return value;
	}

	if (!flags.is_root && !is_wrap) {
		path.push(key);
	} else {
		flags.is_root = false;
	}

	// Make a copy of the current path array
	value_paths.set(value, path.slice(0));

	if (driers[class_name] != null) {
		value = driers[class_name].fnc(holder, key, value);

		value = {
			dry: class_name,
			value: value
		};

		if (driers[class_name].options.add_path !== false) {
			value.drypath = path.slice(0);
		}

		replaced = {'': value};
	} else if (class_name === 'RegExp' && value.constructor == RegExp) {
		value = {dry: 'regexp', value: value.toString()};
		replaced = {'': value};
	} else if (class_name === 'Date' && value.constructor == Date) {
		value = {dry: 'date', value: value.toISOString()};
		replaced = {'': value};
	} else if (typeof value.toDry === 'function') {
		temp = value;
		value = value.toDry();

		// If no path was supplied in the toDry,
		// get some more class information
		if (!value.path) {
			if (temp.constructor) {
				if (!value.namespace && temp.constructor.namespace) {
					value.namespace = temp.constructor.namespace;
				}

				if (!value.dry_class) {
					value.dry_class = temp.constructor.name;
				}
			}
		}

		value.dry = 'toDry';
		value.drypath = path.slice(0);
		replaced = {'': value};
	} else if (typeof value.toJSON === 'function') {
		value = value.toJSON();
		replaced = {'': value};
	} else {
		is_array = Array.isArray(value);
	}

	if (replaced) {
		// Push the replaced object on the chain
		chain.push(replaced);

		// Jsonify the replaced object
		value = dryReplacer(replaced, false, replaced['']);

		// At least one part of the path & chain will have
		// to be popped off. This is needed for toJSON calls
		// that return primitive values
		temp = chain.pop();

		// Don't pop off anything from the path if the last item
		// from the chain was a wrapper for an object,
		// because then it'll already be popped of
		if (!(temp && temp.__is_wrap && temp.__is_object)) {
			path.pop();
		}

		// Break out of the switch
		return value;
	}

	// Push this object on the chain
	chain.push(value);

	if (is_array) {
		new_value = [];

		for (i = 0; i < value.length; i++) {
			new_value[i] = dryReplacer(value, String(i), value[i]);
		}
	} else {
		new_value = recurseGeneralObject(dryReplacer, value);
	}

	value = new_value;

	return value;
}
1242495
function replaceStringPlaceholders(string, args) {
    for (var i = 1; i < args.length; i++) {
        var value = args[i];
        if (typeof value === "object") {
            value = JSON.stringify(value);
        }

        string = string.replace("{}", value);
    }

    return string;
}
688807
function defaultTransformSuccess(value,options){
    if (options.default === true){
        return {
            status:true,
            data:value
        }
    }
    
    if (options.appendStatus !== false){
        let obj = typeof value == 'object' ? value : {}
        return Object.assign(obj,{status:true})
    }

    return value
}
562583
function cleanItem3(value, parent) {

        var newvalue = null;

        if (Array.isArray(value)) {
            newvalue = [];

            var isAllNumbers = (value.length > 0);
            var isAllStrings = (value.length > 0)
            value.forEach(function (item) {
                if (typeof item !== 'number')
                    isAllNumbers = false;

                if (typeof item !== 'string')
                    isAllStrings = false;
            })

            if (isAllNumbers)
                return [cleanItem3(value[0], parent)];

            if (isAllStrings) {
                var enumKey = "Enum" + getTypeFromKey(parent);
                var hash = value.join("!");
                if (hash in enumFromHash)
                    enumKey = enumFromHash[hash]
                else {
                    var found = true;
                    value.forEach(function (key) {
                        if (!(key in enumFromKey)) found = false;
                    })

                    if (found) {
                        enumKey = enumFromKey[value[0]];
                    } else {
                        enums[enumKey] = value;
                        enumFromHash[hash] = enumKey;

                        value.forEach(function (key) {
                            enumFromKey[key] = "Enum" + getTypeFromKey(parent);
                        })
                    }
                }
                return [enumKey];
            }

            value.forEach(function (item) {
                newvalue.push(cleanItem3(item, parent));
            })

            return newvalue;
        }

        if ((typeof value !== "object") || (value == null)) {
            switch (typeof value) {
                case 'string':
                    if (isId(value)) return 'ID';
                    if (isUser(value)) return 'UserId';
                    if (isUserOrgPrefix(value)) return 'UserOrOrgIdPrefixed';
                    if (ids[value] == "orgs") return 'OrgId';
                    if (ids[value] == "roles") return 'EnumConfigRole';
                    if (value in enumDefaultKeys.values) return enumDefaultKeys.values[value];
                    if (ids[value]) return ids[value] + "Id";
                    return 'String';
                case 'number':
                    if (value > 1300000000 && value < 1700000000)
                        return value % 1 == 0 ? 'Date' : 'Time'
                    return value % 1 == 0 ? 'Int' : 'Float'
                case 'boolean':
                    return 'Boolean';
                default:
                    return value == null ? 'NULL' : value;
            }
        }

        var newvalue = {};

        Object.keys(value).forEach(function (key) {
            newvalue[key] = cleanItem3(value[key], parent + key.substr(0, 1).toUpperCase() + key.substr(1));
        });

        return newvalue;
    }
250841
function generateReviver(reviver, undry_paths) {

	return function dryReviver(key, value) {

		var val_type = typeof value,
		    constructor,
		    temp;

		if (val_type === 'string') {
			if (value[0] === special_char) {
				// This is actually a path that needs to be replaced.
				// Put in a String object for now
				return new String(value.slice(1));
			} else if (value[0] == '\\' && value[1] == 'x' && value[2] == '7' && value[3] == 'e') {
				value = special_char + value.slice(4);
			}
		} else if (value && value.dry != null) {

			switch (value.dry) {

				case 'date':
					if (value.value) {
						return new Date(value.value);
					}
					break;

				case 'regexp':
					if (value.value) {
						return RegExp.apply(undefined, get_regex.exec(value.value).slice(1));
					}
					break;

				case '+Infinity':
					return Infinity;

				case '-Infinity':
					return -Infinity;

				case 'toDry':
					constructor = findClass(value);

					// Undry this element, but don't put it in the parsed object yet
					if (constructor && typeof constructor.unDry === 'function') {
						value.unDryConstructor = constructor;
					} else {
						value.undried = value.value;
					}

					if (value.drypath) {
						undry_paths.set(value.drypath.join(special_char), value);
					} else {
						return value.undried;
					}
					break;

				default:
					if (typeof value.value !== 'undefined') {
						if (undriers[value.dry]) {
							value.unDryFunction = undriers[value.dry].fnc;

							if (!value.drypath) {
								// No path given? Then do the undrying right now
								value.undried = value.unDryFunction(this, key, value.value)
							}

						} else {
							value.undried = value.value;
						}

						if (value.drypath) {
							undry_paths.set(value.drypath.join(special_char), value);
						} else {
							return value.undried;
						}
					}
			}
		}

		if (reviver == null) {
			return value;
		}

		return reviver.call(this, key, value);
	};
}
1203985
function cloneDeep(value) {
  let obj = {};
  switch (typeOf(value)) {
    case 'object':
      for (let key of Object.keys(value)) {
        obj[key] = cloneDeep(value[key]);
      }
      return obj;
    case 'array':
      return value.map(ele => cloneDeep(ele));
    default: {
      return value;
    }
  }
}
1369339
function makeDefaultReplacer(map) {
    var lowerCaseMap = {}, key, val;
    for (key in map) {
        val = map[key];
        lowerCaseMap[key.toLowerCase()] = val;
    }
    return function(name) {
        var result = lowerCaseMap[name.toLowerCase()];
        if (result === undefined || result === null) {
            return "{{" + name + "}}";
        }
        return result;
    };
}
805283
function datesTransformReviver(key, value) {

    if (key === DATES_FIELD) {
      dates = value
      return null
    }

    if (value && typeof value === 'object' && value.hasOwnProperty(DATES_FIELD)) {
      for (const prop in value) {
        if (value.hasOwnProperty(prop) && dates.indexOf(value[prop]) !== -1) {
          value[prop] = new Date(Number.parseInt(value[prop]))
        }
      }

      datesHolders.push(value)
      dates = undefined
    }

    if (key === '') { //root object
      datesHolders.forEach(datesHolder => {
        delete datesHolder[DATES_FIELD]
      })

      datesHolders = []
    }

    return value
  }
849753
function retransformValueAST(root, customProperties, withoutProperty) {
	const nextCustomProperties = Object.assign({}, customProperties);

	delete nextCustomProperties[withoutProperty];

	return transformValueAST(root, nextCustomProperties);
}
18141
function reviveObject (object, reviver) {
  let revived = {};

  for (let key in object) {
    if (object.hasOwnProperty(key)) {
      revived[key] = reviveValue(object, key, object[key], reviver);
    }
  }

  return revived;
}
1158594
function regenerate(root, holder, current, seen, retrieve, undry_paths, old, current_path) {

	var temp;

	if (current && typeof current == 'object') {
		// Remember this object has been regenerated already
		seen.set(current, true);

		if (current instanceof Array) {
			return regenerateArray(root, holder, current, seen, retrieve, undry_paths, old, current_path);
		}

		if (current instanceof String) {

			if (current.length > -1) {
				current = current.toString();

				if (temp = undry_paths.get(current)) {
					if (typeof temp.undried != 'undefined') {
						return temp.undried;
					}

					if (!holder) {
						throw new Error('Unable to resolve recursive reference');
					}

					undry_paths.extra_pass.push([holder, temp, current_path]);

					return temp;
				}

				if (retrieve.hasOwnProperty(current)) {
					temp = retrieve[current];
				} else {
					temp = retrieve[current] = retrieveFromPath(root, current.split(special_char));

					if (typeof temp == 'undefined') {
						temp = retrieve[current] = getFromOld(old, current.split(special_char));
					}
				}

				// Because we always regenerate parsed objects first
				// (JSON-dry parsing goes from string » object » regenerated object)
				// keys of regular objects can appear out-of-order, so we need to parse them
				if (temp && temp instanceof String) {
					// Unset the String as a valid result
					retrieve[current] = null;

					// Regenerate the string again
					// (We have to create a new instance, because it's already been "seen")
					temp = retrieve[current] = regenerate(root, holder, new String(temp), seen, retrieve, undry_paths, old, current_path);
				}

				return temp;
			} else {
				return root;
			}
		}

		return regenerateObject(root, holder, current, seen, retrieve, undry_paths, old, current_path);
	}

	return current;
}
740363
private function replacePlaceHolder($value)
    {
        $value=str_replace(self::OBJECT_CONFIG_BASE_DIR_PLACE_HOLDER, $this->m_config->getBaseDir(), $value);
        $value=str_replace(self::OBJECT_CONFIG_USER_DIR_PLACE_HOLDER, $this->m_config->getUserDir(), $value);
        $value=str_replace(self::OBJECT_CONFIG_CONFIG_DIR_PLACE_HOLDER, $this->m_config->getConfigDir(), $value);
        return $value;
    }
57649
function(str, obj) {
    var replacer = function(wholeMatch, key) {
      return obj[key] === undefined ? wholeMatch : obj[key];
    },
    regexp = new RegExp('{{\\s*([a-z0-9-_]+)\\s*}}',"ig");

    for(var beforeReplace = ""; beforeReplace !== str; str = (beforeReplace = str).replace(regexp, replacer)){

    }
    return str;
  }
891992
@Override
    public Object apply(Object value, Object... params) {

        String original = super.asString(value);

        Object needle = super.get(0, params);
        String replacement = "";

        if (needle == null) {
            throw new RuntimeException("invalid pattern: " + needle);
        }

        if (params.length >= 2) {

            Object obj = super.get(1, params);

            if (obj == null) {
                throw new RuntimeException("invalid replacement: " + needle);
            }

            replacement = super.asString(super.get(1, params));
        }

        return original.replace(String.valueOf(needle), String.valueOf(replacement));
    }
1374230
function convertPlaceholders (value) {
      // Probably AST nodes.
      if (typeof value !== 'string') {
        return [value]
      }

      const items = value.split(placeholderRe)
      let placeholder = true
      return items.map((item) => {
        placeholder = !placeholder
        return placeholder ? expressions[item] : t.stringLiteral(item)
      })
    }