{"id":15653256,"url":"https://github.com/jonschlinkert/shallow-clone","last_synced_at":"2025-04-09T08:11:44.567Z","repository":{"id":36201825,"uuid":"40506060","full_name":"jonschlinkert/shallow-clone","owner":"jonschlinkert","description":"Make a shallow clone of an object, array or primitive.","archived":false,"fork":false,"pushed_at":"2020-05-27T15:32:47.000Z","size":24,"stargazers_count":29,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T14:53:56.243Z","etag":null,"topics":["array","clone","object","regex","regular-expression","shallow"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"jonschlinkert","tidelift":"npm/shallow-clone"}},"created_at":"2015-08-10T21:02:38.000Z","updated_at":"2024-07-23T02:08:58.000Z","dependencies_parsed_at":"2022-09-26T21:30:59.571Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/shallow-clone","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fshallow-clone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fshallow-clone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fshallow-clone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fshallow-clone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/shallow-clone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999864,"owners_count":21031046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","clone","object","regex","regular-expression","shallow"],"created_at":"2024-10-03T12:45:08.386Z","updated_at":"2025-04-09T08:11:44.546Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jonschlinkert","https://tidelift.com/funding/github/npm/shallow-clone","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68"],"categories":[],"sub_categories":[],"readme":"# shallow-clone [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/shallow-clone.svg?style=flat)](https://www.npmjs.com/package/shallow-clone) [![NPM monthly downloads](https://img.shields.io/npm/dm/shallow-clone.svg?style=flat)](https://npmjs.org/package/shallow-clone) [![NPM total downloads](https://img.shields.io/npm/dt/shallow-clone.svg?style=flat)](https://npmjs.org/package/shallow-clone) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/shallow-clone.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/shallow-clone)\n\n\u003e Creates a shallow clone of any JavaScript value.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save shallow-clone\n```\n\n## Usage\n\n```js\nconst clone = require('shallow-clone');\n```\n\n**Supports**\n\n* array buffers\n* arrays\n* buffers\n* dates\n* errors\n* float32 arrays\n* float64 arrays\n* int16 arrays\n* int32 arrays\n* int8 arrays\n* maps\n* objects\n* primitives\n* regular expressions\n* sets\n* symbols\n* uint16 arrays\n* uint32 arrays\n* uint8 arrays\n* uint8clamped arrays\n\n## Arrays\n\nBy default, only the array itself is cloned (shallow), use [clone-deep](https://github.com/jonschlinkert/clone-deep) if you also need the elements in the array to be cloned.\n\n```js\nconst arr = [{ a: 0 }, { b: 1 }];\nconst foo = clone(arr);\n// foo =\u003e  [{ 'a': 0 }, { 'b': 1 }]\n\n// array is cloned\nassert(actual === expected); // false\n\n// array elements are not\nassert.deepEqual(actual[0], expected[0]); // true\n```\n\n## Objects\n\nOnly the object is shallow cloned, use [clone-deep](https://github.com/jonschlinkert/clone-deep) if you also need the values in the object to be cloned.\n\n```js\nconsole.log(clone({ a: 1, b: 2, c: 3 }));\n//=\u003e {a: 1, b: 2, c: 3 }\n```\n\n## RegExp\n\nClones regular expressions and flags, and preserves the `.lastIndex`.\n\n```js\nconst regex = clone(/foo/g); //=\u003e /foo/g\n// you can manually reset lastIndex if necessary\nregex.lastIndex = 0;\n```\n\n## Primitives\n\nSimply returns primitives unchanged.\n\n```js\nclone(0); //=\u003e 0\nclone('foo'); //=\u003e 'foo'\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the values of all enumerable-own-properties and symbols from one or more source objects… [more](https://github.com/jonschlinkert/assign-deep) | [homepage](https://github.com/jonschlinkert/assign-deep \"Deeply assign the values of all enumerable-own-properties and symbols from one or more source objects to a target object. Returns the target object.\")\n* [clone-deep](https://www.npmjs.com/package/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. | [homepage](https://github.com/jonschlinkert/clone-deep \"Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.\")\n* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object \"Returns true if an object was created by the `Object` constructor.\")\n* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of \"Get the native type of a value.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 20 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 2  | [doowb](https://github.com/doowb) |  \n| 1  | [jakub-g](https://github.com/jakub-g) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 15, 2019._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fshallow-clone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fshallow-clone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fshallow-clone/lists"}