Browse Source

[CI] Automatic commit check

SaltyMonkey 5 years ago
parent
commit
9edb7365cb
5 changed files with 221 additions and 89 deletions
  1. 10 7
      manifest.json
  2. 20 0
      node_modules/rfdc/index.js
  3. 12 6
      node_modules/rfdc/package.json
  4. 25 16
      node_modules/rfdc/readme.md
  5. 154 60
      node_modules/rfdc/test/index.js

+ 10 - 7
manifest.json

@@ -14,12 +14,12 @@
 		"lib/unitTracker.js": "f7426397562ff5b4ffe88f069131d7a051a88eeb96b1bcb9a59862ea2fa74081",
 		"lib/unitTracker.js": "f7426397562ff5b4ffe88f069131d7a051a88eeb96b1bcb9a59862ea2fa74081",
 		"module.json": "4b95ab9f3d531c2e2c2bb8c2919f99f2aa9f23b70bac498032b065bf541f0bf8",
 		"module.json": "4b95ab9f3d531c2e2c2bb8c2919f99f2aa9f23b70bac498032b065bf541f0bf8",
 		"node_modules/rfdc/LICENSE": "1ce941682a96c7b898ecd125d0f2e22319758ea6f3adbf498a65d649b0f3f7dd",
 		"node_modules/rfdc/LICENSE": "1ce941682a96c7b898ecd125d0f2e22319758ea6f3adbf498a65d649b0f3f7dd",
-		"node_modules/rfdc/index.js": "b1e2abd3238c080ad5b96f61d6a461b679c475b4b1bbceef776417e5e1922149",
-		"node_modules/rfdc/package.json": "88e323621b6835ca2b980ab1d7507f49a2b63f4c8d3301d010640de363694bd3",
-		"node_modules/rfdc/readme.md": "67da311a12dd2d655fc656bafd5d5f0345cd322667bb58201623b468d195bf05",
-		"node_modules/rfdc/test/index.js": "89c8b6631df835a01305a62ebf6ae94feb4381bcc8083fcd30bd4a394f3e5e17",
-		"package-lock.json": "965e29280e83e255aa4cb20fb88d51fe36411d54e46e7e1a90e987b160d8cb49",
-		"package.json": "bdd08f5ce0f85fee98e4d8bf324dbf41cfff243020949a3e63192982c94c35c1",
+		"node_modules/rfdc/index.js": "190dc068bd98e2f0669de0cbd6c6535578df35176bbcde4cfc1cb7f494cc2da0",
+		"node_modules/rfdc/package.json": "87e38a1b6e4cdc368e32085557c26921362631d41a2b26ed28691dc9161ecf4d",
+		"node_modules/rfdc/readme.md": "c09d5aa4b0895e0c38a16f499bb677a09bdc5b165066ae2243738aa9e7ebb5d3",
+		"node_modules/rfdc/test/index.js": "873efbd9a644ab8612058e455945d8e2138c9dda3f4240e781dc68ab6995092f",
+		"package-lock.json": "0e69b6b70efe996770ebcadf89d1d74bffc41e6d2b3da2d062d518082ff3e028",
+		"package.json": "357cb0a741a0e854c0e68eb2da222fb2537fac1691a7ab083491095f5ca6ef4d",
 		"settings/presets/common.json": {
 		"settings/presets/common.json": {
 			"overwrite": false,
 			"overwrite": false,
 			"hash": "92a5c0b8c98a9c9c70d19b2527eaa326151f15ee83ecd18070d4a679a426f2d5"
 			"hash": "92a5c0b8c98a9c9c70d19b2527eaa326151f15ee83ecd18070d4a679a426f2d5"
@@ -42,6 +42,9 @@
 		"node_modules/string-similarity/src/index.js": "941fc8276576aaa2952d4731d90fdc4b7fb2bb3871646e6cd4da47823c432520",
 		"node_modules/string-similarity/src/index.js": "941fc8276576aaa2952d4731d90fdc4b7fb2bb3871646e6cd4da47823c432520",
 		"node_modules/string-similarity/umd/string-similarity.min.js": "656fdfee8a18fc7f1ff1ff5f5d1dee8efc87be96a5e0e74489a986bdc7d95f31",
 		"node_modules/string-similarity/umd/string-similarity.min.js": "656fdfee8a18fc7f1ff1ff5f5d1dee8efc87be96a5e0e74489a986bdc7d95f31",
 		"lib/management/cmd.js": "b32ac2a9aaf65e3a682125d74faca5bcf6dff6885a7eaae0df4e6e8a2e393f8c",
 		"lib/management/cmd.js": "b32ac2a9aaf65e3a682125d74faca5bcf6dff6885a7eaae0df4e6e8a2e393f8c",
-		"lib/unitLog.js": "3b430c1fcd1121f30036f314f7829361e9548245f7ff7be97e44d344179001b7"
+		"lib/unitLog.js": "3b430c1fcd1121f30036f314f7829361e9548245f7ff7be97e44d344179001b7",
+		"node_modules/rfdc/default.js": "d7f46114c176de337df05aef386228b8ee1cd60e93a7400ee4ac98b91651f35e",
+		"node_modules/rfdc/index.d.ts": "1ce746559c2b493ba53418bb35dcfb13b8581bed88c0ac484d92b004077c4b4e",
+		"node_modules/rfdc/index.test-d.ts": "7804d55c3b95c6f79ee64476b095ccd4917f3866c3ec7a127a1ff3cd438ff071"
 	}
 	}
 }
 }

+ 20 - 0
node_modules/rfdc/index.js

@@ -1,6 +1,14 @@
 'use strict'
 'use strict'
 module.exports = rfdc
 module.exports = rfdc
 
 
+function copyBuffer (cur) {
+  if (cur instanceof Buffer) {
+    return Buffer.from(cur)
+  }
+
+  return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)
+}
+
 function rfdc (opts) {
 function rfdc (opts) {
   opts = opts || {}
   opts = opts || {}
 
 
@@ -17,6 +25,8 @@ function rfdc (opts) {
         a2[k] = cur
         a2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         a2[k] = new Date(cur)
         a2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        a2[k] = copyBuffer(cur)
       } else {
       } else {
         a2[k] = fn(cur)
         a2[k] = fn(cur)
       }
       }
@@ -36,6 +46,8 @@ function rfdc (opts) {
         o2[k] = cur
         o2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         o2[k] = new Date(cur)
         o2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        o2[k] = copyBuffer(cur)
       } else {
       } else {
         o2[k] = clone(cur)
         o2[k] = clone(cur)
       }
       }
@@ -54,6 +66,8 @@ function rfdc (opts) {
         o2[k] = cur
         o2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         o2[k] = new Date(cur)
         o2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        o2[k] = copyBuffer(cur)
       } else {
       } else {
         o2[k] = cloneProto(cur)
         o2[k] = cloneProto(cur)
       }
       }
@@ -78,6 +92,8 @@ function rfdcCircles (opts) {
         a2[k] = cur
         a2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         a2[k] = new Date(cur)
         a2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        a2[k] = copyBuffer(cur)
       } else {
       } else {
         var index = refs.indexOf(cur)
         var index = refs.indexOf(cur)
         if (index !== -1) {
         if (index !== -1) {
@@ -104,6 +120,8 @@ function rfdcCircles (opts) {
         o2[k] = cur
         o2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         o2[k] = new Date(cur)
         o2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        o2[k] = copyBuffer(cur)
       } else {
       } else {
         var i = refs.indexOf(cur)
         var i = refs.indexOf(cur)
         if (i !== -1) {
         if (i !== -1) {
@@ -131,6 +149,8 @@ function rfdcCircles (opts) {
         o2[k] = cur
         o2[k] = cur
       } else if (cur instanceof Date) {
       } else if (cur instanceof Date) {
         o2[k] = new Date(cur)
         o2[k] = new Date(cur)
+      } else if (ArrayBuffer.isView(cur)) {
+        o2[k] = copyBuffer(cur)
       } else {
       } else {
         var i = refs.indexOf(cur)
         var i = refs.indexOf(cur)
         if (i !== -1) {
         if (i !== -1) {

+ 12 - 6
node_modules/rfdc/package.json

@@ -1,10 +1,14 @@
 {
 {
   "name": "rfdc",
   "name": "rfdc",
-  "version": "1.1.4",
+  "version": "1.2.0",
   "description": "Really Fast Deep Clone",
   "description": "Really Fast Deep Clone",
   "main": "index.js",
   "main": "index.js",
+  "exports": {
+    ".": "./index.js",
+    "./default": "./default.js"
+  },
   "scripts": {
   "scripts": {
-    "test": "tap -R min test && npm run lint",
+    "test": "tap -R min test && npm run lint && tsd",
     "bench": "node benchmark",
     "bench": "node benchmark",
     "lint": "standard --fix",
     "lint": "standard --fix",
     "cov": "tap --100 test",
     "cov": "tap --100 test",
@@ -40,13 +44,15 @@
   "author": "David Mark Clements <david.clements@nearform.com>",
   "author": "David Mark Clements <david.clements@nearform.com>",
   "license": "MIT",
   "license": "MIT",
   "devDependencies": {
   "devDependencies": {
+    "clone-deep": "^4.0.1",
     "codecov": "^3.4.0",
     "codecov": "^3.4.0",
     "deep-copy": "^1.4.2",
     "deep-copy": "^1.4.2",
     "fast-copy": "^1.2.1",
     "fast-copy": "^1.2.1",
     "fastbench": "^1.0.1",
     "fastbench": "^1.0.1",
     "lodash.clonedeep": "^4.5.0",
     "lodash.clonedeep": "^4.5.0",
     "standard": "^11.0.1",
     "standard": "^11.0.1",
-    "tap": "^12.0.1"
+    "tap": "^12.0.1",
+    "tsd": "^0.7.4"
   },
   },
   "directories": {
   "directories": {
     "test": "test"
     "test": "test"
@@ -61,7 +67,7 @@
   },
   },
   "homepage": "https://github.com/davidmarkclements/rfdc#readme"
   "homepage": "https://github.com/davidmarkclements/rfdc#readme"
 
 
-,"_resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz"
-,"_integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug=="
-,"_from": "rfdc@1.1.4"
+,"_resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.2.0.tgz"
+,"_integrity": "sha512-ijLyszTMmUrXvjSooucVQwimGUk84eRcmCuLV8Xghe3UO85mjUtRAHRyoMM6XtyqbECaXuBWx18La3523sXINA=="
+,"_from": "rfdc@1.2.0"
 }
 }

+ 25 - 16
node_modules/rfdc/readme.md

@@ -23,7 +23,7 @@ clone({a: 1, b: {c: 2}}) // => {a: 1, b: {c: 2}}
 
 
 Copy prototype properties as well as own properties into the new object.
 Copy prototype properties as well as own properties into the new object.
 
 
-It's marginally faster to allow enumerable properties on the prototype 
+It's marginally faster to allow enumerable properties on the prototype
 to be copied into the cloned object (not onto it's prototype, directly onto the object).
 to be copied into the cloned object (not onto it's prototype, directly onto the object).
 
 
 To explain by way of code:
 To explain by way of code:
@@ -39,7 +39,7 @@ Setting `proto` to `true` will provide an additional 2% performance boost.
 
 
 Keeping track of circular references will slow down performance with an
 Keeping track of circular references will slow down performance with an
 additional 25% overhead. Even if an object doesn't have any circular references,
 additional 25% overhead. Even if an object doesn't have any circular references,
-the tracking overhead is the cost. By default if an object with a circular 
+the tracking overhead is the cost. By default if an object with a circular
 reference is passed to `rfdc`, it will throw (similar to how `JSON.stringify` \
 reference is passed to `rfdc`, it will throw (similar to how `JSON.stringify` \
 would throw).
 would throw).
 
 
@@ -48,9 +48,18 @@ object. If performance is important, try removing the circular reference from
 the object (set to `undefined`) and then add it back manually after cloning
 the object (set to `undefined`) and then add it back manually after cloning
 instead of using this option.
 instead of using this option.
 
 
+### `default` import
+It is also possible to directly import the clone function with all options set
+to their default:
+
+```js
+const clone = require("rfdc/default")
+clone({a: 1, b: {c: 2}}) // => {a: 1, b: {c: 2}}
+```
+
 ### Types
 ### Types
 
 
-`rdfc` clones all JSON types:
+`rfdc` clones all JSON types:
 
 
 * `Object`
 * `Object`
 * `Array`
 * `Array`
@@ -62,6 +71,8 @@ With additional support for:
 
 
 * `Date` (copied)
 * `Date` (copied)
 * `undefined` (copied)
 * `undefined` (copied)
+* `Buffer` (copied)
+* `TypedArray` (copied)
 * `Function` (referenced)
 * `Function` (referenced)
 * `AsyncFunction` (referenced)
 * `AsyncFunction` (referenced)
 * `GeneratorFunction` (referenced)
 * `GeneratorFunction` (referenced)
@@ -73,17 +84,14 @@ of `JSON.parse(JSON.stringify(o))`.
 For instance:
 For instance:
 
 
 ```js
 ```js
-const rdfc = require('rdfc')()
+const rfdc = require('rfdc')()
 const err = Error()
 const err = Error()
 err.code = 1
 err.code = 1
 JSON.parse(JSON.stringify(e)) // {code: 1}
 JSON.parse(JSON.stringify(e)) // {code: 1}
-rdfc(e) // {code: 1}
-
-JSON.parse(JSON.stringify(new Uint8Array([1, 2, 3]))) //  {'0': 1, '1': 2, '2': 3 }
-rdfc(new Uint8Array([1, 2, 3])) //  {'0': 1, '1': 2, '2': 3 }
+rfdc(e) // {code: 1}
 
 
 JSON.parse(JSON.stringify({rx: /foo/})) // {rx: {}}
 JSON.parse(JSON.stringify({rx: /foo/})) // {rx: {}}
-rdfc({rx: /foo/}) // {rx: {}}
+rfdc({rx: /foo/}) // {rx: {}}
 ```
 ```
 
 
 ## Benchmarks
 ## Benchmarks
@@ -93,13 +101,14 @@ npm run bench
 ```
 ```
 
 
 ```
 ```
-benchDeepCopy*100: 549.618ms
-benchLodashCloneDeep*100: 1461.134ms
-benchFastCopy*100: 878.146ms
-benchRfdc*100: 323.899ms
-benchRfdcProto*100: 314.136ms
-benchRfdcCircles*100: 384.561ms
-benchRfdcCirclesProto*100: 381.775ms
+benchDeepCopy*100: 457.568ms
+benchLodashCloneDeep*100: 1230.773ms
+benchCloneDeep*100: 655.208ms
+benchFastCopy*100: 747.017ms
+benchRfdc*100: 281.018ms
+benchRfdcProto*100: 277.265ms
+benchRfdcCircles*100: 328.148ms
+benchRfdcCirclesProto*100: 323.004ms
 ```
 ```
 
 
 ## Tests
 ## Tests

+ 154 - 60
node_modules/rfdc/test/index.js

@@ -2,24 +2,34 @@
 
 
 const { test } = require('tap')
 const { test } = require('tap')
 const rfdc = require('..')
 const rfdc = require('..')
+const cloneDefault = require('../default')
 const clone = rfdc()
 const clone = rfdc()
-const cloneProto = rfdc({proto: true})
-const cloneCircles = rfdc({circles: true})
-const cloneCirclesProto = rfdc({circles: true, proto: true})
+const cloneProto = rfdc({ proto: true })
+const cloneCircles = rfdc({ circles: true })
+const cloneCirclesProto = rfdc({ circles: true, proto: true })
+
+const rnd = (max) => Math.round(Math.random() * max)
 
 
 types(clone, 'default')
 types(clone, 'default')
 types(cloneProto, 'proto option')
 types(cloneProto, 'proto option')
 types(cloneCircles, 'circles option')
 types(cloneCircles, 'circles option')
 types(cloneCirclesProto, 'circles and proto option')
 types(cloneCirclesProto, 'circles and proto option')
 
 
-test('default – does not copy proto properties', async ({is}) => {
-  is(clone(Object.create({a: 1})).a, undefined, 'value not copied')
+test('default – does not copy proto properties', async ({ is }) => {
+  is(clone(Object.create({ a: 1 })).a, undefined, 'value not copied')
+})
+test('default – shorthand import', async ({ same }) => {
+  same(
+    clone(Object.create({ a: 1 })),
+    cloneDefault(Object.create({ a: 1 })),
+    'import equals clone with default options'
+  )
 })
 })
-test('proto option – copies enumerable proto properties', async ({is}) => {
-  is(cloneProto(Object.create({a: 1})).a, 1, 'value copied')
+test('proto option – copies enumerable proto properties', async ({ is }) => {
+  is(cloneProto(Object.create({ a: 1 })).a, 1, 'value copied')
 })
 })
-test('circles option - circular object', async ({same, is, isNot}) => {
-  const o = {nest: {a: 1, b: 2}}
+test('circles option - circular object', async ({ same, is, isNot }) => {
+  const o = { nest: { a: 1, b: 2 } }
   o.circular = o
   o.circular = o
   same(cloneCircles(o), o, 'same values')
   same(cloneCircles(o), o, 'same values')
   isNot(cloneCircles(o), o, 'different objects')
   isNot(cloneCircles(o), o, 'different objects')
@@ -28,24 +38,36 @@ test('circles option - circular object', async ({same, is, isNot}) => {
   is(c.circular, c, 'circular references point to copied parent')
   is(c.circular, c, 'circular references point to copied parent')
   isNot(c.circular, o, 'circular references do not point to original parent')
   isNot(c.circular, o, 'circular references do not point to original parent')
 })
 })
-test('circles option – deep circular object', async ({same, is, isNot}) => {
-  const o = {nest: {a: 1, b: 2}}
+test('circles option – deep circular object', async ({ same, is, isNot }) => {
+  const o = { nest: { a: 1, b: 2 } }
   o.nest.circular = o
   o.nest.circular = o
   same(cloneCircles(o), o, 'same values')
   same(cloneCircles(o), o, 'same values')
   isNot(cloneCircles(o), o, 'different objects')
   isNot(cloneCircles(o), o, 'different objects')
   isNot(cloneCircles(o).nest, o.nest, 'different nested objects')
   isNot(cloneCircles(o).nest, o.nest, 'different nested objects')
   const c = cloneCircles(o)
   const c = cloneCircles(o)
   is(c.nest.circular, c, 'circular references point to copied parent')
   is(c.nest.circular, c, 'circular references point to copied parent')
-  isNot(c.nest.circular, o, 'circular references do not point to original parent')
+  isNot(
+    c.nest.circular,
+    o,
+    'circular references do not point to original parent'
+  )
 })
 })
-test('circles option alone – does not copy proto properties', async ({is}) => {
-  is(cloneCircles(Object.create({a: 1})).a, undefined, 'value not copied')
+test('circles option alone – does not copy proto properties', async ({
+  is
+}) => {
+  is(cloneCircles(Object.create({ a: 1 })).a, undefined, 'value not copied')
 })
 })
-test('circles and proto option – copies enumerable proto properties', async ({is}) => {
-  is(cloneCirclesProto(Object.create({a: 1})).a, 1, 'value copied')
+test('circles and proto option – copies enumerable proto properties', async ({
+  is
+}) => {
+  is(cloneCirclesProto(Object.create({ a: 1 })).a, 1, 'value copied')
 })
 })
-test('circles and proto option - circular object', async ({same, is, isNot}) => {
-  const o = {nest: {a: 1, b: 2}}
+test('circles and proto option - circular object', async ({
+  same,
+  is,
+  isNot
+}) => {
+  const o = { nest: { a: 1, b: 2 } }
   o.circular = o
   o.circular = o
   same(cloneCirclesProto(o), o, 'same values')
   same(cloneCirclesProto(o), o, 'same values')
   isNot(cloneCirclesProto(o), o, 'different objects')
   isNot(cloneCirclesProto(o), o, 'different objects')
@@ -54,17 +76,29 @@ test('circles and proto option - circular object', async ({same, is, isNot}) =>
   is(c.circular, c, 'circular references point to copied parent')
   is(c.circular, c, 'circular references point to copied parent')
   isNot(c.circular, o, 'circular references do not point to original parent')
   isNot(c.circular, o, 'circular references do not point to original parent')
 })
 })
-test('circles and proto option – deep circular object', async ({same, is, isNot}) => {
-  const o = {nest: {a: 1, b: 2}}
+test('circles and proto option – deep circular object', async ({
+  same,
+  is,
+  isNot
+}) => {
+  const o = { nest: { a: 1, b: 2 } }
   o.nest.circular = o
   o.nest.circular = o
   same(cloneCirclesProto(o), o, 'same values')
   same(cloneCirclesProto(o), o, 'same values')
   isNot(cloneCirclesProto(o), o, 'different objects')
   isNot(cloneCirclesProto(o), o, 'different objects')
   isNot(cloneCirclesProto(o).nest, o.nest, 'different nested objects')
   isNot(cloneCirclesProto(o).nest, o.nest, 'different nested objects')
   const c = cloneCirclesProto(o)
   const c = cloneCirclesProto(o)
   is(c.nest.circular, c, 'circular references point to copied parent')
   is(c.nest.circular, c, 'circular references point to copied parent')
-  isNot(c.nest.circular, o, 'circular references do not point to original parent')
+  isNot(
+    c.nest.circular,
+    o,
+    'circular references do not point to original parent'
+  )
 })
 })
-test('circles and proto option – deep circular array', async ({same, is, isNot}) => {
+test('circles and proto option – deep circular array', async ({
+  same,
+  is,
+  isNot
+}) => {
   const o = { nest: [1, 2] }
   const o = { nest: [1, 2] }
   o.nest.push(o)
   o.nest.push(o)
   same(cloneCirclesProto(o), o, 'same values')
   same(cloneCirclesProto(o), o, 'same values')
@@ -76,99 +110,159 @@ test('circles and proto option – deep circular array', async ({same, is, isNot
 })
 })
 
 
 function types (clone, label) {
 function types (clone, label) {
-  test(label + ' – number', async ({is}) => {
+  test(label + ' – number', async ({ is }) => {
     is(clone(42), 42, 'same value')
     is(clone(42), 42, 'same value')
   })
   })
-  test(label + ' – string', async ({is}) => {
+  test(label + ' – string', async ({ is }) => {
     is(clone('str'), 'str', 'same value')
     is(clone('str'), 'str', 'same value')
   })
   })
-  test(label + ' – boolean', async ({is}) => {
+  test(label + ' – boolean', async ({ is }) => {
     is(clone(true), true, 'same value')
     is(clone(true), true, 'same value')
   })
   })
-  test(label + ' – function', async ({is}) => {
+  test(label + ' – function', async ({ is }) => {
     const fn = () => {}
     const fn = () => {}
     is(clone(fn), fn, 'same function')
     is(clone(fn), fn, 'same function')
   })
   })
-  test(label + ' – async function', async ({is}) => {
+  test(label + ' – async function', async ({ is }) => {
     const fn = async () => {}
     const fn = async () => {}
     is(clone(fn), fn, 'same function')
     is(clone(fn), fn, 'same function')
   })
   })
-  test(label + ' – generator function', async ({is}) => {
+  test(label + ' – generator function', async ({ is }) => {
     const fn = function * () {}
     const fn = function * () {}
     is(clone(fn), fn, 'same function')
     is(clone(fn), fn, 'same function')
   })
   })
-  test(label + ' – date', async ({is, isNot}) => {
+  test(label + ' – date', async ({ is, isNot }) => {
     const date = new Date()
     const date = new Date()
     is(+clone(date), +date, 'same value')
     is(+clone(date), +date, 'same value')
     isNot(clone(date), date, 'different object')
     isNot(clone(date), date, 'different object')
   })
   })
-  test(label + ' – null', async ({is}) => {
+  test(label + ' – null', async ({ is }) => {
     is(clone(null), null, 'same value')
     is(clone(null), null, 'same value')
   })
   })
-  test(label + ' – shallow object', async ({same, isNot}) => {
-    const o = {a: 1, b: 2}
+  test(label + ' – shallow object', async ({ same, isNot }) => {
+    const o = { a: 1, b: 2 }
     same(clone(o), o, 'same values')
     same(clone(o), o, 'same values')
     isNot(clone(o), o, 'different object')
     isNot(clone(o), o, 'different object')
   })
   })
-  test(label + ' – shallow array', async ({same, isNot}) => {
+  test(label + ' – shallow array', async ({ same, isNot }) => {
     const o = [1, 2]
     const o = [1, 2]
     same(clone(o), o, 'same values')
     same(clone(o), o, 'same values')
     isNot(clone(o), o, 'different arrays')
     isNot(clone(o), o, 'different arrays')
   })
   })
-  test(label + ' – deep object', async ({same, isNot}) => {
-    const o = {nest: {a: 1, b: 2}}
+  test(label + ' – deep object', async ({ same, isNot }) => {
+    const o = { nest: { a: 1, b: 2 } }
     same(clone(o), o, 'same values')
     same(clone(o), o, 'same values')
     isNot(clone(o), o, 'different objects')
     isNot(clone(o), o, 'different objects')
     isNot(clone(o).nest, o.nest, 'different nested objects')
     isNot(clone(o).nest, o.nest, 'different nested objects')
   })
   })
-  test(label + ' – deep array', async ({same, isNot}) => {
-    const o = [ {a: 1, b: 2}, [3] ]
+  test(label + ' – deep array', async ({ same, isNot }) => {
+    const o = [{ a: 1, b: 2 }, [3]]
     same(clone(o), o, 'same values')
     same(clone(o), o, 'same values')
     isNot(clone(o), o, 'different arrays')
     isNot(clone(o), o, 'different arrays')
     isNot(clone(o)[0], o[0], 'different array elements')
     isNot(clone(o)[0], o[0], 'different array elements')
     isNot(clone(o)[1], o[1], 'different array elements')
     isNot(clone(o)[1], o[1], 'different array elements')
   })
   })
-  test(label + ' – nested number', async ({is}) => {
-    is(clone({a: 1}).a, 1, 'same value')
+  test(label + ' – nested number', async ({ is }) => {
+    is(clone({ a: 1 }).a, 1, 'same value')
   })
   })
-  test(label + ' – nested string', async ({is}) => {
-    is(clone({s: 'str'}).s, 'str', 'same value')
+  test(label + ' – nested string', async ({ is }) => {
+    is(clone({ s: 'str' }).s, 'str', 'same value')
   })
   })
-  test(label + ' – nested boolean', async ({is}) => {
-    is(clone({b: true}).b, true, 'same value')
+  test(label + ' – nested boolean', async ({ is }) => {
+    is(clone({ b: true }).b, true, 'same value')
   })
   })
-  test(label + ' – nested function', async ({is}) => {
+  test(label + ' – nested function', async ({ is }) => {
     const fn = () => {}
     const fn = () => {}
-    is(clone({fn}).fn, fn, 'same function')
+    is(clone({ fn }).fn, fn, 'same function')
   })
   })
-  test(label + ' – nested async function', async ({is}) => {
+  test(label + ' – nested async function', async ({ is }) => {
     const fn = async () => {}
     const fn = async () => {}
-    is(clone({fn}).fn, fn, 'same function')
+    is(clone({ fn }).fn, fn, 'same function')
   })
   })
-  test(label + ' – nested generator function', async ({is}) => {
+  test(label + ' – nested generator function', async ({ is }) => {
     const fn = function * () {}
     const fn = function * () {}
-    is(clone({fn}).fn, fn, 'same function')
+    is(clone({ fn }).fn, fn, 'same function')
   })
   })
-  test(label + ' – nested date', async ({is, isNot}) => {
+  test(label + ' – nested date', async ({ is, isNot }) => {
     const date = new Date()
     const date = new Date()
-    is(+clone({d: date}).d, +date, 'same value')
-    isNot(clone({d: date}).d, date, 'different object')
+    is(+clone({ d: date }).d, +date, 'same value')
+    isNot(clone({ d: date }).d, date, 'different object')
   })
   })
-  test(label + ' – nested date in array', async ({is, isNot}) => {
+  test(label + ' – nested date in array', async ({ is, isNot }) => {
     const date = new Date()
     const date = new Date()
-    is(+clone({d: [date]}).d[0], +date, 'same value')
-    isNot(clone({d: [date]}).d[0], date, 'different object')
-    is(+cloneCircles({d: [date]}).d[0], +date, 'same value')
-    isNot(cloneCircles({d: [date]}).d, date, 'different object')
+    is(+clone({ d: [date] }).d[0], +date, 'same value')
+    isNot(clone({ d: [date] }).d[0], date, 'different object')
+    is(+cloneCircles({ d: [date] }).d[0], +date, 'same value')
+    isNot(cloneCircles({ d: [date] }).d, date, 'different object')
   })
   })
-  test(label + ' – nested null', async ({is}) => {
-    is(clone({n: null}).n, null, 'same value')
+  test(label + ' – nested null', async ({ is }) => {
+    is(clone({ n: null }).n, null, 'same value')
   })
   })
-  test(label + ' – arguments', async ({isNot, same}) => {
+  test(label + ' – arguments', async ({ isNot, same }) => {
     function fn (...args) {
     function fn (...args) {
       same(clone(arguments), args, 'same values')
       same(clone(arguments), args, 'same values')
       isNot(clone(arguments), arguments, 'different object')
       isNot(clone(arguments), arguments, 'different object')
     }
     }
     fn(1, 2, 3)
     fn(1, 2, 3)
   })
   })
+  test(`${label} copies buffers from object correctly`, async ({ ok, is, isNot }) => {
+    const input = Date.now().toString(36)
+    const inputBuffer = Buffer.from(input)
+    const clonedBuffer = clone({ a: inputBuffer }).a
+    ok(Buffer.isBuffer(clonedBuffer), 'cloned value is buffer')
+    isNot(clonedBuffer, inputBuffer, 'cloned buffer is not same as input buffer')
+    is(clonedBuffer.toString(), input, 'cloned buffer content is correct')
+  })
+  test(`${label} copies buffers from arrays correctly`, async ({ ok, is, isNot }) => {
+    const input = Date.now().toString(36)
+    const inputBuffer = Buffer.from(input)
+    const [clonedBuffer] = clone([inputBuffer])
+    ok(Buffer.isBuffer(clonedBuffer), 'cloned value is buffer')
+    isNot(clonedBuffer, inputBuffer, 'cloned buffer is not same as input buffer')
+    is(clonedBuffer.toString(), input, 'cloned buffer content is correct')
+  })
+  test(`${label} copies TypedArrays from object correctly`, async ({ ok, is, isNot }) => {
+    const [input1, input2] = [rnd(10), rnd(10)]
+    var buffer = new ArrayBuffer(8)
+    const int32View = new Int32Array(buffer)
+    int32View[0] = input1
+    int32View[1] = input2
+    const cloned = clone({ a: int32View }).a
+    ok(cloned instanceof Int32Array, 'cloned value is instance of class')
+    isNot(cloned, int32View, 'cloned value is not same as input value')
+    is(cloned[0], input1, 'cloned value content is correct')
+    is(cloned[1], input2, 'cloned value content is correct')
+  })
+  test(`${label} copies TypedArrays from array correctly`, async ({ ok, is, isNot }) => {
+    const [input1, input2] = [rnd(10), rnd(10)]
+    var buffer = new ArrayBuffer(16)
+    const int32View = new Int32Array(buffer)
+    int32View[0] = input1
+    int32View[1] = input2
+    const [cloned] = clone([int32View])
+    ok(cloned instanceof Int32Array, 'cloned value is instance of class')
+    isNot(cloned, int32View, 'cloned value is not same as input value')
+    is(cloned[0], input1, 'cloned value content is correct')
+    is(cloned[1], input2, 'cloned value content is correct')
+  })
+  test(`${label} copies complex TypedArrays`, async ({ ok, deepEqual, is, isNot }) => {
+    const [input1, input2, input3] = [rnd(10), rnd(10), rnd(10)]
+    var buffer = new ArrayBuffer(4)
+    const view1 = new Int8Array(buffer, 0, 2)
+    const view2 = new Int8Array(buffer, 2, 2)
+    const view3 = new Int8Array(buffer)
+    view1[0] = input1
+    view2[0] = input2
+    view3[3] = input3
+    const cloned = clone({ view1, view2, view3 })
+    ok(cloned.view1 instanceof Int8Array, 'cloned value is instance of class')
+    ok(cloned.view2 instanceof Int8Array, 'cloned value is instance of class')
+    ok(cloned.view3 instanceof Int8Array, 'cloned value is instance of class')
+    isNot(cloned.view1, view1, 'cloned value is not same as input value')
+    isNot(cloned.view2, view2, 'cloned value is not same as input value')
+    isNot(cloned.view3, view3, 'cloned value is not same as input value')
+    deepEqual(Array.from(cloned.view1), [input1, 0], 'cloned value content is correct')
+    deepEqual(Array.from(cloned.view2), [input2, input3], 'cloned value content is correct')
+    deepEqual(Array.from(cloned.view3), [input1, 0, input2, input3], 'cloned value content is correct')
+  })
 }
 }