Skip to documentation

package

@stackline/deep-copy 1.0.5 — installation and API

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

Install @stackline/deep-copy

npm install @stackline/[email protected]

Package version: 1.0.5. Metadata verified: 2026-11-12. This is separate from the framework version and demonstration runtime.

Node.js requirement
{"node": ">=4.0.0"}
Accepted peer dependencies (declared ranges)
{}

Tested environments are described in the versioned README and linked source checks. A declared peer range is not evidence that every version in it was tested.

Versioned reference

This reference comes from the published @stackline/[email protected] README. Its upstream attribution and license remain with the source. Benchmark and security statements describe the cited tests and advisories, not a guarantee for every application.

@stackline/deep-copy

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

Documentation | npm | Issues | Repository

Current package version: 1.0.5


Why this package?

A compatibility-first maintained continuation of [email protected] 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/[email protected]
Node.js runtime >=4.0.0
CommonJS / primary entry ./index.js
ES module entry ./index.mjs
Type declarations ./index.d.ts

Supported runtimes

  • CommonJS/AMD/classic global: Node.js 4.0.0 and later plus equivalent ES5 browser environments with Object.defineProperty.
  • Native ESM entry: runtimes that support .mjs (tested on current supported Node lines).
  • Types: TypeScript 3.9 and current TypeScript.

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:

  • cycles point to the corresponding in-progress copy instead of overflowing the JavaScript call stack;
  • __proto__, constructor, and prototype are written as own data properties instead of invoking a destination setter.

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.

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

Examples and compatibility

The original example runtime is preserved. Its build is identified by source commit f07bec231ef2c2203bfe8ee1f1ffc5073730b5cd. Package version and runtime version must be checked independently.

Open the original example

Examples load only when requested. They have their own runtime and are separate from this reference.