Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.32
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/traverse/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/traverse/test/circular.js
'use strict';

var test = require('tape');
var traverse = require('../');
var deepEqual = require('./lib/deep_equal');
var util = require('util');

test('circular', function (t) {
	t.plan(1);

	var obj = { x: 3 };
	obj.y = obj;
	traverse(obj).forEach(function () {
		if (this.path.join('') === 'y') {
			t.equal(
				util.inspect(this.circular.node),
				util.inspect(obj)
			);
		}
	});
});

test('deepCirc', function (t) {
	t.plan(2);
	var obj = { x: [1, 2, 3], y: [4, 5] };
	obj.y[2] = obj;

	traverse(obj).forEach(function () {
		if (this.circular) {
			t.deepEqual(this.circular.path, []);
			t.deepEqual(this.path, ['y', '2']);
		}
	});
});

test('doubleCirc', function (t) {
	var obj = { x: [1, 2, 3], y: [4, 5] };
	obj.y[2] = obj;
	obj.x.push(obj.y);

	var circs = [];
	traverse(obj).forEach(function (x) {
		if (this.circular) {
			circs.push({ circ: this.circular, self: this, node: x });
		}
	});

	t.deepEqual(circs[0].self.path, ['x', '3', '2']);
	t.deepEqual(circs[0].circ.path, []);

	t.deepEqual(circs[1].self.path, ['y', '2']);
	t.deepEqual(circs[1].circ.path, []);

	t.deepEqual(circs.length, 2);
	t.end();
});

test('circDubForEach', function (t) {
	var obj = { x: [1, 2, 3], y: [4, 5] };
	obj.y[2] = obj;
	obj.x.push(obj.y);

	traverse(obj).forEach(function () {
		if (this.circular) { this.update('...'); }
	});

	t.same(obj, { x: [1, 2, 3, [4, 5, '...']], y: [4, 5, '...'] });
	t.end();
});

test('circDubMap', function (t) {
	var obj = { x: [1, 2, 3], y: [4, 5] };
	obj.y[2] = obj;
	obj.x.push(obj.y);

	var c = traverse(obj).map(function () {
		if (this.circular) {
			this.update('...');
		}
	});

	t.same(c, { x: [1, 2, 3, [4, 5, '...']], y: [4, 5, '...'] });
	t.end();
});

test('circClone', function (t) {
	var obj = { x: [1, 2, 3], y: [4, 5] };
	obj.y[2] = obj;
	obj.x.push(obj.y);

	var clone = traverse.clone(obj);
	t.ok(obj !== clone);

	t.ok(clone.y[2] === clone);
	t.ok(clone.y[2] !== obj);
	t.ok(clone.x[3][2] === clone);
	t.ok(clone.x[3][2] !== obj);
	t.same(clone.x.slice(0, 3), [1, 2, 3]);
	t.same(clone.y.slice(0, 2), [4, 5]);
	t.end();
});

test('circMapScrub', function (t) {
	var obj = { a: 1, b: 2 };
	obj.c = obj;

	var scrubbed = traverse(obj).map(function () {
		if (this.circular) { this.remove(); }
	});
	t.same(
		Object.keys(scrubbed).sort(),
		['a', 'b']
	);
	t.ok(deepEqual(scrubbed, { a: 1, b: 2 }));

	t.equal(obj.c, obj);
	t.end();
});

Youez - 2016 - github.com/yon3zu
LinuXploit