Returns new buffer with first $n bytes and discards them from current buffer.

@param int $n
@return Buffer
197216
public function consumeSlice($n)
    {
        if ($this->length < $n) {
            throw new BufferUnderflowException();

        } elseif ($this->length === $n) {
            $buffer = $this->buffer;
            $this->buffer = "";
            $this->length = 0;
            return new Buffer($buffer);

        } else {
            $buffer = substr($this->buffer, 0, $n);
            $this->buffer = substr($this->buffer, $n);
            $this->length -= $n;
            return new Buffer($buffer);
        }
    }
43313
public static function bytes($n, &$method = null)
    {
        $bytes = self::php7Bytes($n);
        $method = 'php7';
        if (! isset($bytes)) {
            $bytes = self::mcryptBytes($n);
            $method = 'mcrypt';
        }
        if (! isset($bytes)) {
            $bytes = self::opensslBytes($n);
            $method = 'openssl';
        }
        if (! isset($bytes)) {
            $bytes = self::urandomBytes($n);
            $method = 'urandom';
        }
        if (! isset($bytes)) {
            $bytes = self::mtRandBytes($n);
            $method = 'mt_rand';
        }
        $l = Binary::length($bytes);
        if ($l < $n) {
            $bytes .= self::mtRandBytes($n - $l);
        }
        return $bytes;
    }
276515
public static function paginate($n, $current = 0, $chunk = null)
    {
        return static::query()->paginate($n, $current, $chunk);
    }
1039752
public function segment(int $n)
    {
        if (isset($this->getSegments()[$n - 1])) {
            return $this->getSegments()[$n - 1];
        }

        return null;
    }
597676
public function forward($n)
    {
        $n = (int) $n;
        if (($this->position + $n) > $this->getLength()) {
            throw new \OutOfBoundsException(sprintf('No more bytes to read'));
        }

        $this->position += $n;
    }
861209
public function splice(int $offset, int $n) : self
    {
        $samples = array_splice($this->samples, $offset, $n);
        $labels = array_splice($this->labels, $offset, $n);

        return self::quick($samples, $labels);
    }
957944
protected function toBuffer($input)
    {
        if (is_string($input)) {
            if (strpos($input, '0x') === 0) {
                // hex string
                // $input = str_replace('0x', '', $input);
                return new Buffer($input, 'hex');
            }
            return new Buffer(str_split($input, 1));
        } elseif (is_numeric($input)) {
            if (!$input || $input < 0) {
                return new Buffer([]);
            }
            if (is_float($input)) {
                $input = number_format($input, 0, '', '');
                var_dump($input);
            }
            $gmpInput = gmp_init($input, 10);
            return new Buffer('0x' . gmp_strval($gmpInput, 16), 'hex');
        } elseif ($input === null) {
            return new Buffer([]);
        } elseif (is_array($input)) {
            return new Buffer($input);
        } elseif ($input instanceof Buffer) {
            return $input;
        }
        throw new InvalidArgumentException('The input type didn\'t support.');
    }
331101
public function first($n)
    {
        $first = '';

        if ($n > 0)
        {
            $first = UTF8::substr
            (
                $this->scalarString,
                0,
                $n,
                $this->encoding
            );
        }

        return $this->newSelf($first);
    }
1085770
public function generate(int $n) : Dataset
    {
        $samples = Matrix::gaussian($n, $this->dimensions())
            ->multiply($this->stddev)
            ->add($this->center)
            ->asArray();

        return Unlabeled::quick($samples);
    }
2623
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->initialize();
            $this->setInitialized(true);
        }

        while (($buffer = $this->in->read($len)) !== -1) {
            // Remove the last "\n" from buffer for
            // prevent explode to add an empty cell at
            // the end of array
            $buffer = trim($buffer, "\n");

            $lines = explode("\n", $buffer);
            $skip = $this->skip > 0 ? $this->skip : 0;

            if (count($lines) >= $this->lines) {
                // Buffer have more (or same) number of lines than needed.
                // Fill lineBuffer with the last "$this->_lines" lasts ones.
                $off = count($lines) - $this->lines;
                if ($skip > 0) {
                    $this->lineBuffer = array_slice($lines, $off - $skip, -$skip);
                } else {
                    $this->lineBuffer = array_slice($lines, $off);
                }
            } else {
                // Some new lines ...
                // Prepare space for insert these new ones
                $this->lineBuffer = array_slice($this->lineBuffer, count($lines) - 1);
                $this->lineBuffer = array_merge($this->lineBuffer, $lines);
            }
        }

        if (empty($this->lineBuffer)) {
            $ret = -1;
        } else {
            $ret = implode("\n", $this->lineBuffer);
            $this->lineBuffer = [];
        }

        return $ret;
    }
1054689
public function encryptInteger($n) {
		if (!is_numeric($n)) return null;
		return (PHP_INT_SIZE == 4 ? self::encrypt32($n) : self::encrypt64($n)) ^ $this->encPassword;
	}
656334
public function returnBuffer($buffer = null)
    {
        if ($this->isBufferReturned)
        {
            return $buffer;
        }

        $this->apply($this->applyOnOutput);

        if (ob_get_level() and ! empty($this->errorString))
        {
            # prepend any errors to the buffer string (any errors that were
            # echoed will have been lost during an ob_start callback)
            $buffer = $this->errorString . $buffer;
        }

        # if we were called as part of ob_start, make note of this
        # (avoid doing redundent work if called again)
        $this->isBufferReturned = true;

        return $buffer;
    }
120351
public function writeOctet($n)
    {
        if ($n < 0 || $n > 255) {
            throw new \InvalidArgumentException('Octet out of range 0..255');
        }

        $this->flushBits();
        $this->out .= chr($n);
        return $this;
    }
1031491
public function withPointMovedLeft(int $n) : BigDecimal
    {
        if ($n === 0) {
            return $this;
        }

        if ($n < 0) {
            return $this->withPointMovedRight(-$n);
        }

        return new BigDecimal($this->value, $this->scale + $n);
    }
813519
public function read($n)
    {
        $n = (int) $n;
        $raw = substr($this->bytes, $this->position, $n);
        $this->position += $n;

        return $raw;
    }
1142868
public function deleteChar($n)
    {
        $len = $this->strlen($this->linebuffer);
        if ($n < 0 || $n >= $len) {
            return;
        }

        // read everything up until before current position
        $pre  = $this->substr($this->linebuffer, 0, $n);
        $post = $this->substr($this->linebuffer, $n + 1);

        $this->linebuffer = $pre . $post;

        // move cursor one cell to the left if we're deleting in front of the cursor
        if ($n < $this->linepos) {
            --$this->linepos;
        }

        $this->redraw();
    }
1187033
public function skip($n)
    {
        $start = $this->currentPosition;

        $ret = @fseek($this->stream, $n, SEEK_CUR);
        if ($ret === -1) {
            return -1;
        }

        $this->currentPosition = ftell($this->stream);

        if ($start > $this->currentPosition) {
            $skipped = $start - $this->currentPosition;
        } else {
            $skipped = $this->currentPosition - $start;
        }

        return $skipped;
    }