src/fn/Map.php
public function string($delimiter = PHP_EOL, ...$replacements): string
    {
        $string = '';
        if (!isCallable($delimiter)) {
            if (is_array($delimiter)) {
                array_unshift($replacements, $delimiter);
                $delimiter = PHP_EOL;
            }
            $delimiter = function($counter) use($delimiter) {
                return $counter ? $delimiter : '';
            };
        }
        traverse($this->leaves(function($value, Map\Path $iterator) use ($delimiter, &$string) {
            static $counter = 0;
            $string .= $delimiter(...[$counter++, $iterator->getDepth(), $iterator]) . $value;

        }));
        return $replacements ? str($string, ...$replacements) : $string;
    }
public function string($delimiter = PHP_EOL, ...$replacements): string
    {
        $string = '';
        if (!isCallable($delimiter)) {
            if (is_array($delimiter)) {
                array_unshift($replacements, $delimiter);
                $delimiter = PHP_EOL;
            }
            $delimiter = function($counter) use($delimiter) {
                return $counter ? $delimiter : '';
            };
        }
        traverse($this->leaves(function($value, Map\Path $iterator) use ($delimiter, &$string) {
            static $counter = 0;
            $string .= $delimiter(...[$counter++, $iterator->getDepth(), $iterator]) . $value;

        }));
        return $replacements ? str($string, ...$replacements) : $string;
    }
@param string|callable|array $delimiter

@param array $replacements

@return string