MCPcopy
hub / github.com/Tencent/westore / cloneArray

Function cloneArray

packages/westore-example/miniprogram_npm/rfdc/index.js:25–42  ·  view source on GitHub ↗
(a, fn)

Source from the content-addressed store, hash-verified

23 return opts.proto ? cloneProto : clone
24
25 function cloneArray (a, fn) {
26 var keys = Object.keys(a)
27 var a2 = new Array(keys.length)
28 for (var i = 0; i < keys.length; i++) {
29 var k = keys[i]
30 var cur = a[k]
31 if (typeof cur !== 'object' || cur === null) {
32 a2[k] = cur
33 } else if (cur instanceof Date) {
34 a2[k] = new Date(cur)
35 } else if (ArrayBuffer.isView(cur)) {
36 a2[k] = copyBuffer(cur)
37 } else {
38 a2[k] = fn(cur)
39 }
40 }
41 return a2
42 }
43
44 function clone (o) {
45 if (typeof o !== 'object' || o === null) return o

Callers 2

cloneFunction · 0.70
cloneProtoFunction · 0.70

Calls 1

copyBufferFunction · 0.70

Tested by

no test coverage detected