switch to ESM
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 28 Jul 2023 13:12:04 +0000 (15:12 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 28 Jul 2023 13:12:04 +0000 (15:12 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
14 files changed:
busy-wait.mjs [moved from busy-wait.js with 96% similarity]
deep-clone-object.mjs [moved from deep-clone-object.js with 77% similarity]
empty-array.mjs [moved from empty-array.js with 89% similarity]
fibonacci.mjs [moved from fibonacci.js with 97% similarity]
is-empty-object.mjs [moved from is-empty-object.js with 91% similarity]
is-undefined.mjs [moved from is-undefined.js with 94% similarity]
max.mjs [moved from max.js with 92% similarity]
package.json
pnpm-lock.yaml
promise-handling.mjs [moved from promise-handling.js with 96% similarity]
quick-select.mjs [moved from quick-select.js with 98% similarity]
random.mjs [moved from random.js with 95% similarity]
shallow-clone-object.mjs [moved from shallow-clone-object.js with 86% similarity]
uuid-generator.mjs [moved from uuid-generator.js with 83% similarity]

similarity index 96%
rename from busy-wait.js
rename to busy-wait.mjs
index a851a30e911870542cd9612b2777c7654c057a36..a785a7e8247a3eb4b07acf3f68ec5716eb6b6ea7 100644 (file)
@@ -1,5 +1,5 @@
-const Benchmark = require('benny')
-const { sleep } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import { sleep } from './benchmark-utils.js'
 
 const timeout = 2000
 const interval = 1000
similarity index 77%
rename from deep-clone-object.js
rename to deep-clone-object.mjs
index 0f480c424263664a2e02ab3d8663a9bb87c65bf6..52a1bac29a382a19d6a9c2a060400797d2795a04 100644 (file)
@@ -1,8 +1,9 @@
 /* eslint-disable no-unused-vars */
-const Benchmark = require('benny')
-const _ = require('lodash')
-const clone = require('just-clone')
-const { generateRandomObject } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import _ from 'lodash'
+import clone from 'just-clone'
+import deepClone from 'deep-clone'
+import { generateRandomObject } from './benchmark-utils.js'
 
 const object = generateRandomObject()
 
@@ -20,6 +21,9 @@ Benchmark.suite(
   Benchmark.add('just-clone', (obj = object) => {
     const objClone = clone(obj)
   }),
+  Benchmark.add('deep-clone', (obj = object) => {
+    const objClone = deepClone(obj)
+  }),
   Benchmark.cycle(),
   Benchmark.complete(),
   Benchmark.save({
similarity index 89%
rename from empty-array.js
rename to empty-array.mjs
index c900a4239e4e4a04f17a5b92e3cadebb5d91377c..887e0ce183ecfcf956ea41245cb9aa188c4b5bb1 100644 (file)
@@ -1,5 +1,5 @@
-const Benchmark = require('benny')
-const { generateRandomNumberArray } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import { generateRandomNumberArray } from './benchmark-utils.js'
 
 const size = 10000
 let testArray = generateRandomNumberArray(size)
similarity index 97%
rename from fibonacci.js
rename to fibonacci.mjs
index a62f4711fc75adee803df9991769f832ff21d8b5..00130ce0709a7e33a6abb23ba24bbed6fcfcbb8b 100644 (file)
@@ -1,4 +1,4 @@
-const Benchmark = require('benny')
+import Benchmark from 'benny'
 
 const number = 30
 
similarity index 91%
rename from is-empty-object.js
rename to is-empty-object.mjs
index 02c3a29c809d00f4d9ab70083688a94c7ad21eb9..17072a96660ec37947743e6ddf9762ddbce81fcc 100644 (file)
@@ -1,5 +1,5 @@
-const Benchmark = require('benny')
-const { generateRandomObject } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import { generateRandomObject } from './benchmark-utils.js'
 
 const object = generateRandomObject()
 
similarity index 94%
rename from is-undefined.js
rename to is-undefined.mjs
index 549171ef78b9adc34280ad3c7df3334e2e2d6dce..a04113b881ac45a17a638c24ab1dd0d401fb5650 100644 (file)
@@ -1,4 +1,4 @@
-const Benchmark = require('benny')
+import Benchmark from 'benny'
 
 Benchmark.suite(
   'Is undefined',
diff --git a/max.js b/max.mjs
similarity index 92%
rename from max.js
rename to max.mjs
index 5a486473e9d6fa3afa4aa7da9347ce6384a28e49..de7602ea57f669bb7f8c00539074fe92712cb62d 100644 (file)
--- a/max.js
+++ b/max.mjs
@@ -1,5 +1,5 @@
-const Benchmark = require('benny')
-const { generateRandomNumberArray } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import { generateRandomNumberArray } from './benchmark-utils.js'
 
 const size = 10000
 const testArray = generateRandomNumberArray(size)
index c845cd4e1a081ef6fc31837c94f6259938b6d5bc..2573d225007e3a8a393986539401422ad7a66f53 100644 (file)
   "scripts": {
     "preinstall": "npx --yes only-allow pnpm",
     "prepare": "node prepare.js",
-    "benchmark:busy-wait": "node busy-wait.js",
-    "benchmark:empty-array": "node empty-array.js",
-    "benchmark:deep-clone-object": "node deep-clone-object.js",
-    "benchmark:shallow-clone-object": "node shallow-clone-object.js",
-    "benchmark:is-empty-object": "node is-empty-object.js",
-    "benchmark:is-undefined": "node is-undefined.js",
-    "benchmark:quick-select": "node quick-select.js",
-    "benchmark:max": "node max.js",
-    "benchmark:promise-handling": "node promise-handling.js",
-    "benchmark:fibonacci": "node fibonacci.js",
-    "benchmark:random": "node random.js",
-    "benchmark:uuid-generator": "node uuid-generator.js",
+    "benchmark:busy-wait": "node busy-wait.mjs",
+    "benchmark:empty-array": "node empty-array.mjs",
+    "benchmark:deep-clone-object": "node deep-clone-object.mjs",
+    "benchmark:shallow-clone-object": "node shallow-clone-object.mjs",
+    "benchmark:is-empty-object": "node is-empty-object.mjs",
+    "benchmark:is-undefined": "node is-undefined.mjs",
+    "benchmark:quick-select": "node quick-select.mjs",
+    "benchmark:max": "node max.mjs",
+    "benchmark:promise-handling": "node promise-handling.mjs",
+    "benchmark:fibonacci": "node fibonacci.mjs",
+    "benchmark:random": "node random.mjs",
+    "benchmark:uuid-generator": "node uuid-generator.mjs",
     "format": "prettier . --cache --write; standard . --fix",
     "lint": "eslint . --cache",
     "lint:fix": "eslint . --cache --fix",
@@ -53,6 +53,7 @@
   "license": "MIT",
   "dependencies": {
     "benny": "^3.7.1",
+    "deep-clone": "^4.0.0",
     "just-clone": "^6.2.0",
     "lodash": "^4.17.21",
     "microtime": "^3.1.1",
index 530e1c10600712f3e4a6cf6aaf0bbde6050745f6..e50c2b0cb1043d49f1e54e4ab92b3b14a120a55f 100644 (file)
@@ -11,6 +11,9 @@ dependencies:
   benny:
     specifier: ^3.7.1
     version: 3.7.1
+  deep-clone:
+    specifier: ^4.0.0
+    version: 4.0.0
   just-clone:
     specifier: ^6.2.0
     version: 6.2.0
@@ -507,6 +510,10 @@ packages:
       ms: 2.1.2
     dev: true
 
+  /deep-clone@4.0.0:
+    resolution: {integrity: sha512-bMvDVR8GiGCGHT4SgqXyXDD9Zmo3kv9YLq8aSO2xslP97A3mFkpNBg+t+fjXERvewzhmtk9efvL+V52iVkD0lg==}
+    dev: false
+
   /deep-is@0.1.4:
     resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
     dev: true
similarity index 96%
rename from promise-handling.js
rename to promise-handling.mjs
index 11e0a96493056430a470792173f8fd4fd50f04d9..b3b02107c9cfc793a7c3149db013236df206b8bb 100644 (file)
@@ -1,4 +1,4 @@
-const Benchmark = require('benny')
+import Benchmark from 'benny'
 
 /**
  *
similarity index 98%
rename from quick-select.js
rename to quick-select.mjs
index 7a2486a804e144e5686c2002e2ad492d690a5f8a..34ba13d9eec2547d0a10b5cfbc44bd195dfaa054 100644 (file)
@@ -1,5 +1,5 @@
-const Benchmark = require('benny')
-const { generateRandomInteger } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import { generateRandomInteger } from './benchmark-utils.js'
 
 /**
  * @param numberOfWorkers
similarity index 95%
rename from random.js
rename to random.mjs
index 8c0fa86e669b384e4d812478e00b6a61716031c8..f814d3d37344900edacfe5d5190f106d64f92c19 100644 (file)
--- a/random.js
@@ -1,9 +1,9 @@
-const crypto = require('crypto')
-const Benchmark = require('benny')
-const {
+import crypto from 'crypto'
+import Benchmark from 'benny'
+import {
   secureRandom,
   secureRandomWithRandomValues
-} = require('./benchmark-utils')
+} from './benchmark-utils.js'
 
 const maximum = 281474976710654
 
similarity index 86%
rename from shallow-clone-object.js
rename to shallow-clone-object.mjs
index f8e193b65e701a7d91294cfa6bf973cd7d6b696d..05a97ec3f0103c9f4a645663d92d3dfa16fc63ef 100644 (file)
@@ -1,7 +1,7 @@
 /* eslint-disable no-unused-vars */
-const Benchmark = require('benny')
-const _ = require('lodash')
-const { generateRandomObject } = require('./benchmark-utils')
+import Benchmark from 'benny'
+import _ from 'lodash'
+import { generateRandomObject } from './benchmark-utils.js'
 
 const object = generateRandomObject()
 
similarity index 83%
rename from uuid-generator.js
rename to uuid-generator.mjs
index 08641c12ebc451c01be8e5eb56d5f8728600cec5..92e15d848468cc576ed91f7d06ba4d134a4ad041 100644 (file)
@@ -1,6 +1,6 @@
-const crypto = require('crypto')
-const Benchmark = require('benny')
-const { v4: uuid } = require('uuid')
+import crypto from 'crypto'
+import Benchmark from 'benny'
+import { v4 as uuid } from 'uuid'
 
 Benchmark.suite(
   'UUIDv4 generator',