diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/README.md b/lib/node_modules/@stdlib/utils/json-patch/base/unset/README.md
new file mode 100644
index 000000000000..f4a083201fd5
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/README.md
@@ -0,0 +1,183 @@
+
+
+# unset
+
+> Immutably unset a value at a path in a document using structural sharing.
+
+
+
+
+
+This function immutably unsets a value at a specified path in a document. Only objects and arrays along the path are shallow-cloned; all other subtrees retain their original references (structural sharing).
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var unset = require( '@stdlib/utils/json-patch/base/unset' );
+```
+
+#### unset( document, tokens )
+
+Immutably unsets a value at a path in a document using structural sharing.
+
+```javascript
+var doc = {
+ 'a': {
+ 'b': 1,
+ 'c': 2
+ }
+};
+var out = unset( doc, [ 'a', 'b' ] );
+// returns { 'a': { 'c': 2 } }
+
+var bool = ( doc.a === out.a );
+// returns false
+
+bool = ( doc === out );
+// returns false
+```
+
+```javascript
+var doc = {
+ 'a': [ 1, 2, 3 ]
+};
+var out = unset( doc, [ 'a', '1' ] );
+// returns { 'a': [ 1, 3 ] }
+```
+
+
+
+
+
+
+
+
+
+## Notes
+
+- Only objects and arrays along the path are shallow-cloned. All other subtrees keep their original references (structural sharing).
+- The function throws an `Error` if `tokens` is empty (cannot unset the root of a document).
+- The function throws an `Error` if any token is an unsafe value (e.g., `__proto__`, `constructor`).
+- The function throws a `TypeError` if an intermediate path segment references a non-traversable value (e.g., a string or number).
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var unset = require( '@stdlib/utils/json-patch/base/unset' );
+
+// Unset a value at a shallow path:
+var doc = {
+ 'a': 1,
+ 'b': 2
+};
+var out = unset( doc, [ 'a' ] );
+console.log( out );
+/* =>
+ {
+ 'b': 2
+ }
+*/
+
+// Unset a value at a deep path:
+doc = {
+ 'a': {
+ 'b': {
+ 'c': 1,
+ 'd': 2
+ }
+ }
+};
+out = unset( doc, [ 'a', 'b', 'c' ] );
+console.log( out );
+/* =>
+ {
+ 'a': {
+ 'b': {
+ 'd': 2
+ }
+ }
+ }
+*/
+
+// Unset an element from an array:
+doc = {
+ 'x': [ 'a', 'b', 'c' ]
+};
+out = unset( doc, [ 'x', '1' ] );
+console.log( out );
+/* =>
+ {
+ 'x': [ 'a', 'c' ]
+ }
+*/
+
+// Structural sharing (unchanged subtrees keep references):
+doc = {
+ 'a': {
+ 'b': 1,
+ 'c': 2
+ },
+ 'd': {
+ 'e': 3
+ }
+};
+out = unset( doc, [ 'a', 'b' ] );
+console.log( out.d === doc.d );
+// => true
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/json-patch/base/unset/benchmark/benchmark.js
new file mode 100644
index 000000000000..03657137c47c
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/benchmark/benchmark.js
@@ -0,0 +1,108 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var format = require( '@stdlib/string/format' );
+var isPlainObject = require( '@stdlib/assert/is-plain-object' );
+var pkg = require( './../package.json' ).name;
+var unset = require( './../lib' );
+
+
+// MAIN //
+
+bench( format( '%s::shallow_path', pkg ), function benchmark( b ) {
+ var doc;
+ var out;
+ var i;
+
+ doc = {
+ 'a': 1,
+ 'b': 2,
+ 'c': 3
+ };
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = unset( doc, [ 'a' ] );
+ if ( !isPlainObject( out ) ) {
+ b.fail( 'should return an object' );
+ }
+ }
+ b.toc();
+ if ( !isPlainObject( out ) ) {
+ b.fail( 'should return a plain object' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( format( '%s::deep_path', pkg ), function benchmark( b ) {
+ var doc;
+ var out;
+ var i;
+
+ doc = {
+ 'a': {
+ 'b': {
+ 'c': {
+ 'd': 1
+ }
+ }
+ }
+ };
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = unset( doc, [ 'a', 'b', 'c', 'd' ] );
+ if ( !isPlainObject( out ) ) {
+ b.fail( 'should return an object' );
+ }
+ }
+ b.toc();
+ if ( !isPlainObject( out ) ) {
+ b.fail( 'should return a plain object' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( format( '%s::array', pkg ), function benchmark( b ) {
+ var doc;
+ var out;
+ var i;
+
+ doc = [ 1, 2, 3, 4, 5 ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = unset( doc, [ '2' ] );
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return an object/array' );
+ }
+ }
+ b.toc();
+ if ( typeof out !== 'object' ) {
+ b.fail( 'should return an object/array' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/repl.txt b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/repl.txt
new file mode 100644
index 000000000000..eae2c728f318
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/repl.txt
@@ -0,0 +1,31 @@
+
+{{alias}}( document, tokens )
+ Immutably unsets a value at a path in a document using structural sharing.
+
+ Only objects and arrays along the path are shallow-cloned. All other
+ subtrees keep their original references.
+
+ Parameters
+ ----------
+ document: Object|Array
+ Source document.
+
+ tokens: Array
+ Array of reference tokens.
+
+ Returns
+ -------
+ out: Object|Array
+ New document with the value at the specified path removed.
+
+ Examples
+ --------
+ > var doc = { 'a': { 'b': 1, 'c': 2 } };
+ > var out = {{alias}}( doc, [ 'a', 'b' ] )
+ { 'a': { 'c': 2 } }
+ > var bool = ( doc === out )
+ false
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/index.d.ts
new file mode 100644
index 000000000000..38227983eba3
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/index.d.ts
@@ -0,0 +1,52 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+/**
+* Immutably unsets a value at a path in a document using structural sharing.
+*
+* @param document - source document
+* @param tokens - array of reference tokens
+* @throws tokens must not be empty
+* @throws tokens must not contain unsafe tokens
+* @throws intermediate path segments must reference objects or arrays
+* @returns new document with the value at the specified path removed
+*
+* @example
+* var doc = {
+* 'a': {
+* 'b': 1,
+* 'c': 2
+* }
+* };
+* var out = unset( doc, [ 'a', 'b' ] );
+* // returns { 'a': { 'c': 2 } }
+*
+* var bool = ( doc.a === out.a );
+* // returns false
+*
+* bool = ( doc === out );
+* // returns false
+*/
+declare function unset( document: Array | Record, tokens: Array ): any;
+
+
+// EXPORTS //
+
+export = unset;
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/test.ts b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/test.ts
new file mode 100644
index 000000000000..81a574f2cd5b
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/docs/types/test.ts
@@ -0,0 +1,35 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import unset = require( './index' );
+
+
+// TESTS //
+
+// The function returns any...
+{
+ unset( { 'a': { 'b': 1 } }, [ 'a', 'b' ] ); // $ExpectType any
+ unset( [ 1, 2, 3 ], [ '0' ] ); // $ExpectType any
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ unset(); // $ExpectError
+ unset( { 'a': 1 } ); // $ExpectError
+ unset( { 'a': 1 }, [ 'a' ], 99 ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/examples/index.js b/lib/node_modules/@stdlib/utils/json-patch/base/unset/examples/index.js
new file mode 100644
index 000000000000..11bea4165be4
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/examples/index.js
@@ -0,0 +1,81 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var unset = require( './../lib' );
+
+// Unset a value at a shallow path:
+var doc = {
+ 'a': 1,
+ 'b': 2
+};
+var out = unset( doc, [ 'a' ] );
+console.log( out );
+/* =>
+ {
+ 'b': 2
+ }
+*/
+
+// Unset a value at a deep path:
+doc = {
+ 'a': {
+ 'b': {
+ 'c': 1,
+ 'd': 2
+ }
+ }
+};
+out = unset( doc, [ 'a', 'b', 'c' ] );
+console.log( out );
+/* =>
+ {
+ 'a': {
+ 'b': {
+ 'd': 2
+ }
+ }
+ }
+*/
+
+// Unset an element from an array:
+doc = {
+ 'x': [ 'a', 'b', 'c' ]
+};
+out = unset( doc, [ 'x', '1' ] );
+console.log( out );
+/* =>
+ {
+ 'x': [ 'a', 'c' ]
+ }
+*/
+
+// Structural sharing (unchanged subtrees keep references):
+doc = {
+ 'a': {
+ 'b': 1,
+ 'c': 2
+ },
+ 'd': {
+ 'e': 3
+ }
+};
+out = unset( doc, [ 'a', 'b' ] );
+console.log( out.d === doc.d );
+// => true
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/index.js b/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/index.js
new file mode 100644
index 000000000000..d6cb59bed4e5
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/index.js
@@ -0,0 +1,52 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Immutably unset a value at a path in a document using structural sharing.
+*
+* @module @stdlib/utils/json-patch/base/unset
+*
+* @example
+* var unset = require( '@stdlib/utils/json-patch/base/unset' );
+*
+* var doc = {
+* 'a': {
+* 'b': 1,
+* 'c': 2
+* }
+* };
+* var out = unset( doc, [ 'a', 'b' ] );
+* // returns { 'a': { 'c': 2 } }
+*
+* var bool = ( doc.a === out.a );
+* // returns false
+*
+* bool = ( doc === out );
+* // returns false
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/main.js b/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/main.js
new file mode 100644
index 000000000000..0640aafd5023
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/lib/main.js
@@ -0,0 +1,106 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isArray = require( '@stdlib/assert/is-array' );
+var isPlainObject = require( '@stdlib/assert/is-plain-object' );
+var format = require( '@stdlib/string/format' );
+var copy = require( '@stdlib/utils/copy' );
+var isSafeToken = require( '@stdlib/utils/json-pointer/base/assert/is-safe-token' );
+var resolveToken = require( '@stdlib/utils/json-pointer/base/resolve-token' );
+
+
+// MAIN //
+
+/**
+* Immutably unsets a value at a path in a document using structural sharing.
+*
+* @param {(Object|Array)} document - source document
+* @param {Array} tokens - array of reference tokens
+* @throws {Error} tokens must not be empty
+* @throws {Error} tokens must not contain unsafe tokens
+* @throws {TypeError} intermediate path segments must reference objects or arrays
+* @returns {(Object|Array)} new document with the value at the specified path removed
+*
+* @example
+* var doc = {
+* 'a': {
+* 'b': 1,
+* 'c': 2
+* }
+* };
+* var out = unset( doc, [ 'a', 'b' ] );
+* // returns { 'a': { 'c': 2 } }
+*
+* var bool = ( doc.a === out.a );
+* // returns false
+*
+* bool = ( doc === out );
+* // returns false
+*/
+function unset( document, tokens ) {
+ var current;
+ var child;
+ var root;
+ var key;
+ var i;
+
+ if ( tokens.length === 0 ) {
+ throw new Error( 'invalid argument. Cannot unset the root of a document.' );
+ }
+
+ root = copy( document, 1 );
+ current = root;
+
+ // Walk all tokens except the last, cloning each level:
+ for ( i = 0; i < tokens.length - 1; i++ ) {
+ if ( !isSafeToken( tokens[ i ] ) ) {
+ throw new Error( format( 'invalid argument. Token contains an unsafe value. Value: `%s`.', tokens[ i ] ) );
+ }
+ key = resolveToken( current, tokens[ i ] );
+
+ if ( !isPlainObject( current[ key ] ) && !isArray( current[ key ] ) ) {
+ throw new TypeError( format( 'invalid argument. Path references a non-traversable value at token `%s`.', tokens[ i ] ) );
+ }
+ child = copy( current[ key ], 1 );
+ current[ key ] = child;
+ current = child;
+ }
+
+ // Remove the value at the final token:
+ if ( !isSafeToken( tokens[ tokens.length - 1 ] ) ) {
+ throw new Error( format( 'invalid argument. Token contains an unsafe value. Value: `%s`.', tokens[ tokens.length - 1 ] ) );
+ }
+ key = resolveToken( current, tokens[ tokens.length - 1 ] );
+
+ if ( isArray( current ) ) {
+ current.splice( key, 1 );
+ } else {
+ delete current[ key ];
+ }
+
+ return root;
+}
+
+
+// EXPORTS //
+
+module.exports = unset;
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/package.json b/lib/node_modules/@stdlib/utils/json-patch/base/unset/package.json
new file mode 100644
index 000000000000..916c8e1ab383
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/package.json
@@ -0,0 +1,69 @@
+{
+ "name": "@stdlib/utils/json-patch/base/unset",
+ "version": "0.0.0",
+ "description": "Immutably unset a value at a path in a document using structural sharing.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdutils",
+ "utilities",
+ "utility",
+ "utils",
+ "util",
+ "base",
+ "json",
+ "patch",
+ "json-patch",
+ "rfc6902",
+ "unset",
+ "remove",
+ "delete",
+ "immutable",
+ "structural-sharing"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/utils/json-patch/base/unset/test/test.js b/lib/node_modules/@stdlib/utils/json-patch/base/unset/test/test.js
new file mode 100644
index 000000000000..6aa3cc93fc95
--- /dev/null
+++ b/lib/node_modules/@stdlib/utils/json-patch/base/unset/test/test.js
@@ -0,0 +1,249 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var unset = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof unset, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided an empty tokens array (cannot unset root)', function test( t ) {
+ var doc;
+
+ doc = {
+ 'a': 1
+ };
+ t.throws( badValue, Error, 'throws an error when provided empty tokens' );
+ t.end();
+
+ function badValue() {
+ unset( doc, [] );
+ }
+});
+
+tape( 'the function immutably removes a value at a shallow path', function test( t ) {
+ var expected;
+ var doc;
+ var out;
+
+ doc = {
+ 'a': 1,
+ 'b': 2
+ };
+ expected = {
+ 'b': 2
+ };
+
+ out = unset( doc, [ 'a' ] );
+ t.deepEqual( out, expected, 'returns expected value' );
+ t.notEqual( out, doc, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function immutably removes a value at a deep path', function test( t ) {
+ var expected;
+ var doc;
+ var out;
+
+ doc = {
+ 'a': {
+ 'b': {
+ 'c': 1,
+ 'd': 2
+ }
+ }
+ };
+ expected = {
+ 'a': {
+ 'b': {
+ 'd': 2
+ }
+ }
+ };
+
+ out = unset( doc, [ 'a', 'b', 'c' ] );
+ t.deepEqual( out, expected, 'returns expected value' );
+ t.notEqual( out, doc, 'returns expected value' );
+ t.notEqual( out.a, doc.a, 'returns expected value' );
+ t.notEqual( out.a.b, doc.a.b, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function uses structural sharing for unchanged subtrees', function test( t ) {
+ var doc;
+ var out;
+
+ doc = {
+ 'a': {
+ 'b': {
+ 'c': 1
+ }
+ },
+ 'd': {
+ 'e': 2
+ }
+ };
+ out = unset( doc, [ 'a', 'b', 'c' ] );
+
+ t.strictEqual( out.d, doc.d, 'returns expected value' );
+ t.notEqual( out.a, doc.a, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function removes an element from an array', function test( t ) {
+ var expected;
+ var doc;
+ var out;
+
+ doc = [ 1, 2, 3 ];
+ expected = [ 1, 3 ];
+
+ out = unset( doc, [ '1' ] );
+ t.deepEqual( out, expected, 'returns expected value' );
+ t.notEqual( out, doc, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function removes elements in nested arrays and objects', function test( t ) {
+ var expected;
+ var doc;
+ var out;
+
+ doc = {
+ 'a': [{
+ 'b': 1
+ }, {
+ 'b': 2
+ }]
+ };
+ expected = {
+ 'a': [{
+ 'b': 2
+ }]
+ };
+
+ out = unset( doc, [ 'a', '0' ] );
+ t.deepEqual( out, expected, 'returns expected value' );
+ t.strictEqual( out.a[ 0 ], doc.a[ 1 ], 'returns expected value' );
+ t.notEqual( out.a, doc.a, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function throws an error if a token is an unsafe value (prototype pollution vector)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '__proto__',
+ 'constructor',
+ 'prototype'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ unset( {}, [ value ] );
+ };
+ }
+});
+
+tape( 'the function throws an error if an intermediate token is an unsafe value', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '__proto__',
+ 'constructor',
+ 'prototype'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ unset({
+ 'a': {
+ 'b': 1
+ }
+ }, [ value, 'b' ] );
+ };
+ }
+});
+
+tape( 'the function throws a type error if an intermediate path segment references a non-traversable value', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '',
+ 42,
+ true,
+ null
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws when provided ' + ( typeof values[ i ] ) );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ unset({
+ 'a': value
+ }, [ 'a', 'b' ] );
+ };
+ }
+});
+
+tape( 'the function does not mutate the original document', function test( t ) {
+ var doc;
+ var out;
+
+ doc = {
+ 'a': {
+ 'b': 1,
+ 'c': 2
+ }
+ };
+ out = unset( doc, [ 'a', 'b' ] );
+
+ t.strictEqual( doc.a.b, 1, 'returns expected value' );
+ t.strictEqual( out.a.b, void 0, 'returns expected value' );
+ t.strictEqual( out.a.c, 2, 'returns expected value' );
+
+ t.end();
+});