Alexandro.Net

Download README · GitHub release

@stackline/deep-copy

Compatibility-first legacy deep copying with cycle support and safe property handling.

npm version license GitHub repository Docs Reddit community

Documentation | npm | Issues | Repository

Current package version: 1.0.3


Why this package?

A compatibility-first maintained continuation of deep-copy@1.4.2 for legacy CommonJS, AMD, and classic-browser consumers. It preserves the small upstream contract while adding native ESM/types, safe dangerous-key writes, cycle support, a bounded composite-node limit, and current release engineering.

Stackline maintains this package independently. It is not affiliated with or endorsed by the original maintainer.

Compatibility

Item Value
Package @stackline/deep-copy@1.0.3
Node.js runtime >=4.0.0
CommonJS / primary entry ./index.js
ES module entry ./index.mjs
Type declarations ./index.d.ts

Supported runtimes

Installation

Install

Direct scoped installation:

npm install @stackline/deep-copy

Identity-preserving migration under the historical dependency key:

{
  "dependencies": {
    "deep-copy": "npm:@stackline/deep-copy@^1.0.1"
  }
}

Usage

Existing CommonJS imports remain unchanged:

const dcopy = require('deep-copy')
const cloned = dcopy({ nested: { value: 1 } })

Native ESM and the scoped key are also supported:

import dcopy from '@stackline/deep-copy'

Loading index.js as a classic browser script exposes window.dcopy. AMD loaders receive the callable factory result.

Security

This is a general-purpose copy helper, not a sanitizer. Getters and proxy traps can execute during the legacy enumerable walk, and copying a value does not make untrusted data safe. Report suspected vulnerabilities privately according to SECURITY.md.

API Surface

Contract

The upstream-observed behavior is preserved for numbers, strings, booleans, plain objects, dense arrays, Dates, and nested functions. In particular, non-cyclic repeated references are copied independently and inherited enumerable string keys keep the historical traversal behavior.

Two intentional safety extensions apply:

Traversal is iterative and stops before allocating more than 100,000 composite nodes, throwing a RangeError with code ERR_STACKLINE_DEEP_COPY_LIMIT.

Map, Set, RegExp, typed arrays, symbol keys, descriptors, prototype retention, and shared-reference preservation are not promised by the legacy default. See COMPATIBILITY_CONTRACT.md for exact edge behavior.

Local Development

git clone https://github.com/alexandroit/stackline-deep-copy.git
cd stackline-deep-copy
npm ci
npm run verify

Release tooling uses Node.js 24.20.0 and npm 11.19.0. The consumer runtime contract remains the one documented above.

Consumer Smoke Test

Run the repository's existing consumer/package check after installing development dependencies:

npm run test:smoke

Release Checklist

Run npm run verify and inspect the package contents before release. Publish a new version through the GitHub Actions publishing workflow, using the SHA-512 digest of the reviewed tarball. Verify the exact published version, tarball integrity, and npm provenance after the run.

License

MIT. The original copyright and attribution are preserved in LICENSE, NOTICE, and THIRD_PARTY_LICENSES.md.

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

Community and Links

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.