bunshin-clone 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -4
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
// src/index.ts
|
|
4
6
|
var EMPTY_OPTIONS = {};
|
|
5
7
|
var { hasOwnProperty: HAS_OWN } = Object.prototype;
|
|
6
8
|
var { toString: OBJECT_TO_STRING } = Object.prototype;
|
|
7
|
-
function bunshinClone(target, options) {
|
|
8
|
-
return clone(target, options ?? EMPTY_OPTIONS, /* @__PURE__ */ new WeakMap());
|
|
9
|
+
function bunshinClone(target, options, ref) {
|
|
10
|
+
return clone(target, options ?? EMPTY_OPTIONS, ref ?? /* @__PURE__ */ new WeakMap());
|
|
9
11
|
}
|
|
10
12
|
function clone(node, options, ref) {
|
|
11
13
|
if (!isObject(node)) {
|
|
@@ -193,11 +195,12 @@ function isUnsafeKey(key) {
|
|
|
193
195
|
* High-performance deep clone utility with descriptor support.
|
|
194
196
|
* Supports circular ref and complex built-in types.
|
|
195
197
|
*
|
|
196
|
-
* @version 1.0.
|
|
198
|
+
* @version 1.0.1
|
|
197
199
|
* @author Yusuke Kamiyamane
|
|
198
200
|
* @license MIT
|
|
199
201
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
|
200
202
|
* @see {@link https://github.com/y14e/bunshin-clone}
|
|
201
203
|
*/
|
|
202
204
|
|
|
203
|
-
|
|
205
|
+
exports.cloneWithDescriptors = cloneWithDescriptors;
|
|
206
|
+
exports.default = bunshinClone;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Supports circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.1
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
|
@@ -13,6 +13,9 @@ interface BunshinCloneOptions {
|
|
|
13
13
|
readonly preserveDescriptors?: boolean;
|
|
14
14
|
readonly strictDescriptors?: boolean;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
type Ref = WeakMap<object, unknown>;
|
|
17
|
+
type AnyObject = Record<PropertyKey, unknown>;
|
|
18
|
+
declare function bunshinClone(target: unknown, options?: BunshinCloneOptions, ref?: Ref): unknown;
|
|
19
|
+
declare function cloneWithDescriptors(node: AnyObject, options: BunshinCloneOptions, ref: Ref): AnyObject;
|
|
17
20
|
|
|
18
|
-
export { type BunshinCloneOptions, bunshinClone as default };
|
|
21
|
+
export { type BunshinCloneOptions, cloneWithDescriptors, bunshinClone as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Supports circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.1
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
|
@@ -13,6 +13,9 @@ interface BunshinCloneOptions {
|
|
|
13
13
|
readonly preserveDescriptors?: boolean;
|
|
14
14
|
readonly strictDescriptors?: boolean;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
type Ref = WeakMap<object, unknown>;
|
|
17
|
+
type AnyObject = Record<PropertyKey, unknown>;
|
|
18
|
+
declare function bunshinClone(target: unknown, options?: BunshinCloneOptions, ref?: Ref): unknown;
|
|
19
|
+
declare function cloneWithDescriptors(node: AnyObject, options: BunshinCloneOptions, ref: Ref): AnyObject;
|
|
17
20
|
|
|
18
|
-
export { type BunshinCloneOptions, bunshinClone as default };
|
|
21
|
+
export { type BunshinCloneOptions, cloneWithDescriptors, bunshinClone as default };
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
var EMPTY_OPTIONS = {};
|
|
3
3
|
var { hasOwnProperty: HAS_OWN } = Object.prototype;
|
|
4
4
|
var { toString: OBJECT_TO_STRING } = Object.prototype;
|
|
5
|
-
function bunshinClone(target, options) {
|
|
6
|
-
return clone(target, options ?? EMPTY_OPTIONS, /* @__PURE__ */ new WeakMap());
|
|
5
|
+
function bunshinClone(target, options, ref) {
|
|
6
|
+
return clone(target, options ?? EMPTY_OPTIONS, ref ?? /* @__PURE__ */ new WeakMap());
|
|
7
7
|
}
|
|
8
8
|
function clone(node, options, ref) {
|
|
9
9
|
if (!isObject(node)) {
|
|
@@ -191,11 +191,11 @@ function isUnsafeKey(key) {
|
|
|
191
191
|
* High-performance deep clone utility with descriptor support.
|
|
192
192
|
* Supports circular ref and complex built-in types.
|
|
193
193
|
*
|
|
194
|
-
* @version 1.0.
|
|
194
|
+
* @version 1.0.1
|
|
195
195
|
* @author Yusuke Kamiyamane
|
|
196
196
|
* @license MIT
|
|
197
197
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
|
198
198
|
* @see {@link https://github.com/y14e/bunshin-clone}
|
|
199
199
|
*/
|
|
200
200
|
|
|
201
|
-
export { bunshinClone as default };
|
|
201
|
+
export { cloneWithDescriptors, bunshinClone as default };
|