projen 0.80.7 → 0.80.9

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 (187) hide show
  1. package/.jsii +41 -41
  2. package/lib/awscdk/auto-discover.js +5 -5
  3. package/lib/awscdk/awscdk-app-java.js +1 -1
  4. package/lib/awscdk/awscdk-app-py.js +1 -1
  5. package/lib/awscdk/awscdk-app-ts.js +1 -1
  6. package/lib/awscdk/awscdk-construct.js +2 -2
  7. package/lib/awscdk/awscdk-deps-java.js +1 -1
  8. package/lib/awscdk/awscdk-deps-js.js +1 -1
  9. package/lib/awscdk/awscdk-deps-py.js +1 -1
  10. package/lib/awscdk/awscdk-deps.js +1 -1
  11. package/lib/awscdk/cdk-config.js +1 -1
  12. package/lib/awscdk/cdk-tasks.js +1 -1
  13. package/lib/awscdk/integration-test.js +1 -1
  14. package/lib/awscdk/lambda-extension.js +1 -1
  15. package/lib/awscdk/lambda-function.js +2 -2
  16. package/lib/build/build-workflow.js +1 -1
  17. package/lib/cdk/auto-discover-base.js +2 -2
  18. package/lib/cdk/construct-lib.js +1 -1
  19. package/lib/cdk/integration-test-base.js +1 -1
  20. package/lib/cdk/jsii-docgen.js +1 -1
  21. package/lib/cdk/jsii-project.js +1 -1
  22. package/lib/cdk8s/auto-discover.js +2 -2
  23. package/lib/cdk8s/cdk8s-app-py.js +1 -1
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps.js +1 -1
  28. package/lib/cdk8s/integration-test.js +1 -1
  29. package/lib/cdktf/cdktf-construct.js +1 -1
  30. package/lib/circleci/circleci.js +1 -1
  31. package/lib/component.js +1 -1
  32. package/lib/dependencies.js +1 -1
  33. package/lib/dev-env.js +1 -1
  34. package/lib/docker-compose/docker-compose-service.js +1 -1
  35. package/lib/docker-compose/docker-compose.js +1 -1
  36. package/lib/file.js +1 -1
  37. package/lib/gitattributes.js +1 -1
  38. package/lib/github/actions-provider.js +1 -1
  39. package/lib/github/auto-approve.js +1 -1
  40. package/lib/github/auto-merge.js +1 -1
  41. package/lib/github/dependabot.js +1 -1
  42. package/lib/github/github-credentials.js +1 -1
  43. package/lib/github/github-project.js +1 -1
  44. package/lib/github/github.js +1 -1
  45. package/lib/github/mergify.js +1 -1
  46. package/lib/github/pr-template.js +1 -1
  47. package/lib/github/pull-request-lint.js +1 -1
  48. package/lib/github/stale.js +1 -1
  49. package/lib/github/task-workflow-job.js +1 -1
  50. package/lib/github/task-workflow.js +1 -1
  51. package/lib/github/workflow-actions.js +1 -1
  52. package/lib/github/workflow-jobs.js +1 -1
  53. package/lib/github/workflow-steps.js +1 -1
  54. package/lib/github/workflows.js +1 -1
  55. package/lib/gitlab/configuration.js +1 -1
  56. package/lib/gitlab/gitlab-configuration.js +1 -1
  57. package/lib/gitlab/nested-configuration.js +1 -1
  58. package/lib/gitpod.js +1 -1
  59. package/lib/ignore-file.js +1 -1
  60. package/lib/ini.js +1 -1
  61. package/lib/java/java-project.js +1 -1
  62. package/lib/java/junit.js +1 -1
  63. package/lib/java/maven-compile.js +1 -1
  64. package/lib/java/maven-packaging.js +1 -1
  65. package/lib/java/maven-sample.js +1 -1
  66. package/lib/java/pom.js +1 -1
  67. package/lib/java/projenrc.js +1 -1
  68. package/lib/javascript/bundler.js +1 -1
  69. package/lib/javascript/eslint.js +1 -1
  70. package/lib/javascript/jest.js +4 -4
  71. package/lib/javascript/license-checker.js +1 -1
  72. package/lib/javascript/node-package.js +1 -1
  73. package/lib/javascript/node-project.js +1 -1
  74. package/lib/javascript/npm-config.js +1 -1
  75. package/lib/javascript/prettier.js +1 -1
  76. package/lib/javascript/projenrc.js +1 -1
  77. package/lib/javascript/typescript-config.js +2 -2
  78. package/lib/javascript/upgrade-dependencies.js +2 -2
  79. package/lib/javascript/yarnrc.js +1 -1
  80. package/lib/json-patch.js +1 -1
  81. package/lib/json.js +1 -1
  82. package/lib/license.js +1 -1
  83. package/lib/logger.js +1 -1
  84. package/lib/makefile.js +1 -1
  85. package/lib/object-file.js +1 -1
  86. package/lib/project-build.js +1 -1
  87. package/lib/project-tree.js +1 -1
  88. package/lib/project.js +1 -1
  89. package/lib/projects.js +1 -1
  90. package/lib/projenrc-json.js +2 -2
  91. package/lib/projenrc.js +1 -1
  92. package/lib/python/pip.js +1 -1
  93. package/lib/python/poetry.d.ts +3 -7
  94. package/lib/python/poetry.js +21 -43
  95. package/lib/python/projenrc.js +1 -1
  96. package/lib/python/pytest-sample.js +1 -1
  97. package/lib/python/pytest.js +1 -1
  98. package/lib/python/python-project.js +1 -1
  99. package/lib/python/python-sample.js +1 -1
  100. package/lib/python/requirements-file.js +1 -1
  101. package/lib/python/setuppy.js +1 -1
  102. package/lib/python/setuptools.js +1 -1
  103. package/lib/python/venv.js +1 -1
  104. package/lib/readme.js +1 -1
  105. package/lib/release/publisher.js +1 -1
  106. package/lib/release/release-trigger.js +1 -1
  107. package/lib/release/release.js +1 -1
  108. package/lib/renovatebot.js +1 -1
  109. package/lib/sample-file.js +2 -2
  110. package/lib/semver.js +1 -1
  111. package/lib/source-code.js +1 -1
  112. package/lib/task-runtime.js +1 -1
  113. package/lib/task.js +1 -1
  114. package/lib/tasks.js +1 -1
  115. package/lib/testing.js +1 -1
  116. package/lib/textfile.js +1 -1
  117. package/lib/toml.js +8 -10
  118. package/lib/typescript/projenrc-ts.js +1 -1
  119. package/lib/typescript/projenrc.js +1 -1
  120. package/lib/typescript/typescript-typedoc.js +1 -1
  121. package/lib/typescript/typescript.js +6 -6
  122. package/lib/version.js +2 -2
  123. package/lib/vscode/devcontainer.js +1 -1
  124. package/lib/vscode/extensions.js +1 -1
  125. package/lib/vscode/launch-config.js +1 -1
  126. package/lib/vscode/settings.js +1 -1
  127. package/lib/vscode/vscode.js +1 -1
  128. package/lib/web/next.js +3 -3
  129. package/lib/web/postcss.js +1 -1
  130. package/lib/web/react.js +4 -4
  131. package/lib/web/tailwind.js +1 -1
  132. package/lib/xmlfile.js +1 -1
  133. package/lib/yaml.js +1 -1
  134. package/node_modules/@iarna/toml/LICENSE +14 -0
  135. package/node_modules/@iarna/toml/README.md +301 -0
  136. package/node_modules/@iarna/toml/index.d.ts +57 -0
  137. package/node_modules/@iarna/toml/lib/create-date.js +23 -0
  138. package/node_modules/@iarna/toml/lib/create-datetime-float.js +24 -0
  139. package/node_modules/@iarna/toml/lib/create-datetime.js +10 -0
  140. package/node_modules/@iarna/toml/lib/create-time.js +22 -0
  141. package/node_modules/@iarna/toml/lib/format-num.js +6 -0
  142. package/node_modules/@iarna/toml/lib/parser-debug.js +60 -0
  143. package/node_modules/@iarna/toml/lib/parser.js +127 -0
  144. package/node_modules/@iarna/toml/lib/toml-parser.js +1379 -0
  145. package/node_modules/@iarna/toml/package.json +82 -0
  146. package/node_modules/@iarna/toml/parse-async.js +30 -0
  147. package/node_modules/@iarna/toml/parse-pretty-error.js +33 -0
  148. package/node_modules/@iarna/toml/parse-stream.js +80 -0
  149. package/node_modules/@iarna/toml/parse-string.js +18 -0
  150. package/node_modules/@iarna/toml/parse.js +5 -0
  151. package/node_modules/@iarna/toml/stringify.js +296 -0
  152. package/node_modules/@iarna/toml/toml.js +3 -0
  153. package/node_modules/yaml/browser/dist/parse/parser.js +4 -1
  154. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +19 -10
  155. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +5 -12
  156. package/node_modules/yaml/dist/parse/parser.js +4 -1
  157. package/node_modules/yaml/dist/stringify/foldFlowLines.js +19 -10
  158. package/node_modules/yaml/dist/stringify/stringifyCollection.js +5 -12
  159. package/node_modules/yaml/package.json +1 -1
  160. package/package.json +8 -8
  161. package/node_modules/json2toml/CHANGELOG.md +0 -128
  162. package/node_modules/json2toml/LICENSE.txt +0 -18
  163. package/node_modules/json2toml/README.md +0 -52
  164. package/node_modules/json2toml/index.d.ts +0 -13
  165. package/node_modules/json2toml/index.js +0 -160
  166. package/node_modules/json2toml/package.json +0 -62
  167. package/node_modules/lodash.isdate/LICENSE +0 -47
  168. package/node_modules/lodash.isdate/README.md +0 -18
  169. package/node_modules/lodash.isdate/index.js +0 -119
  170. package/node_modules/lodash.isdate/package.json +0 -17
  171. package/node_modules/lodash.isempty/LICENSE +0 -47
  172. package/node_modules/lodash.isempty/README.md +0 -18
  173. package/node_modules/lodash.isempty/index.js +0 -582
  174. package/node_modules/lodash.isempty/package.json +0 -17
  175. package/node_modules/lodash.isplainobject/LICENSE +0 -47
  176. package/node_modules/lodash.isplainobject/README.md +0 -18
  177. package/node_modules/lodash.isplainobject/index.js +0 -139
  178. package/node_modules/lodash.isplainobject/package.json +0 -17
  179. package/node_modules/strftime/Changelog.md +0 -286
  180. package/node_modules/strftime/Makefile +0 -15
  181. package/node_modules/strftime/Readme.md +0 -208
  182. package/node_modules/strftime/bower.json +0 -13
  183. package/node_modules/strftime/component.json +0 -16
  184. package/node_modules/strftime/package.json +0 -53
  185. package/node_modules/strftime/strftime-min.js +0 -21
  186. package/node_modules/strftime/strftime.js +0 -854
  187. package/node_modules/strftime/test.js +0 -271
@@ -0,0 +1,301 @@
1
+ # @iarna/toml
2
+
3
+ Better TOML parsing and stringifying all in that familiar JSON interface.
4
+
5
+ [![Coverage Status](https://coveralls.io/repos/github/iarna/iarna-toml/badge.svg)](https://coveralls.io/github/iarna/iarna-toml)
6
+
7
+ # ** TOML 0.5.0 **
8
+
9
+ ### TOML Spec Support
10
+
11
+ The most recent version as of 2018-07-26: [v0.5.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.5.0.md)
12
+
13
+ ### Example
14
+
15
+ ```js
16
+ const TOML = require('@iarna/toml')
17
+ const obj = TOML.parse(`[abc]
18
+ foo = 123
19
+ bar = [1,2,3]`)
20
+ /* obj =
21
+ {abc: {foo: 123, bar: [1,2,3]}}
22
+ */
23
+ const str = TOML.stringify(obj)
24
+ /* str =
25
+ [abc]
26
+ foo = 123
27
+ bar = [ 1, 2, 3 ]
28
+ */
29
+ ```
30
+
31
+ Visit the project github [for more examples](https://github.com/iarna/iarna-toml/tree/latest/examples)!
32
+
33
+
34
+ ## Why @iarna/toml
35
+
36
+ * See [TOML-SPEC-SUPPORT](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html)
37
+ for a comparison of which TOML features are supported by the various
38
+ Node.js TOML parsers.
39
+ * BigInt support on Node 10!
40
+ * 100% test coverage.
41
+ * Fast parsing. It's as much as 100 times
42
+ faster than `toml` and 3 times faster than `toml-j0.4`. However a recent
43
+ newcomer [`@ltd/j-toml`](https://www.npmjs.com/package/@ltd/j-toml) has
44
+ appeared with 0.5 support and astoundingly fast parsing speeds for large
45
+ text blocks. All I can say is you'll have to test your specific work loads
46
+ if you want to know which of @iarna/toml and @ltd/j-toml is faster for
47
+ you, as we currently excell in different areas.
48
+ * Careful adherence to spec. Tests go beyond simple coverage.
49
+ * Smallest parser bundle (if you use `@iarna/toml/parse-string`).
50
+ * No deps.
51
+ * Detailed and easy to read error messages‼
52
+
53
+ ```console
54
+ > TOML.parse(src)
55
+ Error: Unexpected character, expecting string, number, datetime, boolean, inline array or inline table at row 6, col 5, pos 87:
56
+ 5: "abc\"" = { abc=123,def="abc" }
57
+ 6> foo=sdkfj
58
+ ^
59
+ 7:
60
+ ```
61
+
62
+ ## TOML.parse(str) → Object [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse.js)
63
+
64
+ Also available with: `require('@iarna/toml/parse-string')`
65
+
66
+ Synchronously parse a TOML string and return an object.
67
+
68
+
69
+ ## TOML.stringify(obj) → String [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/stringify.js)
70
+
71
+ Also available with: `require('@iarna/toml/stringify)`
72
+
73
+ Serialize an object as TOML.
74
+
75
+ ## [your-object].toJSON
76
+
77
+ If an object `TOML.stringify` is serializing has a `toJSON` method then it
78
+ will call it to transform the object before serializing it. This matches
79
+ the behavior of `JSON.stringify`.
80
+
81
+ The one exception to this is that `toJSON` is not called for `Date` objects
82
+ because `JSON` represents dates as strings and TOML can represent them natively.
83
+
84
+ [`moment`](https://www.npmjs.com/package/moment) objects are treated the
85
+ same as native `Date` objects, in this respect.
86
+
87
+ ## TOML.stringify.value(obj) -> String
88
+
89
+ Also available with: `require('@iarna/toml/stringify').value`
90
+
91
+ Serialize a value as TOML would. This is a fragment and not a complete
92
+ valid TOML document.
93
+
94
+ ## Promises and Streaming
95
+
96
+ The parser provides alternative async and streaming interfaces, for times
97
+ that you're working with really absurdly big TOML files and don't want to
98
+ tie-up the event loop while it parses.
99
+
100
+ ### TOML.parse.async(str[, opts]) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-async.js)
101
+
102
+ Also available with: `require('@iarna/toml/parse-async')`
103
+
104
+ `opts.blocksize` is the amount text to parser per pass through the event loop. Defaults to 40kb.
105
+
106
+ Asynchronously parse a TOML string and return a promise of the resulting object.
107
+
108
+ ### TOML.parse.stream(readable) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-readable.js)
109
+
110
+ Also available with: `require('@iarna/toml/parse-stream')`
111
+
112
+ Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
113
+
114
+ ### readable.pipe(TOML.parse.stream()) → Transform [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-through.js)
115
+
116
+ Also available with: `require('@iarna/toml/parse-stream')`
117
+
118
+ Returns a transform stream in object mode. When it completes, emit the
119
+ resulting object. Only one object will ever be emitted.
120
+
121
+ ## Lowlevel Interface [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel.js) [(example w/ parser debugging)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel-debug.js)
122
+
123
+ You construct a parser object, per TOML file you want to process:
124
+
125
+ ```js
126
+ const TOMLParser = require('@iarna/toml/lib/toml-parser.js')
127
+ const parser = new TOMLParser()
128
+ ```
129
+
130
+ Then you call the `parse` method for each chunk as you read them, or in a
131
+ single call:
132
+
133
+ ```js
134
+ parser.parse(`hello = 'world'`)
135
+ ```
136
+
137
+ And finally, you call the `finish` method to complete parsing and retrieve
138
+ the resulting object.
139
+
140
+ ```js
141
+ const data = parser.finish()
142
+ ```
143
+
144
+ Both the `parse` method and `finish` method will throw if they find a
145
+ problem with the string they were given. Error objects thrown from the
146
+ parser have `pos`, `line` and `col` attributes. `TOML.parse` adds a visual
147
+ summary of where in the source string there were issues using
148
+ `parse-pretty-error` and you can too:
149
+
150
+ ```js
151
+ const prettyError = require('./parse-pretty-error.js')
152
+ const newErr = prettyError(err, sourceString)
153
+ ```
154
+
155
+ ## What's Different
156
+
157
+ Version 2 of this module supports TOML 0.5.0. Other modules currently
158
+ published to the npm registry support 0.4.0. 0.5.0 is mostly backwards
159
+ compatible with 0.4.0, but if you have need, you can install @iarna/toml@1
160
+ to get a version of this module that supports 0.4.0. Please see the
161
+ [CHANGELOG](CHANGELOG.md#2.0.0) for details on exactly whats changed.
162
+
163
+ ## TOML we can't do
164
+
165
+ * `-nan` is a valid TOML value and is converted into `NaN`. There is no way to
166
+ produce `-nan` when stringifying. Stringification will produce positive `nan`.
167
+ * Detecting and erroring on invalid utf8 documents: This is because Node's
168
+ UTF8 processing converts invalid sequences into the placeholder character
169
+ and does not have facilities for reporting these as errors instead. We
170
+ _can_ detect the placeholder character, but it's valid to intentionally
171
+ include them in documents, so erroring on them is not great.
172
+ * On versions of Node < 10, very large Integer values will lose precision.
173
+ On Node >=10, bigints are used.
174
+ * Floating/local dates and times are still represented by JavaScript Date
175
+ objects, which don't actually support these concepts. The objects
176
+ returned have been modified so that you can determine what kind of thing
177
+ they are (with `isFloating`, `isDate`, `isTime` properties) and that
178
+ their ISO representation (via `toISOString`) is representative of their
179
+ TOML value. They will correctly round trip if you pass them to
180
+ `TOML.stringify`.
181
+ * Binary, hexadecimal and octal values are converted to ordinary integers and
182
+ will be decimal if you stringify them.
183
+
184
+ ## Changes
185
+
186
+ I write a by hand, honest-to-god,
187
+ [CHANGELOG](https://github.com/iarna/iarna-toml/blob/latest/CHANGELOG.md)
188
+ for this project. It's a description of what went into a release that you
189
+ the consumer of the module could care about, not a list of git commits, so
190
+ please check it out!
191
+
192
+ ## Benchmarks
193
+
194
+ You can run them yourself with:
195
+
196
+ ```console
197
+ $ npm run benchmark
198
+ ```
199
+
200
+ The results below are from my desktop using Node 13.13.0. The library
201
+ versions tested were `@iarna/toml@2.2.4`, `toml-j0.4@1.1.1`, `toml@3.0.0`,
202
+ `@sgarciac/bombadil@2.3.0`, `@ltd/j-toml@0.5.107`, and `fast-toml@0.5.4`. The speed value is
203
+ megabytes-per-second that the parser can process of that document type.
204
+ Bigger is better. The percentage after average results is the margin of error.
205
+
206
+ New here is fast-toml. fast-toml is very fast, for some datatypes, but it
207
+ also is missing most error checking demanded by the spec. For 0.4, it is
208
+ complete except for detail of multiline strings caught by the compliance
209
+ tests. Its support for 0.5 is incomplete. Check out the
210
+ [spec compliance](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html) doc
211
+ for details.
212
+
213
+ As this table is getting a little wide, with how npm and github display it,
214
+ you can also view it seperately in the
215
+ [BENCHMARK](https://shared.by.re-becca.org/misc/BENCHMARK.html) document.
216
+
217
+ | | @iarna/<wbr>toml | toml-j0.4 | toml | @sgarciac/<wbr>bombadil | @ltd/<wbr>j-toml | fast-toml |
218
+ | - | :---------: | :-------: | :--: | :----------------: | :---------: | :-------: |
219
+ | **Overall** | 28MB/sec<br><small>0.35%</small> | 6.5MB/sec<br><small>0.25%</small> | 0.2MB/sec<br><small>0.70%</small> | - | 35MB/sec<br><small>0.23%</small> | - |
220
+ | **Spec Example: v0.4.0** | 26MB/sec<br><small>0.37%</small> | 10MB/sec<br><small>0.27%</small> | 1MB/sec<br><small>0.42%</small> | 1.2MB/sec<br><small>0.95%</small> | 28MB/sec<br><small>0.31%</small> | - |
221
+ | **Spec Example: Hard Unicode** | 64MB/sec<br><small>0.59%</small> | 18MB/sec<br><small>0.12%</small> | 2MB/sec<br><small>0.20%</small> | 0.6MB/sec<br><small>0.53%</small> | 68MB/sec<br><small>0.31%</small> | 78MB/sec<br><small>0.28%</small> |
222
+ | **Types: Array, Inline** | 7.3MB/sec<br><small>0.60%</small> | 4MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>0.91%</small> | 1.3MB/sec<br><small>0.81%</small> | 10MB/sec<br><small>0.35%</small> | 9MB/sec<br><small>0.16%</small> |
223
+ | **Types: Array** | 6.8MB/sec<br><small>0.19%</small> | 6.7MB/sec<br><small>0.15%</small> | 0.2MB/sec<br><small>0.79%</small> | 1.2MB/sec<br><small>0.93%</small> | 8.8MB/sec<br><small>0.47%</small> | 27MB/sec<br><small>0.21%</small> |
224
+ | **Types: Boolean,** | 21MB/sec<br><small>0.20%</small> | 9.4MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>0.96%</small> | 1.8MB/sec<br><small>0.70%</small> | 16MB/sec<br><small>0.20%</small> | 8.4MB/sec<br><small>0.22%</small> |
225
+ | **Types: Datetime** | 18MB/sec<br><small>0.14%</small> | 11MB/sec<br><small>0.15%</small> | 0.3MB/sec<br><small>0.85%</small> | 1.6MB/sec<br><small>0.45%</small> | 9.8MB/sec<br><small>0.48%</small> | 6.5MB/sec<br><small>0.23%</small> |
226
+ | **Types: Float** | 8.8MB/sec<br><small>0.09%</small> | 5.9MB/sec<br><small>0.14%</small> | 0.2MB/sec<br><small>0.51%</small> | 2.1MB/sec<br><small>0.82%</small> | 14MB/sec<br><small>0.15%</small> | 7.9MB/sec<br><small>0.14%</small> |
227
+ | **Types: Int** | 5.9MB/sec<br><small>0.11%</small> | 4.5MB/sec<br><small>0.28%</small> | 0.1MB/sec<br><small>0.78%</small> | 1.5MB/sec<br><small>0.64%</small> | 10MB/sec<br><small>0.14%</small> | 8MB/sec<br><small>0.17%</small> |
228
+ | **Types: Literal String, 7 char** | 26MB/sec<br><small>0.29%</small> | 8.5MB/sec<br><small>0.32%</small> | 0.3MB/sec<br><small>0.84%</small> | 2.3MB/sec<br><small>1.02%</small> | 23MB/sec<br><small>0.15%</small> | 13MB/sec<br><small>0.15%</small> |
229
+ | **Types: Literal String, 92 char** | 46MB/sec<br><small>0.19%</small> | 11MB/sec<br><small>0.20%</small> | 0.3MB/sec<br><small>0.56%</small> | 12MB/sec<br><small>0.92%</small> | 101MB/sec<br><small>0.17%</small> | 75MB/sec<br><small>0.29%</small> |
230
+ | **Types: Literal String, Multiline, 1079 char** | 22MB/sec<br><small>0.42%</small> | 6.7MB/sec<br><small>0.55%</small> | 0.9MB/sec<br><small>0.78%</small> | 44MB/sec<br><small>1.00%</small> | 350MB/sec<br><small>0.16%</small> | 636MB/sec<br><small>0.16%</small> |
231
+ | **Types: Basic String, 7 char** | 25MB/sec<br><small>0.15%</small> | 7.3MB/sec<br><small>0.18%</small> | 0.2MB/sec<br><small>0.96%</small> | 2.2MB/sec<br><small>1.09%</small> | 14MB/sec<br><small>0.16%</small> | 12MB/sec<br><small>0.22%</small> |
232
+ | **Types: Basic String, 92 char** | 43MB/sec<br><small>0.30%</small> | 7.2MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>4.04%</small> | 12MB/sec<br><small>1.33%</small> | 71MB/sec<br><small>0.19%</small> | 70MB/sec<br><small>0.23%</small> |
233
+ | **Types: Basic String, 1079 char** | 24MB/sec<br><small>0.45%</small> | 5.8MB/sec<br><small>0.17%</small> | 0.1MB/sec<br><small>3.64%</small> | 44MB/sec<br><small>1.05%</small> | 93MB/sec<br><small>0.29%</small> | 635MB/sec<br><small>0.28%</small> |
234
+ | **Types: Table, Inline** | 9.7MB/sec<br><small>0.10%</small> | 5.5MB/sec<br><small>0.22%</small> | 0.1MB/sec<br><small>0.87%</small> | 1.4MB/sec<br><small>1.18%</small> | 8.7MB/sec<br><small>0.60%</small> | 8.7MB/sec<br><small>0.22%</small> |
235
+ | **Types: Table** | 7.1MB/sec<br><small>0.14%</small> | 5.6MB/sec<br><small>0.42%</small> | 0.1MB/sec<br><small>0.65%</small> | 1.4MB/sec<br><small>1.11%</small> | 7.4MB/sec<br><small>0.70%</small> | 18MB/sec<br><small>0.20%</small> |
236
+ | **Scaling: Array, Inline, 1000 elements** | 40MB/sec<br><small>0.21%</small> | 2.4MB/sec<br><small>0.19%</small> | 0.1MB/sec<br><small>0.35%</small> | 1.6MB/sec<br><small>1.02%</small> | 17MB/sec<br><small>0.15%</small> | 32MB/sec<br><small>0.16%</small> |
237
+ | **Scaling: Array, Nested, 1000 deep** | 2MB/sec<br><small>0.15%</small> | 1.7MB/sec<br><small>0.26%</small> | 0.3MB/sec<br><small>0.58%</small> | - | 1.8MB/sec<br><small>0.74%</small> | 13MB/sec<br><small>0.20%</small> |
238
+ | **Scaling: Literal String, 40kb** | 61MB/sec<br><small>0.18%</small> | 10MB/sec<br><small>0.15%</small> | 3MB/sec<br><small>0.84%</small> | 12MB/sec<br><small>0.51%</small> | 551MB/sec<br><small>0.44%</small> | 19kMB/sec<br><small>0.19%</small> |
239
+ | **Scaling: Literal String, Multiline, 40kb** | 62MB/sec<br><small>0.16%</small> | 5MB/sec<br><small>0.45%</small> | 0.2MB/sec<br><small>1.70%</small> | 11MB/sec<br><small>0.74%</small> | 291MB/sec<br><small>0.24%</small> | 21kMB/sec<br><small>0.22%</small> |
240
+ | **Scaling: Basic String, Multiline, 40kb** | 62MB/sec<br><small>0.18%</small> | 5.8MB/sec<br><small>0.38%</small> | 2.9MB/sec<br><small>0.86%</small> | 11MB/sec<br><small>0.41%</small> | 949MB/sec<br><small>0.44%</small> | 26kMB/sec<br><small>0.16%</small> |
241
+ | **Scaling: Basic String, 40kb** | 59MB/sec<br><small>0.20%</small> | 6.3MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>1.95%</small> | 12MB/sec<br><small>0.44%</small> | 508MB/sec<br><small>0.35%</small> | 18kMB/sec<br><small>0.15%</small> |
242
+ | **Scaling: Table, Inline, 1000 elements** | 28MB/sec<br><small>0.12%</small> | 8.2MB/sec<br><small>0.19%</small> | 0.3MB/sec<br><small>0.89%</small> | 2.3MB/sec<br><small>1.14%</small> | 5.3MB/sec<br><small>0.24%</small> | 13MB/sec<br><small>0.20%</small> |
243
+ | **Scaling: Table, Inline, Nested, 1000 deep** | 7.8MB/sec<br><small>0.28%</small> | 5MB/sec<br><small>0.20%</small> | 0.1MB/sec<br><small>0.84%</small> | - | 3.2MB/sec<br><small>0.52%</small> | 10MB/sec<br><small>0.23%</small> |
244
+
245
+ ## Tests
246
+
247
+ The test suite is maintained at 100% coverage: [![Coverage Status](https://coveralls.io/repos/github/iarna/iarna-toml/badge.svg)](https://coveralls.io/github/iarna/iarna-toml)
248
+
249
+ The spec was carefully hand converted into a series of test framework
250
+ independent (and mostly language independent) assertions, as pairs of TOML
251
+ and YAML files. You can find those files here:
252
+ [spec-test](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test/).
253
+ A number of examples of invalid Unicode were also written, but are difficult
254
+ to make use of in Node.js where Unicode errors are silently hidden. You can
255
+ find those here: [spec-test-disabled](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test-disabled/).
256
+
257
+ Further tests were written to increase coverage to 100%, these may be more
258
+ implementation specific, but they can be found in [coverage](https://github.com/iarna/iarna-toml/blob/latest/test/coverage.js) and
259
+ [coverage-error](https://github.com/iarna/iarna-toml/blob/latest/test/coverage-error.js).
260
+
261
+ I've also written some quality assurance style tests, which don't contribute
262
+ to coverage but do cover scenarios that could easily be problematic for some
263
+ implementations can be found in:
264
+ [test/qa.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa.js) and
265
+ [test/qa-error.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa-error.js).
266
+
267
+ All of the official example files from the TOML spec are run through this
268
+ parser and compared to the official YAML files when available. These files are from the TOML spec as of:
269
+ [357a4ba6](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc)
270
+ and specifically are:
271
+
272
+ * [github.com/toml-lang/toml/tree/357a4ba6/examples](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/examples)
273
+ * [github.com/toml-lang/toml/tree/357a4ba6/tests](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/tests)
274
+
275
+ The stringifier is tested by round-tripping these same files, asserting that
276
+ `TOML.parse(sourcefile)` deepEqual
277
+ `TOML.parse(TOML.stringify(TOML.parse(sourcefile))`. This is done in
278
+ [test/roundtrip-examples.js](https://github.com/iarna/iarna-toml/blob/latest/test/round-tripping.js)
279
+ There are also some tests written to complete coverage from stringification in:
280
+ [test/stringify.js](https://github.com/iarna/iarna-toml/blob/latest/test/stringify.js)
281
+
282
+ Tests for the async and streaming interfaces are in [test/async.js](https://github.com/iarna/iarna-toml/blob/latest/test/async.js) and [test/stream.js](https://github.com/iarna/iarna-toml/blob/latest/test/stream.js) respectively.
283
+
284
+ Tests for the parsers debugging mode live in [test/devel.js](https://github.com/iarna/iarna-toml/blob/latest/test/devel.js).
285
+
286
+ And finally, many more stringification tests were borrowed from [@othiym23](https://github.com/othiym23)'s
287
+ [toml-stream](https://npmjs.com/package/toml-stream) module. They were fetched as of
288
+ [b6f1e26b572d49742d49fa6a6d11524d003441fa](https://github.com/othiym23/toml-stream/tree/b6f1e26b572d49742d49fa6a6d11524d003441fa/test) and live in
289
+ [test/toml-stream](https://github.com/iarna/iarna-toml/blob/latest/test/toml-stream/).
290
+
291
+ ## Improvements to make
292
+
293
+ * In stringify:
294
+ * Any way to produce comments. As a JSON stand-in I'm not too worried
295
+ about this. That said, a document orientated fork is something I'd like
296
+ to look at eventually…
297
+ * Stringification could use some work on its error reporting. It reports
298
+ _what's_ wrong, but not where in your data structure it was.
299
+ * Further optimize the parser:
300
+ * There are some debugging assertions left in the main parser, these should be moved to a subclass.
301
+ * Make the whole debugging parser thing work as a mixin instead of as a superclass.
@@ -0,0 +1,57 @@
1
+ import { Transform } from "stream";
2
+
3
+ type JsonArray = boolean[] | number[] | string[] | JsonMap[] | Date[]
4
+ type AnyJson = boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]
5
+
6
+ interface JsonMap {
7
+ [key: string]: AnyJson;
8
+ }
9
+
10
+ interface ParseOptions {
11
+ /**
12
+ * The amount text to parser per pass through the event loop. Defaults to 40kb (`40000`).
13
+ */
14
+ blocksize: number
15
+ }
16
+
17
+ interface FuncParse {
18
+ /**
19
+ * Synchronously parse a TOML string and return an object.
20
+ */
21
+ (toml: string): JsonMap
22
+
23
+ /**
24
+ * Asynchronously parse a TOML string and return a promise of the resulting object.
25
+ */
26
+ async (toml: string, options?: ParseOptions): Promise<JsonMap>
27
+
28
+ /**
29
+ * Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
30
+ */
31
+ stream (readable: NodeJS.ReadableStream): Promise<JsonMap>
32
+ stream (): Transform
33
+ }
34
+
35
+ interface FuncStringify {
36
+ /**
37
+ * Serialize an object as TOML.
38
+ *
39
+ * If an object `TOML.stringify` is serializing has a `toJSON` method
40
+ * then it will call it to transform the object before serializing it.
41
+ * This matches the behavior of JSON.stringify.
42
+ *
43
+ * The one exception to this is that `toJSON` is not called for `Date` objects
44
+ * because JSON represents dates as strings and TOML can represent them natively.
45
+ *
46
+ * `moment` objects are treated the same as native `Date` objects, in this respect.
47
+ */
48
+ (obj: JsonMap): string
49
+
50
+ /**
51
+ * Serialize a value as TOML would. This is a fragment and not a complete valid TOML document.
52
+ */
53
+ value (any: AnyJson): string
54
+ }
55
+
56
+ export const parse: FuncParse
57
+ export const stringify: FuncStringify
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+ const f = require('./format-num.js')
3
+ const DateTime = global.Date
4
+
5
+ class Date extends DateTime {
6
+ constructor (value) {
7
+ super(value)
8
+ this.isDate = true
9
+ }
10
+ toISOString () {
11
+ return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
12
+ }
13
+ }
14
+
15
+ module.exports = value => {
16
+ const date = new Date(value)
17
+ /* istanbul ignore if */
18
+ if (isNaN(date)) {
19
+ throw new TypeError('Invalid Datetime')
20
+ } else {
21
+ return date
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+ const f = require('./format-num.js')
3
+
4
+ class FloatingDateTime extends Date {
5
+ constructor (value) {
6
+ super(value + 'Z')
7
+ this.isFloating = true
8
+ }
9
+ toISOString () {
10
+ const date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
11
+ const time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
12
+ return `${date}T${time}`
13
+ }
14
+ }
15
+
16
+ module.exports = value => {
17
+ const date = new FloatingDateTime(value)
18
+ /* istanbul ignore if */
19
+ if (isNaN(date)) {
20
+ throw new TypeError('Invalid Datetime')
21
+ } else {
22
+ return date
23
+ }
24
+ }
@@ -0,0 +1,10 @@
1
+ 'use strict'
2
+ module.exports = value => {
3
+ const date = new Date(value)
4
+ /* istanbul ignore if */
5
+ if (isNaN(date)) {
6
+ throw new TypeError('Invalid Datetime')
7
+ } else {
8
+ return date
9
+ }
10
+ }
@@ -0,0 +1,22 @@
1
+ 'use strict'
2
+ const f = require('./format-num.js')
3
+
4
+ class Time extends Date {
5
+ constructor (value) {
6
+ super(`0000-01-01T${value}Z`)
7
+ this.isTime = true
8
+ }
9
+ toISOString () {
10
+ return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
11
+ }
12
+ }
13
+
14
+ module.exports = value => {
15
+ const date = new Time(value)
16
+ /* istanbul ignore if */
17
+ if (isNaN(date)) {
18
+ throw new TypeError('Invalid Datetime')
19
+ } else {
20
+ return date
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ 'use strict'
2
+ module.exports = (d, num) => {
3
+ num = String(num)
4
+ while (num.length < d) num = '0' + num
5
+ return num
6
+ }
@@ -0,0 +1,60 @@
1
+ 'use strict'
2
+ const Parser = require('./parser.js')
3
+ const util = require('util')
4
+
5
+ const dump = _ => util.inspect(_, {colors: true, depth: 10, breakLength: Infinity})
6
+ class DebugParser extends Parser {
7
+ stateName (state) {
8
+ // istanbul ignore next
9
+ return (state.parser && state.parser.name) || state.name || ('anonymous')
10
+ }
11
+ runOne () {
12
+ const callStack = this.stack.concat(this.state).map(_ => this.stateName(_)).join(' <- ')
13
+ console.log('RUN', callStack, dump({line: this.line, col: this.col, char: this.char, ret: this.state.returned}))
14
+ return super.runOne()
15
+ }
16
+ finish () {
17
+ const obj = super.finish()
18
+ // istanbul ignore if
19
+ if (this.stack.length !== 0) {
20
+ throw new Parser.Error('All states did not return by end of stream')
21
+ }
22
+ return obj
23
+ }
24
+ callStack () {
25
+ const callStack = this.stack.map(_ => this.stateName(_)).join(' ').replace(/\S/g, ' ')
26
+ return callStack ? callStack + ' ' : ''
27
+ }
28
+ next (fn) {
29
+ console.log(' ', this.callStack(), 'NEXT', this.stateName(fn))
30
+ return super.next(fn)
31
+ }
32
+ goto (fn) {
33
+ console.log(' ', this.callStack(), 'GOTO', this.stateName(fn))
34
+ super.next(fn)
35
+ return false
36
+ }
37
+ call (fn, returnWith) {
38
+ console.log(' ', this.callStack(), 'CALL', fn.name, returnWith ? '-> ' + returnWith.name : '')
39
+ if (returnWith) super.next(returnWith)
40
+ this.stack.push(this.state)
41
+ this.state = {parser: fn, buf: '', returned: null}
42
+ }
43
+ callNow (fn, returnWith) {
44
+ console.log(' ', this.callStack(), 'CALLNOW', fn.name, returnWith ? '-> ' + returnWith.name : '')
45
+ if (returnWith) super.next(returnWith)
46
+ this.stack.push(this.state)
47
+ this.state = {parser: fn, buf: '', returned: null}
48
+ return false
49
+ }
50
+ return (value) {
51
+ console.log(' ', this.callStack(), 'RETURN')
52
+ return super.return(value)
53
+ }
54
+ returnNow (value) {
55
+ console.log(' ', this.callStack(), 'RETURNNOW')
56
+ super.return(value)
57
+ return false
58
+ }
59
+ }
60
+ module.exports = DebugParser
@@ -0,0 +1,127 @@
1
+ 'use strict'
2
+ const ParserEND = 0x110000
3
+ class ParserError extends Error {
4
+ /* istanbul ignore next */
5
+ constructor (msg, filename, linenumber) {
6
+ super('[ParserError] ' + msg, filename, linenumber)
7
+ this.name = 'ParserError'
8
+ this.code = 'ParserError'
9
+ if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError)
10
+ }
11
+ }
12
+ class State {
13
+ constructor (parser) {
14
+ this.parser = parser
15
+ this.buf = ''
16
+ this.returned = null
17
+ this.result = null
18
+ this.resultTable = null
19
+ this.resultArr = null
20
+ }
21
+ }
22
+ class Parser {
23
+ constructor () {
24
+ this.pos = 0
25
+ this.col = 0
26
+ this.line = 0
27
+ this.obj = {}
28
+ this.ctx = this.obj
29
+ this.stack = []
30
+ this._buf = ''
31
+ this.char = null
32
+ this.ii = 0
33
+ this.state = new State(this.parseStart)
34
+ }
35
+
36
+ parse (str) {
37
+ /* istanbul ignore next */
38
+ if (str.length === 0 || str.length == null) return
39
+
40
+ this._buf = String(str)
41
+ this.ii = -1
42
+ this.char = -1
43
+ let getNext
44
+ while (getNext === false || this.nextChar()) {
45
+ getNext = this.runOne()
46
+ }
47
+ this._buf = null
48
+ }
49
+ nextChar () {
50
+ if (this.char === 0x0A) {
51
+ ++this.line
52
+ this.col = -1
53
+ }
54
+ ++this.ii
55
+ this.char = this._buf.codePointAt(this.ii)
56
+ ++this.pos
57
+ ++this.col
58
+ return this.haveBuffer()
59
+ }
60
+ haveBuffer () {
61
+ return this.ii < this._buf.length
62
+ }
63
+ runOne () {
64
+ return this.state.parser.call(this, this.state.returned)
65
+ }
66
+ finish () {
67
+ this.char = ParserEND
68
+ let last
69
+ do {
70
+ last = this.state.parser
71
+ this.runOne()
72
+ } while (this.state.parser !== last)
73
+
74
+ this.ctx = null
75
+ this.state = null
76
+ this._buf = null
77
+
78
+ return this.obj
79
+ }
80
+ next (fn) {
81
+ /* istanbul ignore next */
82
+ if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn))
83
+ this.state.parser = fn
84
+ }
85
+ goto (fn) {
86
+ this.next(fn)
87
+ return this.runOne()
88
+ }
89
+ call (fn, returnWith) {
90
+ if (returnWith) this.next(returnWith)
91
+ this.stack.push(this.state)
92
+ this.state = new State(fn)
93
+ }
94
+ callNow (fn, returnWith) {
95
+ this.call(fn, returnWith)
96
+ return this.runOne()
97
+ }
98
+ return (value) {
99
+ /* istanbul ignore next */
100
+ if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'))
101
+ if (value === undefined) value = this.state.buf
102
+ this.state = this.stack.pop()
103
+ this.state.returned = value
104
+ }
105
+ returnNow (value) {
106
+ this.return(value)
107
+ return this.runOne()
108
+ }
109
+ consume () {
110
+ /* istanbul ignore next */
111
+ if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'))
112
+ this.state.buf += this._buf[this.ii]
113
+ }
114
+ error (err) {
115
+ err.line = this.line
116
+ err.col = this.col
117
+ err.pos = this.pos
118
+ return err
119
+ }
120
+ /* istanbul ignore next */
121
+ parseStart () {
122
+ throw new ParserError('Must declare a parseStart method')
123
+ }
124
+ }
125
+ Parser.END = ParserEND
126
+ Parser.Error = ParserError
127
+ module.exports = Parser