Файловый менеджер - Редактировать - /home/freeclou/app.optimyar.com/front-web/build/assets/resources/agGrid/test.zip
Назад
PK �z[�� bL7 L7 api-test.jsnu �Iw�� 'use strict'; var ip = require('..'); var assert = require('assert'); var net = require('net'); var os = require('os'); describe('IP library for node.js', function() { describe('toBuffer()/toString() methods', function() { it('should convert to buffer IPv4 address', function() { var buf = ip.toBuffer('127.0.0.1'); assert.equal(buf.toString('hex'), '7f000001'); assert.equal(ip.toString(buf), '127.0.0.1'); }); it('should convert to buffer IPv4 address in-place', function() { var buf = new Buffer(128); var offset = 64; ip.toBuffer('127.0.0.1', buf, offset); assert.equal(buf.toString('hex', offset, offset + 4), '7f000001'); assert.equal(ip.toString(buf, offset, 4), '127.0.0.1'); }); it('should convert to buffer IPv6 address', function() { var buf = ip.toBuffer('::1'); assert(/(00){15,15}01/.test(buf.toString('hex'))); assert.equal(ip.toString(buf), '::1'); assert.equal(ip.toString(ip.toBuffer('1::')), '1::'); assert.equal(ip.toString(ip.toBuffer('abcd::dcba')), 'abcd::dcba'); }); it('should convert to buffer IPv6 address in-place', function() { var buf = new Buffer(128); var offset = 64; ip.toBuffer('::1', buf, offset); assert(/(00){15,15}01/.test(buf.toString('hex', offset, offset + 16))); assert.equal(ip.toString(buf, offset, 16), '::1'); assert.equal(ip.toString(ip.toBuffer('1::', buf, offset), offset, 16), '1::'); assert.equal(ip.toString(ip.toBuffer('abcd::dcba', buf, offset), offset, 16), 'abcd::dcba'); }); it('should convert to buffer IPv6 mapped IPv4 address', function() { var buf = ip.toBuffer('::ffff:127.0.0.1'); assert.equal(buf.toString('hex'), '00000000000000000000ffff7f000001'); assert.equal(ip.toString(buf), '::ffff:7f00:1'); buf = ip.toBuffer('ffff::127.0.0.1'); assert.equal(buf.toString('hex'), 'ffff000000000000000000007f000001'); assert.equal(ip.toString(buf), 'ffff::7f00:1'); buf = ip.toBuffer('0:0:0:0:0:ffff:127.0.0.1'); assert.equal(buf.toString('hex'), '00000000000000000000ffff7f000001'); assert.equal(ip.toString(buf), '::ffff:7f00:1'); }); }); describe('fromPrefixLen() method', function() { it('should create IPv4 mask', function() { assert.equal(ip.fromPrefixLen(24), '255.255.255.0'); }); it('should create IPv6 mask', function() { assert.equal(ip.fromPrefixLen(64), 'ffff:ffff:ffff:ffff::'); }); it('should create IPv6 mask explicitly', function() { assert.equal(ip.fromPrefixLen(24, 'IPV6'), 'ffff:ff00::'); }); }); describe('not() method', function() { it('should reverse bits in address', function() { assert.equal(ip.not('255.255.255.0'), '0.0.0.255'); }); }); describe('or() method', function() { it('should or bits in ipv4 addresses', function() { assert.equal(ip.or('0.0.0.255', '192.168.1.10'), '192.168.1.255'); }); it('should or bits in ipv6 addresses', function() { assert.equal(ip.or('::ff', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff'); }); it('should or bits in mixed addresses', function() { assert.equal(ip.or('0.0.0.255', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff'); }); }); describe('mask() method', function() { it('should mask bits in address', function() { assert.equal(ip.mask('192.168.1.134', '255.255.255.0'), '192.168.1.0'); assert.equal(ip.mask('192.168.1.134', '::ffff:ff00'), '::ffff:c0a8:100'); }); it('should not leak data', function() { for (var i = 0; i < 10; i++) assert.equal(ip.mask('::1', '0.0.0.0'), '::'); }); }); describe('subnet() method', function() { // Test cases calculated with http://www.subnet-calculator.com/ var ipv4Subnet = ip.subnet('192.168.1.134', '255.255.255.192'); it('should compute ipv4 network address', function() { assert.equal(ipv4Subnet.networkAddress, '192.168.1.128'); }); it('should compute ipv4 network\'s first address', function() { assert.equal(ipv4Subnet.firstAddress, '192.168.1.129'); }); it('should compute ipv4 network\'s last address', function() { assert.equal(ipv4Subnet.lastAddress, '192.168.1.190'); }); it('should compute ipv4 broadcast address', function() { assert.equal(ipv4Subnet.broadcastAddress, '192.168.1.191'); }); it('should compute ipv4 subnet number of addresses', function() { assert.equal(ipv4Subnet.length, 64); }); it('should compute ipv4 subnet number of addressable hosts', function() { assert.equal(ipv4Subnet.numHosts, 62); }); it('should compute ipv4 subnet mask', function() { assert.equal(ipv4Subnet.subnetMask, '255.255.255.192'); }); it('should compute ipv4 subnet mask\'s length', function() { assert.equal(ipv4Subnet.subnetMaskLength, 26); }); it('should know whether a subnet contains an address', function() { assert.equal(ipv4Subnet.contains('192.168.1.180'), true); }); it('should know whether a subnet does not contain an address', function() { assert.equal(ipv4Subnet.contains('192.168.1.195'), false); }); }); describe('subnet() method with mask length 32', function() { // Test cases calculated with http://www.subnet-calculator.com/ var ipv4Subnet = ip.subnet('192.168.1.134', '255.255.255.255'); it('should compute ipv4 network\'s first address', function() { assert.equal(ipv4Subnet.firstAddress, '192.168.1.134'); }); it('should compute ipv4 network\'s last address', function() { assert.equal(ipv4Subnet.lastAddress, '192.168.1.134'); }); it('should compute ipv4 subnet number of addressable hosts', function() { assert.equal(ipv4Subnet.numHosts, 1); }); }); describe('subnet() method with mask length 31', function() { // Test cases calculated with http://www.subnet-calculator.com/ var ipv4Subnet = ip.subnet('192.168.1.134', '255.255.255.254'); it('should compute ipv4 network\'s first address', function() { assert.equal(ipv4Subnet.firstAddress, '192.168.1.134'); }); it('should compute ipv4 network\'s last address', function() { assert.equal(ipv4Subnet.lastAddress, '192.168.1.135'); }); it('should compute ipv4 subnet number of addressable hosts', function() { assert.equal(ipv4Subnet.numHosts, 2); }); }); describe('cidrSubnet() method', function() { // Test cases calculated with http://www.subnet-calculator.com/ var ipv4Subnet = ip.cidrSubnet('192.168.1.134/26'); it('should compute an ipv4 network address', function() { assert.equal(ipv4Subnet.networkAddress, '192.168.1.128'); }); it('should compute an ipv4 network\'s first address', function() { assert.equal(ipv4Subnet.firstAddress, '192.168.1.129'); }); it('should compute an ipv4 network\'s last address', function() { assert.equal(ipv4Subnet.lastAddress, '192.168.1.190'); }); it('should compute an ipv4 broadcast address', function() { assert.equal(ipv4Subnet.broadcastAddress, '192.168.1.191'); }); it('should compute an ipv4 subnet number of addresses', function() { assert.equal(ipv4Subnet.length, 64); }); it('should compute an ipv4 subnet number of addressable hosts', function() { assert.equal(ipv4Subnet.numHosts, 62); }); it('should compute an ipv4 subnet mask', function() { assert.equal(ipv4Subnet.subnetMask, '255.255.255.192'); }); it('should compute an ipv4 subnet mask\'s length', function() { assert.equal(ipv4Subnet.subnetMaskLength, 26); }); it('should know whether a subnet contains an address', function() { assert.equal(ipv4Subnet.contains('192.168.1.180'), true); }); it('should know whether a subnet contains an address', function() { assert.equal(ipv4Subnet.contains('192.168.1.195'), false); }); }); describe('cidr() method', function() { it('should mask address in CIDR notation', function() { assert.equal(ip.cidr('192.168.1.134/26'), '192.168.1.128'); assert.equal(ip.cidr('2607:f0d0:1002:51::4/56'), '2607:f0d0:1002::'); }); }); describe('isEqual() method', function() { it('should check if addresses are equal', function() { assert(ip.isEqual('127.0.0.1', '::7f00:1')); assert(!ip.isEqual('127.0.0.1', '::7f00:2')); assert(ip.isEqual('127.0.0.1', '::ffff:7f00:1')); assert(!ip.isEqual('127.0.0.1', '::ffaf:7f00:1')); assert(ip.isEqual('::ffff:127.0.0.1', '::ffff:127.0.0.1')); assert(ip.isEqual('::ffff:127.0.0.1', '127.0.0.1')); }); }); describe('isPrivate() method', function() { it('should check if an address is localhost', function() { assert.equal(ip.isPrivate('127.0.0.1'), true); }); it('should check if an address is from a 192.168.x.x network', function() { assert.equal(ip.isPrivate('192.168.0.123'), true); assert.equal(ip.isPrivate('192.168.122.123'), true); assert.equal(ip.isPrivate('192.162.1.2'), false); }); it('should check if an address is from a 172.16.x.x network', function() { assert.equal(ip.isPrivate('172.16.0.5'), true); assert.equal(ip.isPrivate('172.16.123.254'), true); assert.equal(ip.isPrivate('171.16.0.5'), false); assert.equal(ip.isPrivate('172.25.232.15'), true); assert.equal(ip.isPrivate('172.15.0.5'), false); assert.equal(ip.isPrivate('172.32.0.5'), false); }); it('should check if an address is from a 169.254.x.x network', function() { assert.equal(ip.isPrivate('169.254.2.3'), true); assert.equal(ip.isPrivate('169.254.221.9'), true); assert.equal(ip.isPrivate('168.254.2.3'), false); }); it('should check if an address is from a 10.x.x.x network', function() { assert.equal(ip.isPrivate('10.0.2.3'), true); assert.equal(ip.isPrivate('10.1.23.45'), true); assert.equal(ip.isPrivate('12.1.2.3'), false); }); it('should check if an address is from a private IPv6 network', function() { assert.equal(ip.isPrivate('fd12:3456:789a:1::1'), true); assert.equal(ip.isPrivate('fe80::f2de:f1ff:fe3f:307e'), true); assert.equal(ip.isPrivate('::ffff:10.100.1.42'), true); assert.equal(ip.isPrivate('::FFFF:172.16.200.1'), true); assert.equal(ip.isPrivate('::ffff:192.168.0.1'), true); }); it('should check if an address is from the internet', function() { assert.equal(ip.isPrivate('165.225.132.33'), false); // joyent.com }); it('should check if an address is a loopback IPv6 address', function() { assert.equal(ip.isPrivate('::'), true); assert.equal(ip.isPrivate('::1'), true); assert.equal(ip.isPrivate('fe80::1'), true); }); }); describe('loopback() method', function() { describe('undefined', function() { it('should respond with 127.0.0.1', function() { assert.equal(ip.loopback(), '127.0.0.1') }); }); describe('ipv4', function() { it('should respond with 127.0.0.1', function() { assert.equal(ip.loopback('ipv4'), '127.0.0.1') }); }); describe('ipv6', function() { it('should respond with fe80::1', function() { assert.equal(ip.loopback('ipv6'), 'fe80::1') }); }); }); describe('isLoopback() method', function() { describe('127.0.0.1', function() { it('should respond with true', function() { assert.ok(ip.isLoopback('127.0.0.1')) }); }); describe('127.8.8.8', function () { it('should respond with true', function () { assert.ok(ip.isLoopback('127.8.8.8')) }); }); describe('8.8.8.8', function () { it('should respond with false', function () { assert.equal(ip.isLoopback('8.8.8.8'), false); }); }); describe('fe80::1', function() { it('should respond with true', function() { assert.ok(ip.isLoopback('fe80::1')) }); }); describe('::1', function() { it('should respond with true', function() { assert.ok(ip.isLoopback('::1')) }); }); describe('::', function() { it('should respond with true', function() { assert.ok(ip.isLoopback('::')) }); }); }); describe('address() method', function() { describe('undefined', function() { it('should respond with a private ip', function() { assert.ok(ip.isPrivate(ip.address())); }); }); describe('private', function() { [ undefined, 'ipv4', 'ipv6' ].forEach(function(family) { describe(family, function() { it('should respond with a private ip', function() { assert.ok(ip.isPrivate(ip.address('private', family))); }); }); }); }); var interfaces = os.networkInterfaces(); Object.keys(interfaces).forEach(function(nic) { describe(nic, function() { [ undefined, 'ipv4' ].forEach(function(family) { describe(family, function() { it('should respond with an ipv4 address', function() { var addr = ip.address(nic, family); assert.ok(!addr || net.isIPv4(addr)); }); }); }); describe('ipv6', function() { it('should respond with an ipv6 address', function() { var addr = ip.address(nic, 'ipv6'); assert.ok(!addr || net.isIPv6(addr)); }); }) }); }); }); describe('toLong() method', function() { it('should respond with a int', function() { assert.equal(ip.toLong('127.0.0.1'), 2130706433); assert.equal(ip.toLong('255.255.255.255'), 4294967295); }); }); describe('fromLong() method', function() { it('should repond with ipv4 address', function() { assert.equal(ip.fromLong(2130706433), '127.0.0.1'); assert.equal(ip.fromLong(4294967295), '255.255.255.255'); }); }) }); PK f�z[�0��� � buffer-test.jsnu �Iw�� var assert = require('assert'); var OffsetBuffer = require('../'); describe('OffsetBuffer', function() { var o; beforeEach(function() { o = new OffsetBuffer(); }); describe('.take()', function() { it('should return empty buffer', function() { var b = new Buffer('hello world'); o.push(b); var r = o.take(0); assert.equal(r.length, 0); assert.equal(o.size, b.length); }); it('should return the first buffer itself', function() { var b = new Buffer('hello world'); o.push(b); var r = o.take(b.length); assert(r === b); assert(o.isEmpty()); }); it('should return the slice of the buffer ', function() { var b = new Buffer('hello world'); o.push(b); assert.equal(o.take(5).toString(), 'hello'); assert.equal(o.take(1).toString(), ' '); assert.equal(o.take(5).toString(), 'world'); assert(o.isEmpty()); }); it('should concat buffers', function() { o.push(new Buffer('hello')); o.push(new Buffer(' ')); o.push(new Buffer('world!')); assert.equal(o.take(11).toString(), 'hello world'); assert.equal(o.take(1).toString(), '!'); assert(o.isEmpty()); }); }); describe('.skip', function() { it('should skip bytes', function() { o.push(new Buffer('hello ')); o.push(new Buffer('world')); o.push(new Buffer(' oh gosh')); assert.equal(o.take(2).toString(), 'he'); o.skip(1); assert.equal(o.take(2).toString(), 'lo'); o.skip(1); assert.equal(o.take(2).toString(), 'wo'); o.skip(4); assert.equal(o.take(7).toString(), 'oh gosh'); assert(o.isEmpty()); }); }); describe('.peekUInt8', function() { it('should return and not move by one byte', function() { o.push(new Buffer([ 0x1, 0x2 ])); assert.equal(o.peekUInt8(), 1); assert.equal(o.readUInt8(), 1); assert.equal(o.peekUInt8(), 2); assert.equal(o.readUInt8(), 2); assert(o.isEmpty()); }); }); describe('.peekInt8', function() { it('should return signed number', function() { o.push(new Buffer([ 0x80 ])); assert.equal(o.peekInt8(), -128); assert.equal(o.readInt8(), -128); assert(o.isEmpty()); }); }); describe('.readUInt8', function() { it('should return and move by one byte', function() { o.push(new Buffer([ 0x1, 0x2 ])); o.push(new Buffer([ 0x3, 0x4 ])); assert.equal(o.readUInt8(), 1); assert.equal(o.readUInt8(), 2); assert.equal(o.readUInt8(), 3); assert.equal(o.readUInt8(), 4); assert(o.isEmpty()); }); }); describe('.readInt8', function() { it('should return signed number', function() { o.push(new Buffer([ 0x8f, 0x7f ])); assert.equal(o.readInt8(), -113); assert.equal(o.readInt8(), 127); assert(o.isEmpty()); }); }); describe('.readUInt16LE', function() { it('should return and move by two bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3 ])); o.push(new Buffer([ 0x4, 0x5, 0x6 ])); assert.equal(o.readUInt16LE(), 0x0201); assert.equal(o.readUInt16LE(), 0x0403); assert.equal(o.readUInt16LE(), 0x0605); assert(o.isEmpty()); }); it('should return and move by two bytes (regression #1)', function() { o.push(new Buffer([ 0x1 ])); o.push(new Buffer([ 0x2, 0x3, 0x4 ])); assert.equal(o.readUInt16LE(), 0x0201); assert.equal(o.readUInt16LE(), 0x0403); assert(o.isEmpty()); }); }); describe('.readInt16LE', function() { it('should return signed number', function() { o.push(new Buffer([ 0x23, 0x81 ])); assert.equal(o.readInt16LE(), -32477); assert(o.isEmpty()); }); }); describe('.readUInt24LE', function() { it('should return and move by three bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3, 0x4, 0x5 ])); o.push(new Buffer([ 0x6, 0x7 ])); o.push(new Buffer([ 0x8, 0x9 ])); assert.equal(o.readUInt24LE(), 0x030201); assert.equal(o.readUInt24LE(), 0x060504); assert.equal(o.readUInt24LE(), 0x090807); assert(o.isEmpty()); }); it('should return and move by three bytes (regression #1)', function() { o.push(new Buffer([ 0x1, 0x2 ])); o.push(new Buffer([ 0x3 ])); assert.equal(o.readUInt24LE(), 0x030201); assert.equal(o.buffers.length, 0); assert(o.isEmpty()); }); }); describe('.readInt24LE', function() { it('should return signed number', function() { o.push(new Buffer([ 0x23, 0x45, 0x81 ])); assert.equal(o.readInt24LE(), -8305373); assert(o.isEmpty()); }); }); describe('.readUInt32LE', function() { it('should return and move by four bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 ])); o.push(new Buffer([ 0x8, 0x9, 0xa ])); o.push(new Buffer([ 0xb, 0xc, 0xd ])); o.push(new Buffer([ 0xe, 0xf, 0x10 ])); assert.equal(o.readUInt32LE(), 0x04030201); assert.equal(o.readUInt32LE(), 0x08070605); assert.equal(o.readUInt32LE(), 0x0c0b0a09); assert.equal(o.readUInt32LE(), 0x100f0e0d); assert(o.isEmpty()); }); it('should return and move by four bytes (regression #1)', function() { o.push(new Buffer([ 0x1, 0x2, 0x3 ])); o.push(new Buffer([ 0x4 ])); assert.equal(o.readUInt32LE(), 0x04030201); assert.equal(o.buffers.length, 0); assert(o.isEmpty()); }); }); describe('.readInt32LE', function() { it('should return signed number', function() { o.push(new Buffer([ 0xff, 0xff, 0xff, 0xff ])); assert.equal(o.readInt32LE(), -1); assert(o.isEmpty()); }); }); describe('.readUInt16BE', function() { it('should return and move by two bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3 ])); o.push(new Buffer([ 0x4, 0x5, 0x6 ])); assert.equal(o.readUInt16BE(), 0x0102); assert.equal(o.readUInt16BE(), 0x0304); assert.equal(o.readUInt16BE(), 0x0506); assert(o.isEmpty()); }); }); describe('.readInt16BE', function() { it('should return signed number', function() { o.push(new Buffer([ 0x81, 0x23 ])); assert.equal(o.readInt16BE(), -32477); assert(o.isEmpty()); }); }); describe('.readUInt24BE', function() { it('should return and move by three bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3, 0x4, 0x5 ])); o.push(new Buffer([ 0x6, 0x7 ])); o.push(new Buffer([ 0x8, 0x9 ])); assert.equal(o.readUInt24BE(), 0x010203); assert.equal(o.readUInt24BE(), 0x040506); assert.equal(o.readUInt24BE(), 0x070809); assert(o.isEmpty()); }); }); describe('.readInt24BE', function() { it('should return signed number', function() { o.push(new Buffer([ 0x81, 0x45, 0x23 ])); assert.equal(o.readInt24BE(), -8305373); assert(o.isEmpty()); }); }); describe('.readUInt32BE', function() { it('should return and move by four bytes', function() { o.push(new Buffer([ 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 ])); o.push(new Buffer([ 0x8, 0x9, 0xa ])); o.push(new Buffer([ 0xb, 0xc, 0xd ])); o.push(new Buffer([ 0xe, 0xf, 0x10 ])); assert.equal(o.readUInt32BE(), 0x01020304); assert.equal(o.readUInt32BE(), 0x05060708); assert.equal(o.readUInt32BE(), 0x090a0b0c); assert.equal(o.readUInt32BE(), 0x0d0e0f10); assert(o.isEmpty()); }); it('should return positive values', function() { o.push(new Buffer([ 0xff, 0xff, 0xff, 0xff ])); assert.equal(o.readUInt32BE(), 0xffffffff); assert(o.isEmpty()); }); }); describe('.readInt32BE', function() { it('should return signed number', function() { o.push(new Buffer([ 0xff, 0xff, 0xff, 0xff ])); assert.equal(o.readInt32BE(), -1); assert(o.isEmpty()); }); }); describe('.has', function() { it('should properly check the amount of the remaining bytes', function() { o.push(new Buffer([ 1, 2, 3 ])); assert(o.has(3)); assert.equal(o.readUInt8(), 0x01); assert(!o.has(3)); assert(o.has(2)); assert.equal(o.readUInt16BE(), 0x0203); assert(!o.has(1)); }); }); }); PK �z[���� � .index.js.un~nu �Iw�� Vim�UnDo� �0IK5<}� W�qT]�j�����2�Z � Q6c� _� � ���� Q6c� � � � 5�_� � ���� Q6c� � � � require("test").run(exports);5��PK �z[�j�6 6 common-index.jsnu �Iw�� "use strict"; require("test").run(require("./index"))PK �z[��P P index.jsnu �Iw�� // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. "use strict"; // test using assert var qs = require('../'); // folding block, commented to pass gjslint // {{{ // [ wonkyQS, canonicalQS, obj ] var qsTestCases = [ ['foo=918854443121279438895193', 'foo=918854443121279438895193', {'foo': '918854443121279438895193'}], ['foo=bar', 'foo=bar', {'foo': 'bar'}], ['foo=bar&foo=quux', 'foo=bar&foo=quux', {'foo': ['bar', 'quux']}], ['foo=1&bar=2', 'foo=1&bar=2', {'foo': '1', 'bar': '2'}], ['my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F', 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F', {'my weird field': 'q1!2"\'w$5&7/z8)?' }], ['foo%3Dbaz=bar', 'foo%3Dbaz=bar', {'foo=baz': 'bar'}], ['foo=baz=bar', 'foo=baz%3Dbar', {'foo': 'baz=bar'}], ['str=foo&arr=1&arr=2&arr=3&somenull=&undef=', 'str=foo&arr=1&arr=2&arr=3&somenull=&undef=', { 'str': 'foo', 'arr': ['1', '2', '3'], 'somenull': '', 'undef': ''}], [' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}], // disable test that fails ['foo=%zx', 'foo=%25zx', {'foo': '%zx'}], ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }], // See: https://github.com/joyent/node/issues/1707 ['hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', 'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', { hasOwnProperty: 'x', toString: 'foo', valueOf: 'bar', __defineGetter__: 'baz' }], // See: https://github.com/joyent/node/issues/3058 ['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }] ]; // [ wonkyQS, canonicalQS, obj ] var qsColonTestCases = [ ['foo:bar', 'foo:bar', {'foo': 'bar'}], ['foo:bar;foo:quux', 'foo:bar;foo:quux', {'foo': ['bar', 'quux']}], ['foo:1&bar:2;baz:quux', 'foo:1%26bar%3A2;baz:quux', {'foo': '1&bar:2', 'baz': 'quux'}], ['foo%3Abaz:bar', 'foo%3Abaz:bar', {'foo:baz': 'bar'}], ['foo:baz:bar', 'foo:baz%3Abar', {'foo': 'baz:bar'}] ]; // [wonkyObj, qs, canonicalObj] var extendedFunction = function() {}; extendedFunction.prototype = {a: 'b'}; var qsWeirdObjects = [ [{regexp: /./g}, 'regexp=', {'regexp': ''}], [{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}], [{fn: function() {}}, 'fn=', {'fn': ''}], [{fn: new Function('')}, 'fn=', {'fn': ''}], [{math: Math}, 'math=', {'math': ''}], [{e: extendedFunction}, 'e=', {'e': ''}], [{d: new Date()}, 'd=', {'d': ''}], [{d: Date}, 'd=', {'d': ''}], [{f: new Boolean(false), t: new Boolean(true)}, 'f=&t=', {'f': '', 't': ''}], [{f: false, t: true}, 'f=false&t=true', {'f': 'false', 't': 'true'}], [{n: null}, 'n=', {'n': ''}], [{nan: NaN}, 'nan=', {'nan': ''}], [{inf: Infinity}, 'inf=', {'inf': ''}] ]; // }}} var qsNoMungeTestCases = [ ['', {}], ['foo=bar&foo=baz', {'foo': ['bar', 'baz']}], ['blah=burp', {'blah': 'burp'}], ['gragh=1&gragh=3&goo=2', {'gragh': ['1', '3'], 'goo': '2'}], ['frappucino=muffin&goat%5B%5D=scone&pond=moose', {'frappucino': 'muffin', 'goat[]': 'scone', 'pond': 'moose'}], ['trololol=yes&lololo=no', {'trololol': 'yes', 'lololo': 'no'}] ]; exports['test basic'] = function(assert) { assert.strictEqual('918854443121279438895193', qs.parse('id=918854443121279438895193').id, 'prase id=918854443121279438895193'); }; exports['test that the canonical qs is parsed properly'] = function(assert) { qsTestCases.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[0]), 'parse ' + testCase[0]); }); }; exports['test that the colon test cases can do the same'] = function(assert) { qsColonTestCases.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[0], ';', ':'), 'parse ' + testCase[0] + ' -> ; :'); }); }; exports['test the weird objects, that they get parsed properly'] = function(assert) { qsWeirdObjects.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[1]), 'parse ' + testCase[1]); }); }; exports['test non munge test cases'] = function(assert) { qsNoMungeTestCases.forEach(function(testCase) { assert.deepEqual(testCase[0], qs.stringify(testCase[1], '&', '=', false), 'stringify ' + JSON.stringify(testCase[1]) + ' -> & ='); }); }; exports['test the nested qs-in-qs case'] = function(assert) { var f = qs.parse('a=b&q=x%3Dy%26y%3Dz'); f.q = qs.parse(f.q); assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } }, 'parse a=b&q=x%3Dy%26y%3Dz'); }; exports['test nested in colon'] = function(assert) { var f = qs.parse('a:b;q:x%3Ay%3By%3Az', ';', ':'); f.q = qs.parse(f.q, ';', ':'); assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } }, 'parse a:b;q:x%3Ay%3By%3Az -> ; :'); }; exports['test stringifying'] = function(assert) { qsTestCases.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[2]), 'stringify ' + JSON.stringify(testCase[2])); }); qsColonTestCases.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[2], ';', ':'), 'stringify ' + JSON.stringify(testCase[2]) + ' -> ; :'); }); qsWeirdObjects.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[0]), 'stringify ' + JSON.stringify(testCase[0])); }); }; exports['test stringifying nested'] = function(assert) { var f = qs.stringify({ a: 'b', q: qs.stringify({ x: 'y', y: 'z' }) }); assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz', JSON.stringify({ a: 'b', 'qs.stringify -> q': { x: 'y', y: 'z' } })); var threw = false; try { qs.parse(undefined); } catch(error) { threw = true; } assert.ok(!threw, "does not throws on undefined"); }; exports['test nested in colon'] = function(assert) { var f = qs.stringify({ a: 'b', q: qs.stringify({ x: 'y', y: 'z' }, ';', ':') }, ';', ':'); assert.equal(f, 'a:b;q:x%3Ay%3By%3Az', 'stringify ' + JSON.stringify({ a: 'b', 'qs.stringify -> q': { x: 'y', y: 'z' } }) + ' -> ; : '); assert.deepEqual({}, qs.parse(), 'parse undefined'); }; PK �z[��(4 4 tap-index.jsnu �Iw�� "use strict"; require("retape")(require("./index"))PK ��|[� /� � benchmark/index.jsnu �Iw�� 'use strict'; var timeSafeCompare = require('../../lib/index'); function random(length) { length = length || 32; var result = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-+/*[]{}-=\|;\':\"<>?,./"; for( var i=0; i < length; i++ ){ result += possible.charAt(Math.floor(Math.random() * possible.length)); } return result; } function run(count) { count = count || 100*1000; console.log('benchmark count: ' + count/1000 + 'k'); console.time('benchmark'); while(count--){ timeSafeCompare(random(), random()); } console.timeEnd('benchmark'); } run(100000); module.exports = run; PK ��|[��� unit/index.jsnu �Iw�� 'use strict'; var assert = require('assert'); var timeSafeCompare = require('../../lib/index'); process.on('error', function (e) { console.log('caught: ' + e); }); function testEqual(a, b) { assert(timeSafeCompare(a, b)); // lets also do a parity check with the strict equal to operator assert(a === b); } function testNotEqual(a, b) { assert(!timeSafeCompare(a, b)); // lets also do a parity check with the strict not equal to operator assert(a !== b); } // note: lets also make sure tsscmp can be inline replaced for any types - // just incase if anyone is interested // positive tests testEqual('127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935', '127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935', 'test '); testEqual('a', 'a'); testEqual('', ''); testEqual(undefined, undefined); testEqual(true, true); testEqual(false, false); (function () { var a = { a: 1 }; testEqual(a, a); })(); (function () { function f1() { return 1; }; testEqual(f1, f1); })(); // negative tests testNotEqual(''); testNotEqual('a', 'b'); testNotEqual('a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); testNotEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'a'); testNotEqual('alpha', 'beta'); testNotEqual(false, true); testNotEqual(false, undefined); testNotEqual(function () { }, function () { }); testNotEqual({}, {}); testNotEqual({ a: 1 }, { a: 1 }); testNotEqual({ a: 1 }, { a: 2 }); testNotEqual([1, 2], [1, 2]); testNotEqual([1, 2], [1, 2, 3]); (function () { var a = { p: 1 }; var b = { p: 1 }; testNotEqual(a, b); })(); (function () { function f1() { return 1; }; function f2() { return 1; }; testNotEqual(f1, f2); })(); console.log('Success: all tests complete.'); PK �z[�� bL7 L7 api-test.jsnu �Iw�� PK f�z[�0��� � �7 buffer-test.jsnu �Iw�� PK �z[���� � IX .index.js.un~nu �Iw�� PK �z[�j�6 6 U\ common-index.jsnu �Iw�� PK �z[��P P �\ index.jsnu �Iw�� PK �z[��(4 4 Rz tap-index.jsnu �Iw�� PK ��|[� /� � �z benchmark/index.jsnu �Iw�� PK ��|[��� �} unit/index.jsnu �Iw�� PK h 2�
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка