@node-core/utils 7.2.0 → 7.2.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.
Files changed (182) hide show
  1. package/lib/ci/build-types/test_build.js +3 -3
  2. package/lib/ci/failure_aggregator.js +2 -2
  3. package/lib/ci/run_ci.js +3 -2
  4. package/lib/cli.js +6 -6
  5. package/lib/figures.js +6 -6
  6. package/lib/update-v8/backport.js +3 -4
  7. package/lib/verbosity.js +2 -4
  8. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
  9. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
  10. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
  11. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
  12. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
  13. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
  14. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
  15. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
  16. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
  17. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
  18. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
  19. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
  20. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
  21. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
  22. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
  23. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
  24. package/node_modules/ansi-regex/index.js +9 -4
  25. package/node_modules/ansi-regex/package.json +1 -1
  26. package/node_modules/ansi-regex/readme.md +6 -0
  27. package/node_modules/ansi-styles/index.d.ts +12 -12
  28. package/node_modules/ansi-styles/index.js +3 -3
  29. package/node_modules/ansi-styles/package.json +4 -4
  30. package/node_modules/cli-truncate/index.d.ts +3 -3
  31. package/node_modules/cli-truncate/index.js +40 -14
  32. package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
  33. package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
  34. package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
  35. package/node_modules/cli-truncate/package.json +7 -7
  36. package/node_modules/cli-truncate/readme.md +2 -3
  37. package/node_modules/ghauth/.github/dependabot.yml +11 -3
  38. package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
  39. package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
  40. package/node_modules/ghauth/CHANGELOG.md +60 -0
  41. package/node_modules/ghauth/package.json +30 -6
  42. package/node_modules/js-yaml/README.md +20 -187
  43. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
  44. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
  45. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
  46. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
  47. package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
  48. package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
  49. package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
  50. package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
  51. package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
  52. package/node_modules/js-yaml/package.json +8 -7
  53. package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
  54. package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
  55. package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
  56. package/node_modules/listr2/node_modules/string-width/index.js +207 -0
  57. package/node_modules/listr2/node_modules/string-width/package.json +65 -0
  58. package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
  59. package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
  60. package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
  61. package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
  62. package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
  63. package/node_modules/listr2/package.json +16 -19
  64. package/node_modules/log-update/index.d.ts +64 -1
  65. package/node_modules/log-update/index.js +268 -18
  66. package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
  67. package/node_modules/log-update/node_modules/string-width/index.js +207 -0
  68. package/node_modules/log-update/node_modules/string-width/package.json +65 -0
  69. package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
  70. package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
  71. package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
  72. package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
  73. package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
  74. package/node_modules/log-update/package.json +14 -12
  75. package/node_modules/log-update/readme.md +61 -0
  76. package/node_modules/slice-ansi/index.d.ts +2 -2
  77. package/node_modules/slice-ansi/index.js +260 -112
  78. package/node_modules/slice-ansi/package.json +10 -9
  79. package/node_modules/slice-ansi/readme.md +3 -2
  80. package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  81. package/node_modules/smol-toml/README.md +205 -191
  82. package/node_modules/smol-toml/dist/date.d.ts +0 -1
  83. package/node_modules/smol-toml/dist/date.js +0 -1
  84. package/node_modules/smol-toml/dist/error.d.ts +0 -1
  85. package/node_modules/smol-toml/dist/error.js +0 -1
  86. package/node_modules/smol-toml/dist/extract.js +32 -65
  87. package/node_modules/smol-toml/dist/index.cjs +302 -288
  88. package/node_modules/smol-toml/dist/index.d.ts +0 -1
  89. package/node_modules/smol-toml/dist/index.js +0 -1
  90. package/node_modules/smol-toml/dist/parse.d.ts +1 -3
  91. package/node_modules/smol-toml/dist/parse.js +22 -21
  92. package/node_modules/smol-toml/dist/primitive.js +75 -76
  93. package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
  94. package/node_modules/smol-toml/dist/stringify.js +43 -30
  95. package/node_modules/smol-toml/dist/struct.js +90 -93
  96. package/node_modules/smol-toml/dist/util.d.ts +1 -1
  97. package/node_modules/smol-toml/dist/util.js +36 -39
  98. package/node_modules/smol-toml/package.json +6 -6
  99. package/node_modules/strip-ansi/index.js +5 -0
  100. package/node_modules/strip-ansi/package.json +5 -5
  101. package/package.json +3 -5
  102. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
  103. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
  104. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
  105. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
  106. package/node_modules/chalk/package.json +0 -92
  107. package/node_modules/chalk/readme.md +0 -331
  108. package/node_modules/chalk/source/index.d.ts +0 -437
  109. package/node_modules/chalk/source/index.js +0 -261
  110. package/node_modules/chalk/source/utilities.js +0 -33
  111. package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
  112. package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
  113. package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
  114. package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
  115. package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
  116. package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
  117. package/node_modules/colorette/LICENSE.md +0 -7
  118. package/node_modules/colorette/README.md +0 -134
  119. package/node_modules/colorette/index.cjs +0 -218
  120. package/node_modules/colorette/index.d.ts +0 -93
  121. package/node_modules/colorette/index.js +0 -150
  122. package/node_modules/colorette/package.json +0 -40
  123. package/node_modules/eventemitter3/LICENSE +0 -21
  124. package/node_modules/eventemitter3/README.md +0 -94
  125. package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
  126. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
  127. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
  128. package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
  129. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
  130. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
  131. package/node_modules/eventemitter3/index.d.ts +0 -135
  132. package/node_modules/eventemitter3/index.js +0 -336
  133. package/node_modules/eventemitter3/index.mjs +0 -4
  134. package/node_modules/eventemitter3/package.json +0 -67
  135. package/node_modules/figures/index.d.ts +0 -279
  136. package/node_modules/figures/index.js +0 -292
  137. package/node_modules/figures/package.json +0 -49
  138. package/node_modules/figures/readme.md +0 -337
  139. package/node_modules/listr2/dist/index.cjs +0 -2189
  140. package/node_modules/listr2/dist/index.d.ts +0 -1528
  141. package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
  142. package/node_modules/rfdc/LICENSE +0 -15
  143. package/node_modules/rfdc/default.js +0 -3
  144. package/node_modules/rfdc/index.d.ts +0 -13
  145. package/node_modules/rfdc/index.js +0 -198
  146. package/node_modules/rfdc/index.test-d.ts +0 -13
  147. package/node_modules/rfdc/package.json +0 -73
  148. package/node_modules/rfdc/readme.md +0 -181
  149. package/node_modules/rfdc/test/index.js +0 -306
  150. package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
  151. package/node_modules/smol-toml/dist/date.js.map +0 -1
  152. package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
  153. package/node_modules/smol-toml/dist/error.js.map +0 -1
  154. package/node_modules/smol-toml/dist/extract.js.map +0 -1
  155. package/node_modules/smol-toml/dist/index.cjs.map +0 -1
  156. package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
  157. package/node_modules/smol-toml/dist/index.js.map +0 -1
  158. package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
  159. package/node_modules/smol-toml/dist/parse.js.map +0 -1
  160. package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
  161. package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
  162. package/node_modules/smol-toml/dist/primitive.js.map +0 -1
  163. package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
  164. package/node_modules/smol-toml/dist/stringify.js.map +0 -1
  165. package/node_modules/smol-toml/dist/struct.js.map +0 -1
  166. package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
  167. package/node_modules/smol-toml/dist/util.js.map +0 -1
  168. package/node_modules/smol-toml/src/date.ts +0 -152
  169. package/node_modules/smol-toml/src/error.ts +0 -77
  170. package/node_modules/smol-toml/src/extract.ts +0 -113
  171. package/node_modules/smol-toml/src/index.ts +0 -42
  172. package/node_modules/smol-toml/src/parse.ts +0 -184
  173. package/node_modules/smol-toml/src/primitive.ts +0 -249
  174. package/node_modules/smol-toml/src/stringify.ts +0 -191
  175. package/node_modules/smol-toml/src/struct.ts +0 -202
  176. package/node_modules/smol-toml/src/util.ts +0 -106
  177. /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
  178. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
  179. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
  180. /package/node_modules/{chalk → ansi-escapes}/license +0 -0
  181. /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
  182. /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
@@ -1,21 +0,0 @@
1
- name: CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ${{ matrix.os }}
8
-
9
- strategy:
10
- matrix:
11
- os: [ubuntu-latest]
12
- node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x]
13
-
14
- steps:
15
- - uses: actions/checkout@v2
16
- - name: Use Node.js ${{ matrix.node-version }}
17
- uses: actions/setup-node@v1
18
- with:
19
- node-version: ${{ matrix.node-version }}
20
- - run: npm install
21
- - run: npm run ci
@@ -1,15 +0,0 @@
1
- Copyright 2019 "David Mark Clements <david.mark.clements@gmail.com>"
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation
5
- the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
6
- to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
-
8
- The above copyright notice and this permission notice shall be included in all copies or substantial portions
9
- of the Software.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
12
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
13
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
14
- CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
15
- IN THE SOFTWARE.
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = require('./index.js')()
@@ -1,13 +0,0 @@
1
- declare namespace rfdc {
2
- interface Options {
3
- proto?: boolean;
4
- circles?: boolean;
5
- constructorHandlers?: ConstructorHandlerConfig[];
6
- }
7
- }
8
- type Constructor<T> = {new(...args: any[]): T};
9
- type ConstructorHandlerConfig<T = any> = [Constructor<T>, (o: T) => T];
10
-
11
- declare function rfdc(options?: rfdc.Options): <T>(input: T) => T;
12
-
13
- export = rfdc;
@@ -1,198 +0,0 @@
1
- 'use strict'
2
- module.exports = rfdc
3
-
4
- function copyBuffer (cur) {
5
- if (cur instanceof Buffer) {
6
- return Buffer.from(cur)
7
- }
8
-
9
- return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)
10
- }
11
-
12
- function rfdc (opts) {
13
- opts = opts || {}
14
- if (opts.circles) return rfdcCircles(opts)
15
-
16
- const constructorHandlers = new Map()
17
- constructorHandlers.set(Date, (o) => new Date(o))
18
- constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)))
19
- constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))
20
- if (opts.constructorHandlers) {
21
- for (const handler of opts.constructorHandlers) {
22
- constructorHandlers.set(handler[0], handler[1])
23
- }
24
- }
25
-
26
- let handler = null
27
-
28
- return opts.proto ? cloneProto : clone
29
-
30
- function cloneArray (a, fn) {
31
- const keys = Object.keys(a)
32
- const a2 = new Array(keys.length)
33
- for (let i = 0; i < keys.length; i++) {
34
- const k = keys[i]
35
- const cur = a[k]
36
- if (typeof cur !== 'object' || cur === null) {
37
- a2[k] = cur
38
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
39
- a2[k] = handler(cur, fn)
40
- } else if (ArrayBuffer.isView(cur)) {
41
- a2[k] = copyBuffer(cur)
42
- } else {
43
- a2[k] = fn(cur)
44
- }
45
- }
46
- return a2
47
- }
48
-
49
- function clone (o) {
50
- if (typeof o !== 'object' || o === null) return o
51
- if (Array.isArray(o)) return cloneArray(o, clone)
52
- if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
53
- return handler(o, clone)
54
- }
55
- const o2 = {}
56
- for (const k in o) {
57
- if (Object.hasOwnProperty.call(o, k) === false) continue
58
- const cur = o[k]
59
- if (typeof cur !== 'object' || cur === null) {
60
- o2[k] = cur
61
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
62
- o2[k] = handler(cur, clone)
63
- } else if (ArrayBuffer.isView(cur)) {
64
- o2[k] = copyBuffer(cur)
65
- } else {
66
- o2[k] = clone(cur)
67
- }
68
- }
69
- return o2
70
- }
71
-
72
- function cloneProto (o) {
73
- if (typeof o !== 'object' || o === null) return o
74
- if (Array.isArray(o)) return cloneArray(o, cloneProto)
75
- if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
76
- return handler(o, cloneProto)
77
- }
78
- const o2 = {}
79
- for (const k in o) {
80
- const cur = o[k]
81
- if (typeof cur !== 'object' || cur === null) {
82
- o2[k] = cur
83
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
84
- o2[k] = handler(cur, cloneProto)
85
- } else if (ArrayBuffer.isView(cur)) {
86
- o2[k] = copyBuffer(cur)
87
- } else {
88
- o2[k] = cloneProto(cur)
89
- }
90
- }
91
- return o2
92
- }
93
- }
94
-
95
- function rfdcCircles (opts) {
96
- const refs = []
97
- const refsNew = []
98
-
99
- const constructorHandlers = new Map()
100
- constructorHandlers.set(Date, (o) => new Date(o))
101
- constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)))
102
- constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))
103
- if (opts.constructorHandlers) {
104
- for (const handler of opts.constructorHandlers) {
105
- constructorHandlers.set(handler[0], handler[1])
106
- }
107
- }
108
-
109
- let handler = null
110
- return opts.proto ? cloneProto : clone
111
-
112
- function cloneArray (a, fn) {
113
- const keys = Object.keys(a)
114
- const a2 = new Array(keys.length)
115
- for (let i = 0; i < keys.length; i++) {
116
- const k = keys[i]
117
- const cur = a[k]
118
- if (typeof cur !== 'object' || cur === null) {
119
- a2[k] = cur
120
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
121
- a2[k] = handler(cur, fn)
122
- } else if (ArrayBuffer.isView(cur)) {
123
- a2[k] = copyBuffer(cur)
124
- } else {
125
- const index = refs.indexOf(cur)
126
- if (index !== -1) {
127
- a2[k] = refsNew[index]
128
- } else {
129
- a2[k] = fn(cur)
130
- }
131
- }
132
- }
133
- return a2
134
- }
135
-
136
- function clone (o) {
137
- if (typeof o !== 'object' || o === null) return o
138
- if (Array.isArray(o)) return cloneArray(o, clone)
139
- if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
140
- return handler(o, clone)
141
- }
142
- const o2 = {}
143
- refs.push(o)
144
- refsNew.push(o2)
145
- for (const k in o) {
146
- if (Object.hasOwnProperty.call(o, k) === false) continue
147
- const cur = o[k]
148
- if (typeof cur !== 'object' || cur === null) {
149
- o2[k] = cur
150
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
151
- o2[k] = handler(cur, clone)
152
- } else if (ArrayBuffer.isView(cur)) {
153
- o2[k] = copyBuffer(cur)
154
- } else {
155
- const i = refs.indexOf(cur)
156
- if (i !== -1) {
157
- o2[k] = refsNew[i]
158
- } else {
159
- o2[k] = clone(cur)
160
- }
161
- }
162
- }
163
- refs.pop()
164
- refsNew.pop()
165
- return o2
166
- }
167
-
168
- function cloneProto (o) {
169
- if (typeof o !== 'object' || o === null) return o
170
- if (Array.isArray(o)) return cloneArray(o, cloneProto)
171
- if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
172
- return handler(o, cloneProto)
173
- }
174
- const o2 = {}
175
- refs.push(o)
176
- refsNew.push(o2)
177
- for (const k in o) {
178
- const cur = o[k]
179
- if (typeof cur !== 'object' || cur === null) {
180
- o2[k] = cur
181
- } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
182
- o2[k] = handler(cur, cloneProto)
183
- } else if (ArrayBuffer.isView(cur)) {
184
- o2[k] = copyBuffer(cur)
185
- } else {
186
- const i = refs.indexOf(cur)
187
- if (i !== -1) {
188
- o2[k] = refsNew[i]
189
- } else {
190
- o2[k] = cloneProto(cur)
191
- }
192
- }
193
- }
194
- refs.pop()
195
- refsNew.pop()
196
- return o2
197
- }
198
- }
@@ -1,13 +0,0 @@
1
- import { expectType } from 'tsd';
2
- import rfdc = require('.');
3
-
4
- const clone = rfdc();
5
-
6
- expectType<number>(clone(5));
7
- expectType<{ lorem: string }>(clone({ lorem: "ipsum" }));
8
-
9
- const cloneHandlers = rfdc({
10
- constructorHandlers: [
11
- [RegExp, (o) => new RegExp(o)],
12
- ],
13
- })
@@ -1,73 +0,0 @@
1
- {
2
- "name": "rfdc",
3
- "version": "1.4.1",
4
- "description": "Really Fast Deep Clone",
5
- "main": "index.js",
6
- "exports": {
7
- ".": "./index.js",
8
- "./default": "./default.js"
9
- },
10
- "scripts": {
11
- "test": "tap -R min test && npm run lint",
12
- "bench": "node benchmark",
13
- "lint": "standard --fix",
14
- "cov": "tap --100 test",
15
- "cov-ui": "tap --coverage-report=html test",
16
- "ci": "standard && tap --100 --coverage-report=text-lcov test | codecov --pipe"
17
- },
18
- "keywords": [
19
- "object",
20
- "obj",
21
- "properties",
22
- "clone",
23
- "copy",
24
- "deep",
25
- "recursive",
26
- "key",
27
- "keys",
28
- "values",
29
- "prop",
30
- "deep-clone",
31
- "deepclone",
32
- "deep-copy",
33
- "deepcopy",
34
- "fast",
35
- "performance",
36
- "performant",
37
- "fastclone",
38
- "fastcopy",
39
- "fast-clone",
40
- "fast-deep-clone",
41
- "fast-copy",
42
- "fast-deep-copy"
43
- ],
44
- "author": "David Mark Clements <david.clements@nearform.com>",
45
- "license": "MIT",
46
- "devDependencies": {
47
- "clone-deep": "^4.0.1",
48
- "codecov": "^3.4.0",
49
- "deep-copy": "^1.4.2",
50
- "fast-copy": "^1.2.1",
51
- "fastbench": "^1.0.1",
52
- "fastest-json-copy": "^1.0.1",
53
- "lodash.clonedeep": "^4.5.0",
54
- "nano-copy": "^0.1.0",
55
- "plain-object-clone": "^1.1.0",
56
- "ramda": "^0.27.1",
57
- "standard": "^17.0.0",
58
- "tap": "^12.0.1",
59
- "tsd": "^0.7.4"
60
- },
61
- "directories": {
62
- "test": "test"
63
- },
64
- "dependencies": {},
65
- "repository": {
66
- "type": "git",
67
- "url": "git+https://github.com/davidmarkclements/rfdc.git"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/davidmarkclements/rfdc/issues"
71
- },
72
- "homepage": "https://github.com/davidmarkclements/rfdc#readme"
73
- }
@@ -1,181 +0,0 @@
1
- # rfdc
2
-
3
- Really Fast Deep Clone
4
-
5
-
6
- [![build status](https://img.shields.io/travis/davidmarkclements/rfdc.svg)](https://travis-ci.org/davidmarkclements/rfdc)
7
- [![coverage](https://img.shields.io/codecov/c/github/davidmarkclements/rfdc.svg)](https://codecov.io/gh/davidmarkclements/rfdc)
8
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
9
-
10
-
11
- ## Usage
12
-
13
- ```js
14
- const clone = require('rfdc')()
15
- clone({a: 1, b: {c: 2}}) // => {a: 1, b: {c: 2}}
16
- ```
17
-
18
- ## API
19
-
20
- ### `require('rfdc')(opts = { proto: false, circles: false, constructorHandlers: [] }) => clone(obj) => obj2`
21
-
22
- #### `proto` option
23
-
24
- Copy prototype properties as well as own properties into the new object.
25
-
26
- It's marginally faster to allow enumerable properties on the prototype
27
- to be copied into the cloned object (not onto it's prototype, directly onto the object).
28
-
29
- To explain by way of code:
30
-
31
- ```js
32
- require('rfdc')({ proto: false })(Object.create({a: 1})) // => {}
33
- require('rfdc')({ proto: true })(Object.create({a: 1})) // => {a: 1}
34
- ```
35
-
36
- Setting `proto` to `true` will provide an additional 2% performance boost.
37
-
38
- #### `circles` option
39
-
40
- Keeping track of circular references will slow down performance with an
41
- additional 25% overhead. Even if an object doesn't have any circular references,
42
- the tracking overhead is the cost. By default if an object with a circular
43
- reference is passed to `rfdc`, it will throw (similar to how `JSON.stringify` \
44
- would throw).
45
-
46
- Use the `circles` option to detect and preserve circular references in the
47
- object. If performance is important, try removing the circular reference from
48
- the object (set to `undefined`) and then add it back manually after cloning
49
- instead of using this option.
50
-
51
- #### `constructorHandlers` option
52
-
53
- Sometimes consumers may want to add custom clone behaviour for particular classes
54
- (for example `RegExp` or `ObjectId`, which aren't supported out-of-the-box).
55
-
56
- This can be done by passing `constructorHandlers`, which takes an array of tuples,
57
- where the first item is the class to match, and the second item is a function that
58
- takes the input and returns a cloned output:
59
-
60
- ```js
61
- const clone = require('rfdc')({
62
- constructorHandlers: [
63
- [RegExp, (o) => new RegExp(o)],
64
- ]
65
- })
66
-
67
- clone({r: /foo/}) // => {r: /foo/}
68
- ```
69
-
70
- **NOTE**: For performance reasons, the handlers will only match an instance of the
71
- *exact* class (not a subclass). Subclasses will need to be added separately if they
72
- also need special clone behaviour.
73
-
74
- ### `default` import
75
- It is also possible to directly import the clone function with all options set
76
- to their default:
77
-
78
- ```js
79
- const clone = require("rfdc/default")
80
- clone({a: 1, b: {c: 2}}) // => {a: 1, b: {c: 2}}
81
- ```
82
-
83
- ### Types
84
-
85
- `rfdc` clones all JSON types:
86
-
87
- * `Object`
88
- * `Array`
89
- * `Number`
90
- * `String`
91
- * `null`
92
-
93
- With additional support for:
94
-
95
- * `Date` (copied)
96
- * `undefined` (copied)
97
- * `Buffer` (copied)
98
- * `TypedArray` (copied)
99
- * `Map` (copied)
100
- * `Set` (copied)
101
- * `Function` (referenced)
102
- * `AsyncFunction` (referenced)
103
- * `GeneratorFunction` (referenced)
104
- * `arguments` (copied to a normal object)
105
-
106
- All other types have output values that match the output
107
- of `JSON.parse(JSON.stringify(o))`.
108
-
109
- For instance:
110
-
111
- ```js
112
- const rfdc = require('rfdc')()
113
- const err = Error()
114
- err.code = 1
115
- JSON.parse(JSON.stringify(e)) // {code: 1}
116
- rfdc(e) // {code: 1}
117
-
118
- JSON.parse(JSON.stringify({rx: /foo/})) // {rx: {}}
119
- rfdc({rx: /foo/}) // {rx: {}}
120
- ```
121
-
122
- ## Benchmarks
123
-
124
- ```sh
125
- npm run bench
126
- ```
127
-
128
- ```
129
- benchDeepCopy*100: 671.675ms
130
- benchLodashCloneDeep*100: 1.574s
131
- benchCloneDeep*100: 936.792ms
132
- benchFastCopy*100: 822.668ms
133
- benchFastestJsonCopy*100: 363.898ms // See note below
134
- benchPlainObjectClone*100: 556.635ms
135
- benchNanoCopy*100: 770.234ms
136
- benchRamdaClone*100: 2.695s
137
- benchJsonParseJsonStringify*100: 2.290s // JSON.parse(JSON.stringify(obj))
138
- benchRfdc*100: 412.818ms
139
- benchRfdcProto*100: 424.076ms
140
- benchRfdcCircles*100: 443.357ms
141
- benchRfdcCirclesProto*100: 465.053ms
142
- ```
143
-
144
- It is true that [fastest-json-copy](https://www.npmjs.com/package/fastest-json-copy) may be faster, BUT it has such huge limitations that it is rarely useful. For example, it treats things like `Date` and `Map` instances the same as empty `{}`. It can't handle circular references. [plain-object-clone](https://www.npmjs.com/package/plain-object-clone) is also really limited in capability.
145
-
146
- ## Tests
147
-
148
- ```sh
149
- npm test
150
- ```
151
-
152
- ```
153
- 169 passing (342.514ms)
154
- ```
155
-
156
- ### Coverage
157
-
158
- ```sh
159
- npm run cov
160
- ```
161
-
162
- ```
163
- ----------|----------|----------|----------|----------|-------------------|
164
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
165
- ----------|----------|----------|----------|----------|-------------------|
166
- All files | 100 | 100 | 100 | 100 | |
167
- index.js | 100 | 100 | 100 | 100 | |
168
- ----------|----------|----------|----------|----------|-------------------|
169
- ```
170
-
171
- ### `__proto__` own property copying
172
-
173
- `rfdc` works the same way as `Object.assign` when it comes to copying `['__proto__']` (e.g. when
174
- an object has an own property key called '__proto__'). It results in the target object
175
- prototype object being set per the value of the `['__proto__']` own property.
176
-
177
- For detailed write-up on how a way to handle this security-wise see https://www.fastify.io/docs/latest/Guides/Prototype-Poisoning/.
178
-
179
- ## License
180
-
181
- MIT