@contrast/agent 4.32.10 → 4.32.12

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 (228) hide show
  1. package/bin/VERSION +1 -1
  2. package/bin/contrast-service-darwin-arm64 +0 -0
  3. package/bin/contrast-service-darwin-x64 +0 -0
  4. package/bin/contrast-service-linux-arm64 +0 -0
  5. package/bin/contrast-service-linux-x64 +0 -0
  6. package/bin/contrast-service-win32-x64.exe +0 -0
  7. package/node_modules/file-stream-rotator/FileStreamRotator.js +200 -41
  8. package/node_modules/file-stream-rotator/LICENSE.txt +17 -0
  9. package/node_modules/file-stream-rotator/README.md +16 -1
  10. package/node_modules/file-stream-rotator/package.json +5 -5
  11. package/node_modules/file-stream-rotator/tests/every-minute-test.js +32 -15
  12. package/node_modules/file-stream-rotator/tests/every-second-test.js +16 -7
  13. package/node_modules/file-stream-rotator/tests/large-test.js +33 -0
  14. package/node_modules/file-stream-rotator/tests/rotate-on-size-without-date.js +103 -0
  15. package/node_modules/object-hash/dist/object_hash.js +1 -2
  16. package/node_modules/object-hash/index.js +33 -21
  17. package/node_modules/object-hash/package.json +20 -18
  18. package/node_modules/object-hash/readme.markdown +20 -5
  19. package/node_modules/winston-daily-rotate-file/README.md +81 -12
  20. package/node_modules/winston-daily-rotate-file/daily-rotate-file.js +69 -30
  21. package/node_modules/winston-daily-rotate-file/index.d.ts +119 -72
  22. package/node_modules/winston-daily-rotate-file/package.json +20 -19
  23. package/node_modules/winston-transport/.eslintrc +1 -1
  24. package/node_modules/winston-transport/.nyc_output/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  25. package/node_modules/winston-transport/.nyc_output/processinfo/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  26. package/node_modules/winston-transport/.nyc_output/processinfo/index.json +1 -1
  27. package/node_modules/winston-transport/CHANGELOG.md +11 -0
  28. package/node_modules/winston-transport/dist/index.js +2 -2
  29. package/node_modules/winston-transport/index.d.ts +2 -0
  30. package/node_modules/winston-transport/index.js +2 -2
  31. package/node_modules/winston-transport/node_modules/readable-stream/README.md +106 -0
  32. package/node_modules/winston-transport/node_modules/readable-stream/errors-browser.js +127 -0
  33. package/node_modules/winston-transport/node_modules/readable-stream/errors.js +116 -0
  34. package/node_modules/winston-transport/node_modules/readable-stream/experimentalWarning.js +17 -0
  35. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_duplex.js +41 -46
  36. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_passthrough.js +1 -11
  37. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_readable.js +271 -263
  38. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_transform.js +18 -42
  39. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_writable.js +101 -147
  40. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  41. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  42. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  43. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  44. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  45. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  46. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  47. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  48. package/node_modules/winston-transport/node_modules/readable-stream/package.json +72 -0
  49. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable-browser.js +2 -0
  50. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable.js +5 -8
  51. package/node_modules/winston-transport/package.json +16 -14
  52. package/package.json +6 -6
  53. package/node_modules/colors/LICENSE +0 -25
  54. package/node_modules/colors/README.md +0 -221
  55. package/node_modules/colors/examples/normal-usage.js +0 -82
  56. package/node_modules/colors/examples/safe-string.js +0 -79
  57. package/node_modules/colors/index.d.ts +0 -136
  58. package/node_modules/colors/lib/colors.js +0 -211
  59. package/node_modules/colors/lib/custom/trap.js +0 -46
  60. package/node_modules/colors/lib/custom/zalgo.js +0 -110
  61. package/node_modules/colors/lib/extendStringPrototype.js +0 -110
  62. package/node_modules/colors/lib/index.js +0 -13
  63. package/node_modules/colors/lib/maps/america.js +0 -10
  64. package/node_modules/colors/lib/maps/rainbow.js +0 -12
  65. package/node_modules/colors/lib/maps/random.js +0 -11
  66. package/node_modules/colors/lib/maps/zebra.js +0 -5
  67. package/node_modules/colors/lib/styles.js +0 -95
  68. package/node_modules/colors/lib/system/has-flag.js +0 -35
  69. package/node_modules/colors/lib/system/supports-colors.js +0 -151
  70. package/node_modules/colors/package.json +0 -49
  71. package/node_modules/colors/safe.d.ts +0 -48
  72. package/node_modules/colors/safe.js +0 -10
  73. package/node_modules/colors/themes/generic-logging.js +0 -12
  74. package/node_modules/core-util-is/LICENSE +0 -19
  75. package/node_modules/core-util-is/README.md +0 -3
  76. package/node_modules/core-util-is/float.patch +0 -604
  77. package/node_modules/core-util-is/lib/util.js +0 -107
  78. package/node_modules/core-util-is/package.json +0 -36
  79. package/node_modules/core-util-is/test.js +0 -68
  80. package/node_modules/cycle/README.md +0 -49
  81. package/node_modules/cycle/cycle.js +0 -170
  82. package/node_modules/cycle/package.json +0 -16
  83. package/node_modules/fast-safe-stringify/.travis.yml +0 -8
  84. package/node_modules/fast-safe-stringify/CHANGELOG.md +0 -17
  85. package/node_modules/fast-safe-stringify/LICENSE +0 -23
  86. package/node_modules/fast-safe-stringify/benchmark.js +0 -137
  87. package/node_modules/fast-safe-stringify/index.d.ts +0 -8
  88. package/node_modules/fast-safe-stringify/index.js +0 -161
  89. package/node_modules/fast-safe-stringify/package.json +0 -50
  90. package/node_modules/fast-safe-stringify/readme.md +0 -154
  91. package/node_modules/fast-safe-stringify/test-stable.js +0 -311
  92. package/node_modules/fast-safe-stringify/test.js +0 -304
  93. package/node_modules/isarray/.npmignore +0 -1
  94. package/node_modules/isarray/.travis.yml +0 -4
  95. package/node_modules/isarray/Makefile +0 -6
  96. package/node_modules/isarray/README.md +0 -60
  97. package/node_modules/isarray/component.json +0 -19
  98. package/node_modules/isarray/index.js +0 -5
  99. package/node_modules/isarray/package.json +0 -49
  100. package/node_modules/isarray/test.js +0 -20
  101. package/node_modules/object-hash/.jshintrc +0 -19
  102. package/node_modules/object-hash/.travis.yml +0 -35
  103. package/node_modules/object-hash/bower.json +0 -15
  104. package/node_modules/object-hash/dist/object_hash.js.map +0 -1
  105. package/node_modules/object-hash/dist/object_hash_test.js +0 -4737
  106. package/node_modules/object-hash/gulpfile.js +0 -97
  107. package/node_modules/object-hash/karma.conf.js +0 -69
  108. package/node_modules/object-hash/test/blob.js +0 -41
  109. package/node_modules/object-hash/test/index.js +0 -290
  110. package/node_modules/object-hash/test/object-classes.js +0 -106
  111. package/node_modules/object-hash/test/old-crypto.js +0 -60
  112. package/node_modules/object-hash/test/replacer.js +0 -36
  113. package/node_modules/object-hash/test/types.js +0 -174
  114. package/node_modules/object-hash/test/writeToStream.js +0 -27
  115. package/node_modules/process-nextick-args/index.js +0 -45
  116. package/node_modules/process-nextick-args/license.md +0 -19
  117. package/node_modules/process-nextick-args/package.json +0 -29
  118. package/node_modules/process-nextick-args/readme.md +0 -18
  119. package/node_modules/readable-stream/.travis.yml +0 -34
  120. package/node_modules/readable-stream/README.md +0 -58
  121. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  122. package/node_modules/readable-stream/duplex-browser.js +0 -1
  123. package/node_modules/readable-stream/duplex.js +0 -1
  124. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  125. package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
  126. package/node_modules/readable-stream/package.json +0 -56
  127. package/node_modules/readable-stream/passthrough.js +0 -1
  128. package/node_modules/readable-stream/transform.js +0 -1
  129. package/node_modules/readable-stream/writable-browser.js +0 -1
  130. package/node_modules/readable-stream/writable.js +0 -8
  131. package/node_modules/winston-compat/.gitattributes +0 -1
  132. package/node_modules/winston-compat/.node-version +0 -1
  133. package/node_modules/winston-compat/CHANGELOG.md +0 -17
  134. package/node_modules/winston-compat/LICENSE +0 -22
  135. package/node_modules/winston-compat/README.md +0 -2
  136. package/node_modules/winston-compat/index.js +0 -295
  137. package/node_modules/winston-compat/lib/transport.js +0 -135
  138. package/node_modules/winston-compat/node_modules/fecha/CHANGELOG.md +0 -11
  139. package/node_modules/winston-compat/node_modules/fecha/LICENSE +0 -22
  140. package/node_modules/winston-compat/node_modules/fecha/README.md +0 -259
  141. package/node_modules/winston-compat/node_modules/fecha/fecha.d.ts +0 -47
  142. package/node_modules/winston-compat/node_modules/fecha/fecha.js +0 -334
  143. package/node_modules/winston-compat/node_modules/fecha/fecha.min.js +0 -1
  144. package/node_modules/winston-compat/node_modules/fecha/package.json +0 -44
  145. package/node_modules/winston-compat/node_modules/logform/.babelrc +0 -3
  146. package/node_modules/winston-compat/node_modules/logform/.eslintrc +0 -7
  147. package/node_modules/winston-compat/node_modules/logform/.gitattributes +0 -1
  148. package/node_modules/winston-compat/node_modules/logform/.travis.yml +0 -17
  149. package/node_modules/winston-compat/node_modules/logform/CHANGELOG.md +0 -103
  150. package/node_modules/winston-compat/node_modules/logform/LICENSE +0 -21
  151. package/node_modules/winston-compat/node_modules/logform/README.md +0 -170
  152. package/node_modules/winston-compat/node_modules/logform/align.js +0 -14
  153. package/node_modules/winston-compat/node_modules/logform/browser.js +0 -36
  154. package/node_modules/winston-compat/node_modules/logform/cli.js +0 -52
  155. package/node_modules/winston-compat/node_modules/logform/colorize.js +0 -118
  156. package/node_modules/winston-compat/node_modules/logform/combine.js +0 -66
  157. package/node_modules/winston-compat/node_modules/logform/dist/align.js +0 -14
  158. package/node_modules/winston-compat/node_modules/logform/dist/browser.js +0 -37
  159. package/node_modules/winston-compat/node_modules/logform/dist/cli.js +0 -75
  160. package/node_modules/winston-compat/node_modules/logform/dist/colorize.js +0 -147
  161. package/node_modules/winston-compat/node_modules/logform/dist/combine.js +0 -66
  162. package/node_modules/winston-compat/node_modules/logform/dist/format.js +0 -69
  163. package/node_modules/winston-compat/node_modules/logform/dist/index.js +0 -54
  164. package/node_modules/winston-compat/node_modules/logform/dist/json.js +0 -27
  165. package/node_modules/winston-compat/node_modules/logform/dist/label.js +0 -19
  166. package/node_modules/winston-compat/node_modules/logform/dist/levels.js +0 -15
  167. package/node_modules/winston-compat/node_modules/logform/dist/logstash.js +0 -32
  168. package/node_modules/winston-compat/node_modules/logform/dist/metadata.js +0 -63
  169. package/node_modules/winston-compat/node_modules/logform/dist/ms.js +0 -18
  170. package/node_modules/winston-compat/node_modules/logform/dist/pad-levels.js +0 -118
  171. package/node_modules/winston-compat/node_modules/logform/dist/pretty-print.js +0 -20
  172. package/node_modules/winston-compat/node_modules/logform/dist/printf.js +0 -40
  173. package/node_modules/winston-compat/node_modules/logform/dist/simple.js +0 -36
  174. package/node_modules/winston-compat/node_modules/logform/dist/splat.js +0 -147
  175. package/node_modules/winston-compat/node_modules/logform/dist/timestamp.js +0 -28
  176. package/node_modules/winston-compat/node_modules/logform/dist/uncolorize.js +0 -31
  177. package/node_modules/winston-compat/node_modules/logform/examples/combine.js +0 -14
  178. package/node_modules/winston-compat/node_modules/logform/examples/filter.js +0 -30
  179. package/node_modules/winston-compat/node_modules/logform/examples/invalid.js +0 -6
  180. package/node_modules/winston-compat/node_modules/logform/examples/metadata.js +0 -78
  181. package/node_modules/winston-compat/node_modules/logform/examples/padLevels.js +0 -39
  182. package/node_modules/winston-compat/node_modules/logform/examples/volume.js +0 -25
  183. package/node_modules/winston-compat/node_modules/logform/format.js +0 -52
  184. package/node_modules/winston-compat/node_modules/logform/index.d.ts +0 -53
  185. package/node_modules/winston-compat/node_modules/logform/index.js +0 -52
  186. package/node_modules/winston-compat/node_modules/logform/json.js +0 -26
  187. package/node_modules/winston-compat/node_modules/logform/label.js +0 -19
  188. package/node_modules/winston-compat/node_modules/logform/levels.js +0 -12
  189. package/node_modules/winston-compat/node_modules/logform/logstash.js +0 -29
  190. package/node_modules/winston-compat/node_modules/logform/metadata.js +0 -61
  191. package/node_modules/winston-compat/node_modules/logform/ms.js +0 -18
  192. package/node_modules/winston-compat/node_modules/logform/package.json +0 -51
  193. package/node_modules/winston-compat/node_modules/logform/pad-levels.js +0 -83
  194. package/node_modules/winston-compat/node_modules/logform/pretty-print.js +0 -16
  195. package/node_modules/winston-compat/node_modules/logform/printf.js +0 -26
  196. package/node_modules/winston-compat/node_modules/logform/simple.js +0 -33
  197. package/node_modules/winston-compat/node_modules/logform/splat.js +0 -125
  198. package/node_modules/winston-compat/node_modules/logform/timestamp.js +0 -30
  199. package/node_modules/winston-compat/node_modules/logform/tsconfig.json +0 -22
  200. package/node_modules/winston-compat/node_modules/logform/uncolorize.js +0 -27
  201. package/node_modules/winston-compat/package.json +0 -46
  202. package/node_modules/winston-compat/test/clone.test.js +0 -25
  203. package/node_modules/winston-compat/test/helpers.js +0 -256
  204. package/node_modules/winston-compat/test/timestamp.test.js +0 -14
  205. package/node_modules/winston-compat/test/transports/transport.js +0 -205
  206. package/node_modules/winston-compat/test/winston-compat.test.js +0 -18
  207. package/node_modules/winston-daily-rotate-file/.eslintrc.js +0 -11
  208. package/node_modules/winston-daily-rotate-file/.node-version +0 -1
  209. package/node_modules/winston-daily-rotate-file/.travis.yml +0 -15
  210. package/node_modules/winston-daily-rotate-file/node_modules/semver/CHANGELOG.md +0 -70
  211. package/node_modules/winston-daily-rotate-file/node_modules/semver/LICENSE +0 -15
  212. package/node_modules/winston-daily-rotate-file/node_modules/semver/README.md +0 -443
  213. package/node_modules/winston-daily-rotate-file/node_modules/semver/bin/semver.js +0 -174
  214. package/node_modules/winston-daily-rotate-file/node_modules/semver/package.json +0 -32
  215. package/node_modules/winston-daily-rotate-file/node_modules/semver/range.bnf +0 -16
  216. package/node_modules/winston-daily-rotate-file/node_modules/semver/semver.js +0 -1596
  217. package/node_modules/winston-daily-rotate-file/test/memory-stream.js +0 -38
  218. package/node_modules/winston-daily-rotate-file/test/random-string.js +0 -31
  219. package/node_modules/winston-daily-rotate-file/test/transport-tests.js +0 -250
  220. package/node_modules/winston-transport/.nyc_output/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
  221. package/node_modules/winston-transport/.nyc_output/processinfo/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
  222. package/node_modules/winston-transport/.travis.yml +0 -17
  223. package/node_modules/winston-transport/tsconfig.json +0 -22
  224. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/CONTRIBUTING.md +0 -0
  225. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/GOVERNANCE.md +0 -0
  226. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/LICENSE +0 -0
  227. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream-browser.js +0 -0
  228. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream.js +0 -0
@@ -1,161 +0,0 @@
1
- module.exports = stringify
2
- stringify.default = stringify
3
- stringify.stable = deterministicStringify
4
- stringify.stableStringify = deterministicStringify
5
-
6
- var arr = []
7
- var replacerStack = []
8
-
9
- // Regular stringify
10
- function stringify (obj, replacer, spacer) {
11
- decirc(obj, '', [], undefined)
12
- var res
13
- if (replacerStack.length === 0) {
14
- res = JSON.stringify(obj, replacer, spacer)
15
- } else {
16
- res = JSON.stringify(obj, replaceGetterValues(replacer), spacer)
17
- }
18
- while (arr.length !== 0) {
19
- var part = arr.pop()
20
- if (part.length === 4) {
21
- Object.defineProperty(part[0], part[1], part[3])
22
- } else {
23
- part[0][part[1]] = part[2]
24
- }
25
- }
26
- return res
27
- }
28
- function decirc (val, k, stack, parent) {
29
- var i
30
- if (typeof val === 'object' && val !== null) {
31
- for (i = 0; i < stack.length; i++) {
32
- if (stack[i] === val) {
33
- var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k)
34
- if (propertyDescriptor.get !== undefined) {
35
- if (propertyDescriptor.configurable) {
36
- Object.defineProperty(parent, k, { value: '[Circular]' })
37
- arr.push([parent, k, val, propertyDescriptor])
38
- } else {
39
- replacerStack.push([val, k])
40
- }
41
- } else {
42
- parent[k] = '[Circular]'
43
- arr.push([parent, k, val])
44
- }
45
- return
46
- }
47
- }
48
- stack.push(val)
49
- // Optimize for Arrays. Big arrays could kill the performance otherwise!
50
- if (Array.isArray(val)) {
51
- for (i = 0; i < val.length; i++) {
52
- decirc(val[i], i, stack, val)
53
- }
54
- } else {
55
- var keys = Object.keys(val)
56
- for (i = 0; i < keys.length; i++) {
57
- var key = keys[i]
58
- decirc(val[key], key, stack, val)
59
- }
60
- }
61
- stack.pop()
62
- }
63
- }
64
-
65
- // Stable-stringify
66
- function compareFunction (a, b) {
67
- if (a < b) {
68
- return -1
69
- }
70
- if (a > b) {
71
- return 1
72
- }
73
- return 0
74
- }
75
-
76
- function deterministicStringify (obj, replacer, spacer) {
77
- var tmp = deterministicDecirc(obj, '', [], undefined) || obj
78
- var res
79
- if (replacerStack.length === 0) {
80
- res = JSON.stringify(tmp, replacer, spacer)
81
- } else {
82
- res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer)
83
- }
84
- while (arr.length !== 0) {
85
- var part = arr.pop()
86
- if (part.length === 4) {
87
- Object.defineProperty(part[0], part[1], part[3])
88
- } else {
89
- part[0][part[1]] = part[2]
90
- }
91
- }
92
- return res
93
- }
94
-
95
- function deterministicDecirc (val, k, stack, parent) {
96
- var i
97
- if (typeof val === 'object' && val !== null) {
98
- for (i = 0; i < stack.length; i++) {
99
- if (stack[i] === val) {
100
- var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k)
101
- if (propertyDescriptor.get !== undefined) {
102
- if (propertyDescriptor.configurable) {
103
- Object.defineProperty(parent, k, { value: '[Circular]' })
104
- arr.push([parent, k, val, propertyDescriptor])
105
- } else {
106
- replacerStack.push([val, k])
107
- }
108
- } else {
109
- parent[k] = '[Circular]'
110
- arr.push([parent, k, val])
111
- }
112
- return
113
- }
114
- }
115
- if (typeof val.toJSON === 'function') {
116
- return
117
- }
118
- stack.push(val)
119
- // Optimize for Arrays. Big arrays could kill the performance otherwise!
120
- if (Array.isArray(val)) {
121
- for (i = 0; i < val.length; i++) {
122
- deterministicDecirc(val[i], i, stack, val)
123
- }
124
- } else {
125
- // Create a temporary object in the required way
126
- var tmp = {}
127
- var keys = Object.keys(val).sort(compareFunction)
128
- for (i = 0; i < keys.length; i++) {
129
- var key = keys[i]
130
- deterministicDecirc(val[key], key, stack, val)
131
- tmp[key] = val[key]
132
- }
133
- if (parent !== undefined) {
134
- arr.push([parent, k, val])
135
- parent[k] = tmp
136
- } else {
137
- return tmp
138
- }
139
- }
140
- stack.pop()
141
- }
142
- }
143
-
144
- // wraps replacer function to handle values we couldn't replace
145
- // and mark them as [Circular]
146
- function replaceGetterValues (replacer) {
147
- replacer = replacer !== undefined ? replacer : function (k, v) { return v }
148
- return function (key, val) {
149
- if (replacerStack.length > 0) {
150
- for (var i = 0; i < replacerStack.length; i++) {
151
- var part = replacerStack[i]
152
- if (part[1] === key && part[0] === val) {
153
- val = '[Circular]'
154
- replacerStack.splice(i, 1)
155
- break
156
- }
157
- }
158
- }
159
- return replacer.call(this, key, val)
160
- }
161
- }
@@ -1,50 +0,0 @@
1
- {
2
- "name": "fast-safe-stringify",
3
- "version": "2.0.7",
4
- "description": "Safely and quickly serialize JavaScript objects",
5
- "keywords": [
6
- "stable",
7
- "stringify",
8
- "JSON",
9
- "JSON.stringify",
10
- "safe",
11
- "serialize"
12
- ],
13
- "main": "index.js",
14
- "scripts": {
15
- "test": "standard && tap --no-esm test.js test-stable.js",
16
- "benchmark": "node benchmark.js"
17
- },
18
- "author": "David Mark Clements",
19
- "contributors": [
20
- "Ruben Bridgewater",
21
- "Matteo Collina",
22
- "Ben Gourley",
23
- "Gabriel Lesperance",
24
- "Alex Liu",
25
- "Christoph Walcher",
26
- "Nicholas Young"
27
- ],
28
- "license": "MIT",
29
- "typings": "index",
30
- "devDependencies": {
31
- "benchmark": "^2.1.4",
32
- "clone": "^2.1.0",
33
- "json-stringify-safe": "^5.0.1",
34
- "standard": "^11.0.0",
35
- "tap": "^12.0.0"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/davidmarkclements/fast-safe-stringify.git"
40
- },
41
- "bugs": {
42
- "url": "https://github.com/davidmarkclements/fast-safe-stringify/issues"
43
- },
44
- "homepage": "https://github.com/davidmarkclements/fast-safe-stringify#readme",
45
- "dependencies": {}
46
-
47
- ,"_resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz"
48
- ,"_integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA=="
49
- ,"_from": "fast-safe-stringify@2.0.7"
50
- }
@@ -1,154 +0,0 @@
1
- # fast-safe-stringify
2
-
3
- Safe and fast serialization alternative to [JSON.stringify][].
4
-
5
- Gracefully handles circular structures instead of throwing.
6
-
7
- Provides a deterministic ("stable") version as well that will also gracefully
8
- handle circular structures. See the example below for further information.
9
-
10
- ## Usage
11
-
12
- The same as [JSON.stringify][].
13
-
14
- `stringify(value[, replacer[, space]])`
15
-
16
- ```js
17
- const safeStringify = require('fast-safe-stringify')
18
- const o = { a: 1 }
19
- o.o = o
20
-
21
- console.log(safeStringify(o))
22
- // '{"a":1,"o":"[Circular]"}'
23
- console.log(JSON.stringify(o))
24
- // TypeError: Converting circular structure to JSON
25
-
26
- function replacer(key, value) {
27
- console.log('Key:', JSON.stringify(key), 'Value:', JSON.stringify(value))
28
- // Remove the circular structure
29
- if (value === '[Circular]') {
30
- return
31
- }
32
- return value
33
- }
34
- const serialized = safeStringify(o, replacer, 2)
35
- // Key: "" Value: {"a":1,"o":"[Circular]"}
36
- // Key: "a" Value: 1
37
- // Key: "o" Value: "[Circular]"
38
- console.log(serialized)
39
- // {
40
- // "a": 1
41
- // }
42
- ```
43
-
44
- Using the deterministic version also works the same:
45
-
46
- ```js
47
- const safeStringify = require('fast-safe-stringify')
48
- const o = { b: 1, a: 0 }
49
- o.o = o
50
-
51
- console.log(safeStringify(o))
52
- // '{"b":1,"a":0,"o":"[Circular]"}'
53
- console.log(safeStringify.stableStringify(o))
54
- // '{"a":0,"b":1,"o":"[Circular]"}'
55
- console.log(JSON.stringify(o))
56
- // TypeError: Converting circular structure to JSON
57
- ```
58
-
59
- A faster and side-effect free implementation is available in the
60
- [safe-stable-stringify][] module. However it is still considered experimental
61
- due to a new and more complex implementation.
62
-
63
- ## Differences to JSON.stringify
64
-
65
- In general the behavior is identical to [JSON.stringify][]. The [`replacer`][]
66
- and [`space`][] options are also available.
67
-
68
- A few exceptions exist to [JSON.stringify][] while using [`toJSON`][] or
69
- [`replacer`][]:
70
-
71
- ### Regular safe stringify
72
-
73
- - Manipulating a circular structure of the passed in value in a `toJSON` or the
74
- `replacer` is not possible! It is possible for any other value and property.
75
-
76
- - In case a circular structure is detected and the [`replacer`][] is used it
77
- will receive the string `[Circular]` as the argument instead of the circular
78
- object itself.
79
-
80
- ### Deterministic ("stable") safe stringify
81
-
82
- - Manipulating the input object either in a [`toJSON`][] or the [`replacer`][]
83
- function will not have any effect on the output. The output entirely relies on
84
- the shape the input value had at the point passed to the stringify function!
85
-
86
- - In case a circular structure is detected and the [`replacer`][] is used it
87
- will receive the string `[Circular]` as the argument instead of the circular
88
- object itself.
89
-
90
- A side effect free variation without these limitations can be found as well
91
- ([`safe-stable-stringify`][]). It is also faster than the current
92
- implementation. It is still considered experimental due to a new and more
93
- complex implementation.
94
-
95
- ## Benchmarks
96
-
97
- Although not JSON, the Node.js `util.inspect` method can be used for similar
98
- purposes (e.g. logging) and also handles circular references.
99
-
100
- Here we compare `fast-safe-stringify` with some alternatives:
101
- (Lenovo T450s with a i7-5600U CPU using Node.js 8.9.4)
102
-
103
- ```md
104
- fast-safe-stringify: simple object x 1,121,497 ops/sec ±0.75% (97 runs sampled)
105
- fast-safe-stringify: circular x 560,126 ops/sec ±0.64% (96 runs sampled)
106
- fast-safe-stringify: deep x 32,472 ops/sec ±0.57% (95 runs sampled)
107
- fast-safe-stringify: deep circular x 32,513 ops/sec ±0.80% (92 runs sampled)
108
-
109
- util.inspect: simple object x 272,837 ops/sec ±1.48% (90 runs sampled)
110
- util.inspect: circular x 116,896 ops/sec ±1.19% (95 runs sampled)
111
- util.inspect: deep x 19,382 ops/sec ±0.66% (92 runs sampled)
112
- util.inspect: deep circular x 18,717 ops/sec ±0.63% (96 runs sampled)
113
-
114
- json-stringify-safe: simple object x 233,621 ops/sec ±0.97% (94 runs sampled)
115
- json-stringify-safe: circular x 110,409 ops/sec ±1.85% (95 runs sampled)
116
- json-stringify-safe: deep x 8,705 ops/sec ±0.87% (96 runs sampled)
117
- json-stringify-safe: deep circular x 8,336 ops/sec ±2.20% (93 runs sampled)
118
- ```
119
-
120
- For stable stringify comparisons, see the performance benchmarks in the
121
- [`safe-stable-stringify`][] readme.
122
-
123
- ## Protip
124
-
125
- Whether `fast-safe-stringify` or alternatives are used: if the use case
126
- consists of deeply nested objects without circular references the following
127
- pattern will give best results.
128
- Shallow or one level nested objects on the other hand will slow down with it.
129
- It is entirely dependant on the use case.
130
-
131
- ```js
132
- const stringify = require('fast-safe-stringify')
133
-
134
- function tryJSONStringify (obj) {
135
- try { return JSON.stringify(obj) } catch (_) {}
136
- }
137
-
138
- const serializedString = tryJSONStringify(deep) || stringify(deep)
139
- ```
140
-
141
- ## Acknowledgements
142
-
143
- Sponsored by [nearForm](http://nearform.com)
144
-
145
- ## License
146
-
147
- MIT
148
-
149
- [`replacer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The%20replacer%20parameter
150
- [`safe-stable-stringify`]: https://github.com/BridgeAR/safe-stable-stringify
151
- [`space`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The%20space%20argument
152
- [`toJSON`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior
153
- [benchmark]: https://github.com/epoberezkin/fast-json-stable-stringify/blob/67f688f7441010cfef91a6147280cc501701e83b/benchmark
154
- [JSON.stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
@@ -1,311 +0,0 @@
1
- const test = require('tap').test
2
- const fss = require('./').stable
3
- const clone = require('clone')
4
- const s = JSON.stringify
5
-
6
- test('circular reference to root', function (assert) {
7
- const fixture = { name: 'Tywin Lannister' }
8
- fixture.circle = fixture
9
- const expected = s(
10
- { circle: '[Circular]', name: 'Tywin Lannister' }
11
- )
12
- const actual = fss(fixture)
13
- assert.is(actual, expected)
14
- assert.end()
15
- })
16
-
17
- test('circular getter reference to root', function (assert) {
18
- const fixture = {
19
- name: 'Tywin Lannister',
20
- get circle () {
21
- return fixture
22
- }
23
- }
24
-
25
- const expected = s(
26
- { circle: '[Circular]', name: 'Tywin Lannister' }
27
- )
28
- const actual = fss(fixture)
29
- assert.is(actual, expected)
30
- assert.end()
31
- })
32
-
33
- test('nested circular reference to root', function (assert) {
34
- const fixture = { name: 'Tywin Lannister' }
35
- fixture.id = { circle: fixture }
36
- const expected = s(
37
- { id: { circle: '[Circular]' }, name: 'Tywin Lannister' }
38
- )
39
- const actual = fss(fixture)
40
- assert.is(actual, expected)
41
- assert.end()
42
- })
43
-
44
- test('child circular reference', function (assert) {
45
- const fixture = { name: 'Tywin Lannister', child: { name: 'Tyrion Lannister' } }
46
- fixture.child.dinklage = fixture.child
47
- const expected = s({
48
- child: {
49
- dinklage: '[Circular]', name: 'Tyrion Lannister'
50
- },
51
- name: 'Tywin Lannister'
52
- })
53
- const actual = fss(fixture)
54
- assert.is(actual, expected)
55
- assert.end()
56
- })
57
-
58
- test('nested child circular reference', function (assert) {
59
- const fixture = { name: 'Tywin Lannister', child: { name: 'Tyrion Lannister' } }
60
- fixture.child.actor = { dinklage: fixture.child }
61
- const expected = s({
62
- child: {
63
- actor: { dinklage: '[Circular]' }, name: 'Tyrion Lannister'
64
- },
65
- name: 'Tywin Lannister'
66
- })
67
- const actual = fss(fixture)
68
- assert.is(actual, expected)
69
- assert.end()
70
- })
71
-
72
- test('circular objects in an array', function (assert) {
73
- const fixture = { name: 'Tywin Lannister' }
74
- fixture.hand = [fixture, fixture]
75
- const expected = s({
76
- hand: ['[Circular]', '[Circular]'], name: 'Tywin Lannister'
77
- })
78
- const actual = fss(fixture)
79
- assert.is(actual, expected)
80
- assert.end()
81
- })
82
-
83
- test('nested circular references in an array', function (assert) {
84
- const fixture = {
85
- name: 'Tywin Lannister',
86
- offspring: [{ name: 'Tyrion Lannister' }, { name: 'Cersei Lannister' }]
87
- }
88
- fixture.offspring[0].dinklage = fixture.offspring[0]
89
- fixture.offspring[1].headey = fixture.offspring[1]
90
-
91
- const expected = s({
92
- name: 'Tywin Lannister',
93
- offspring: [
94
- { dinklage: '[Circular]', name: 'Tyrion Lannister' },
95
- { headey: '[Circular]', name: 'Cersei Lannister' }
96
- ]
97
- })
98
- const actual = fss(fixture)
99
- assert.is(actual, expected)
100
- assert.end()
101
- })
102
-
103
- test('circular arrays', function (assert) {
104
- const fixture = []
105
- fixture.push(fixture, fixture)
106
- const expected = s(['[Circular]', '[Circular]'])
107
- const actual = fss(fixture)
108
- assert.is(actual, expected)
109
- assert.end()
110
- })
111
-
112
- test('nested circular arrays', function (assert) {
113
- const fixture = []
114
- fixture.push(
115
- { name: 'Jon Snow', bastards: fixture },
116
- { name: 'Ramsay Bolton', bastards: fixture }
117
- )
118
- const expected = s([
119
- { bastards: '[Circular]', name: 'Jon Snow' },
120
- { bastards: '[Circular]', name: 'Ramsay Bolton' }
121
- ])
122
- const actual = fss(fixture)
123
- assert.is(actual, expected)
124
- assert.end()
125
- })
126
-
127
- test('repeated non-circular references in objects', function (assert) {
128
- const daenerys = { name: 'Daenerys Targaryen' }
129
- const fixture = {
130
- motherOfDragons: daenerys,
131
- queenOfMeereen: daenerys
132
- }
133
- const expected = s(fixture)
134
- const actual = fss(fixture)
135
- assert.is(actual, expected)
136
- assert.end()
137
- })
138
-
139
- test('repeated non-circular references in arrays', function (assert) {
140
- const daenerys = { name: 'Daenerys Targaryen' }
141
- const fixture = [daenerys, daenerys]
142
- const expected = s(fixture)
143
- const actual = fss(fixture)
144
- assert.is(actual, expected)
145
- assert.end()
146
- })
147
-
148
- test('double child circular reference', function (assert) {
149
- // create circular reference
150
- const child = { name: 'Tyrion Lannister' }
151
- child.dinklage = child
152
-
153
- // include it twice in the fixture
154
- const fixture = { name: 'Tywin Lannister', childA: child, childB: child }
155
- const cloned = clone(fixture)
156
- const expected = s({
157
- childA: {
158
- dinklage: '[Circular]', name: 'Tyrion Lannister'
159
- },
160
- childB: {
161
- dinklage: '[Circular]', name: 'Tyrion Lannister'
162
- },
163
- name: 'Tywin Lannister'
164
- })
165
- const actual = fss(fixture)
166
- assert.is(actual, expected)
167
-
168
- // check if the fixture has not been modified
169
- assert.deepEqual(fixture, cloned)
170
- assert.end()
171
- })
172
-
173
- test('child circular reference with toJSON', function (assert) {
174
- // Create a test object that has an overriden `toJSON` property
175
- TestObject.prototype.toJSON = function () { return { special: 'case' } }
176
- function TestObject (content) {}
177
-
178
- // Creating a simple circular object structure
179
- const parentObject = {}
180
- parentObject.childObject = new TestObject()
181
- parentObject.childObject.parentObject = parentObject
182
-
183
- // Creating a simple circular object structure
184
- const otherParentObject = new TestObject()
185
- otherParentObject.otherChildObject = {}
186
- otherParentObject.otherChildObject.otherParentObject = otherParentObject
187
-
188
- // Making sure our original tests work
189
- assert.deepEqual(parentObject.childObject.parentObject, parentObject)
190
- assert.deepEqual(otherParentObject.otherChildObject.otherParentObject, otherParentObject)
191
-
192
- // Should both be idempotent
193
- assert.equal(fss(parentObject), '{"childObject":{"special":"case"}}')
194
- assert.equal(fss(otherParentObject), '{"special":"case"}')
195
-
196
- // Therefore the following assertion should be `true`
197
- assert.deepEqual(parentObject.childObject.parentObject, parentObject)
198
- assert.deepEqual(otherParentObject.otherChildObject.otherParentObject, otherParentObject)
199
-
200
- assert.end()
201
- })
202
-
203
- test('null object', function (assert) {
204
- const expected = s(null)
205
- const actual = fss(null)
206
- assert.is(actual, expected)
207
- assert.end()
208
- })
209
-
210
- test('null property', function (assert) {
211
- const expected = s({ f: null })
212
- const actual = fss({ f: null })
213
- assert.is(actual, expected)
214
- assert.end()
215
- })
216
-
217
- test('nested child circular reference in toJSON', function (assert) {
218
- var circle = { some: 'data' }
219
- circle.circle = circle
220
- var a = {
221
- b: {
222
- toJSON: function () {
223
- a.b = 2
224
- return '[Redacted]'
225
- }
226
- },
227
- baz: {
228
- circle,
229
- toJSON: function () {
230
- a.baz = circle
231
- return '[Redacted]'
232
- }
233
- }
234
- }
235
- var o = {
236
- a,
237
- bar: a
238
- }
239
-
240
- const expected = s({
241
- a: {
242
- b: '[Redacted]',
243
- baz: '[Redacted]'
244
- },
245
- bar: {
246
- // TODO: This is a known limitation of the current implementation.
247
- // The ideal result would be:
248
- //
249
- // b: 2,
250
- // baz: {
251
- // circle: '[Circular]',
252
- // some: 'data'
253
- // }
254
- //
255
- b: '[Redacted]',
256
- baz: '[Redacted]'
257
- }
258
- })
259
- const actual = fss(o)
260
- assert.is(actual, expected)
261
- assert.end()
262
- })
263
-
264
- test('circular getters are restored when stringified', function (assert) {
265
- const fixture = {
266
- name: 'Tywin Lannister',
267
- get circle () {
268
- return fixture
269
- }
270
- }
271
- fss(fixture)
272
-
273
- assert.is(fixture.circle, fixture)
274
- assert.end()
275
- })
276
-
277
- test('non-configurable circular getters use a replacer instead of markers', function (assert) {
278
- const fixture = { name: 'Tywin Lannister' }
279
- Object.defineProperty(fixture, 'circle', {
280
- configurable: false,
281
- get: function () { return fixture },
282
- enumerable: true
283
- })
284
-
285
- fss(fixture)
286
-
287
- assert.is(fixture.circle, fixture)
288
- assert.end()
289
- })
290
-
291
- test('getter child circular reference', function (assert) {
292
- const fixture = {
293
- name: 'Tywin Lannister',
294
- child: {
295
- name: 'Tyrion Lannister',
296
- get dinklage () { return fixture.child }
297
- },
298
- get self () { return fixture }
299
- }
300
-
301
- const expected = s({
302
- child: {
303
- dinklage: '[Circular]', name: 'Tyrion Lannister'
304
- },
305
- name: 'Tywin Lannister',
306
- self: '[Circular]'
307
- })
308
- const actual = fss(fixture)
309
- assert.is(actual, expected)
310
- assert.end()
311
- })